OfficeIMO

API Reference

Class

MarkdownFence

Namespace OfficeIMO.Markdown
Assembly OfficeIMO.Markdown
Modifiers static

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) #
Returns: String

Applies 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 requiredposition: 0
Markdown text to transform.
transformer System.Func{System.String,System.String} requiredposition: 1
Transform to apply outside fenced code blocks.

Returns

Transformed markdown with fenced content preserved verbatim.

public static String BuildSafeFence(String content, Int32 minimumLength = 3) #
Returns: String

Builds a code-fence marker that cannot be prematurely closed by runs inside content.

Parameters

content System.String requiredposition: 0
Code content.
minimumLength System.Int32 = 3 optionalposition: 1
Minimum fence length (defaults to 3).

Returns

Safe fence marker (backticks or tildes).

public static Int32 LongestRun(String text, Char marker) #
Returns: Int32

Returns the longest contiguous run of marker within text.

Parameters

text System.String requiredposition: 0
marker System.Char requiredposition: 1
public static Boolean TryReadContainerAwareFenceRun(String line, out String linePrefix, out Char marker, out Int32 runLength, out String suffix) #
Returns: Boolean

Tries 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 requiredposition: 0
Line to inspect.
linePrefix System.String@ requiredposition: 1
Leading indentation and blockquote markers preceding the fence.
marker System.Char@ requiredposition: 2
Fence marker (` or ~).
runLength System.Int32@ requiredposition: 3
Fence run length.
suffix System.String@ requiredposition: 4
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) #
Returns: Boolean

Tries to parse a fence run from a markdown line.

Parameters

line System.String requiredposition: 0
Line to inspect.
marker System.Char@ requiredposition: 1
Fence marker (` or ~).
runLength System.Int32@ requiredposition: 2
Fence run length.
suffix System.String@ requiredposition: 3
Any trailing text after the marker run (for example language token).

Returns

true when the line starts with a valid fence run; otherwise false.