Documentation
¶
Overview ¶
Package fences provides utilities for detecting markdown code regions (fenced code blocks and inline code spans) and applying transformations only to text outside those regions.
This prevents special tokens like $1, $@, or @file from being interpreted when they appear inside ``` fences, ~~~ fences, or `inline` code spans.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ranges ¶
Ranges returns byte ranges [start, end) of fenced code blocks in content. Recognises both backtick (```) and tilde (~~~) fences, with optional leading indentation (up to 3 spaces) and optional info strings. An unclosed fence extends to the end of content.
func ReplaceOutside ¶
ReplaceOutside applies fn to each text segment that is outside fenced code blocks and inline code spans, leaving code content unchanged. This is the primary entry point for callers that need to do regex replacement only on non-code text.
func StripCode ¶
StripCode returns content with fenced code blocks and inline code spans removed. Useful for detection/matching where only non-code text matters.
func StripFenced ¶
StripFenced returns content with fenced code block regions removed. Useful for detection/matching where only non-fenced text matters. NOTE: this does NOT strip inline code spans; use StripCode for both.
Types ¶
This section is empty.