BeckCodeBlockPreprocessor
Pennington.Beck
Renders a ```beck fence to a static, self-animating inline <svg> at render time via the pure-C# Beck engine — no client JavaScript. Two fence forms are supported:
```beck— the fence body is inline Beck YAML, rendered directly.```beck:symbol— the body is one file path per line (resolved againstContentRoot, like the tree-sitter:symbolembed), whose YAML is read and rendered. A diagram can live in one shared.beck.yamland appear as both highlighted source and a live render from that single file.
A comma-separated flag tail tunes the render: ```beck,static forces the fully-revealed static frame, ```beck,scrub drives the choreography from scroll position, and ```beck,style=sketch overrides meta.style on the document before rendering. Flags combine with the file-embed form (```beck:symbol,static).
The emitted SVG needs no wiring: it keys dark mode off the host's markers (the ancestor [data-theme] by default; configurable via SvgRenderOptions.ThemeHooks) and its --beck-* tokens fall back to the host's --color-* palette, so each diagram adopts the live site colors. Each render lands in a <div class="beck-embed"> (beck-embed--error on failure) for the host to frame with its own CSS.
Properties
Priorityint- Higher runs first; beats the tree-sitter preprocessor (100) so a
beck:symbolfence is handled here, never mistaken for a source embed.
Constructors
BeckCodeBlockPreprocessor
#public BeckCodeBlockPreprocessor(BeckOptions options, IHttpContextAccessor httpContextAccessor)
Creates the preprocessor wired to the host's render options and the per-request diagnostics accessor.
Parameters
optionsBeckOptionshttpContextAccessorIHttpContextAccessor
Methods
TryProcess
#public CodeBlockPreprocessResult TryProcess(string code, string languageId)
Attempts to preprocess a code block. Returns a result if handled, or null to pass through.
Parameters
codestringlanguageIdstring
Returns
CodeBlockPreprocessResultPennington.Beck.BeckCodeBlockPreprocessor
namespace Pennington.Beck;
/// Renders a ```beck fence to a static, self-animating inline <svg> at render time via the pure-C# Beck engine — no client JavaScript. Two fence forms are supported: ```beck — the fence body is inline Beck YAML, rendered directly.```beck:symbol — the body is one file path per line (resolved against ContentRoot, like the tree-sitter :symbol embed), whose YAML is read and rendered. A diagram can live in one shared .beck.yaml and appear as both highlighted source and a live render from that single file.
A comma-separated flag tail tunes the render: ```beck,static forces the fully-revealed static frame, ```beck,scrub drives the choreography from scroll position, and ```beck,style=sketch overrides meta.style on the document before rendering. Flags combine with the file-embed form (```beck:symbol,static). The emitted SVG needs no wiring: it keys dark mode off the host's markers (the ancestor [data-theme] by default; configurable via SvgRenderOptions.ThemeHooks) and its --beck-* tokens fall back to the host's --color-* palette, so each diagram adopts the live site colors. Each render lands in a <div class="beck-embed"> (beck-embed--error on failure) for the host to frame with its own CSS.
public class BeckCodeBlockPreprocessor
{
/// Creates the preprocessor wired to the host's render options and the per-request diagnostics accessor.
public BeckCodeBlockPreprocessor(BeckOptions options, IHttpContextAccessor httpContextAccessor)
;
/// Higher runs first; beats the tree-sitter preprocessor (100) so a beck:symbol fence is handled here, never mistaken for a source embed.
public int Priority { get; }
/// Attempts to preprocess a code block. Returns a result if handled, or null to pass through.
public CodeBlockPreprocessResult TryProcess(string code, string languageId)
;
}