Docs · API reference · Verso.Extensions.Utilities

VariableSubstitution Class#

Shared utility for @variable token substitution used by HTML and Mermaid kernels. Uses the same @(\w+) pattern as SQL parameter binding.

public static class VariableSubstitution

Inheritance System.Object → VariableSubstitution

Methods#

Apply(string, IVariableStore) Method#

Replaces @variableName tokens with System.Object.ToString values from the variable store. @@ is escaped to a literal @. Unresolved variables are left as-is.

public static string Apply(string source, Verso.Abstractions.IVariableStore variables);

Parameters#

source System.String

The source text containing @variable tokens.

variables IVariableStore

The variable store to resolve values from.

Returns#

System.String
The source text with resolved variables substituted.

FindUnresolved(string, IVariableStore) Method#

Returns the positions of unresolved @variable tokens in the source text.

public static System.Collections.Generic.IReadOnlyList<(string Name,int Offset,int Length)> FindUnresolved(string source, Verso.Abstractions.IVariableStore variables);

Parameters#

source System.String

The source text to scan.

variables IVariableStore

The variable store to check against.

Returns#

System.Collections.Generic.IReadOnlyList<<System.String,System.Int32,System.Int32>>
A list of (VariableName, Offset, Length) tuples for each unresolved variable.