API Reference
MarkdownFence
Helpers for reading markdown fenced-code boundaries and choosing non-colliding fences.
Inheritance
- Object
- MarkdownFence
Methods
public static String ApplyTransformOutsideFencedCodeBlocks(String input, Func<String, String> transformer) #StringApplies a text transformation only to segments outside fenced code blocks while preserving container-aware fence boundaries such as blockquoted or indented fences.
Parameters
- input System.String
- Markdown text to transform.
- transformer System.Func{System.String,System.String}
- Transform to apply outside fenced code blocks.
Returns
Transformed markdown with fenced content preserved verbatim.
public static String BuildSafeFence(String content, Int32 minimumLength = 3) #StringBuilds a code-fence marker that cannot be prematurely closed by runs inside content.
Parameters
- content System.String
- Code content.
- minimumLength System.Int32 = 3
- Minimum fence length (defaults to 3).
Returns
Safe fence marker (backticks or tildes).
public static Int32 LongestRun(String text, Char marker) #Int32Returns the longest contiguous run of marker within text.
Parameters
- text System.String
- marker System.Char
public static Boolean TryReadContainerAwareFenceRun(String line, out String linePrefix, out Char marker, out Int32 runLength, out String suffix) #BooleanTries to parse a fence run from a line that may be prefixed by blockquote container markers and indentation, returning the preserved prefix separately.
Parameters
- line System.String
- Line to inspect.
- linePrefix System.String@
- Leading indentation and blockquote markers preceding the fence.
- marker System.Char@
- Fence marker (` or ~).
- runLength System.Int32@
- Fence run length.
- suffix System.String@
- Any trailing text after the marker run (for example language token).
Returns
true when the line contains a valid fence run after container prefixes; otherwise false.
public static Boolean TryReadFenceRun(String line, out Char marker, out Int32 runLength, out String suffix) #BooleanTries to parse a fence run from a markdown line.
Parameters
- line System.String
- Line to inspect.
- marker System.Char@
- Fence marker (` or ~).
- runLength System.Int32@
- Fence run length.
- suffix System.String@
- Any trailing text after the marker run (for example language token).
Returns
true when the line starts with a valid fence run; otherwise false.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object