⚠️ This is pre-release documentation for v3. For stable docs, visit v2.
Skip to content

@tmlmt/cooklang-parser / formatCodeFrame

Function: formatCodeFrame() ​

formatCodeFrame(span, source, label?): string

Renders a source span as a code frame (location marker, source lines and caret pointers), without any diagnostic header.

Parameters ​

span ​

DiagnosticSourceSpan

The span to render. Positions refer to source.

source ​

string

The original text the span refers to.

label? ​

string = "recipe"

Optional label shown in the location marker (default "recipe").

Returns ​

string

A multi-line plain-text string.