List of functions in the ude.renderers.markdown_safety namespace.

Entity NameDescription
link_destination_is_unsafeTrue when a link destination has a scheme that is not in SAFE_LINK_SCHEMES, after the tricks a browser (or a Markdown renderer) undoes: HTML entities (javascript:), percent-escapes, invisible and control characters, letter case.
_destination_spanThe (start, end) of the link destination that begins after the “(” at text[start - 1]: either <...> or a run without whitespace in which parentheses balance (CommonMark), with backslash escapes.
neutralize_unsafe_linksReplaces the destination of every inline link or image and every reference definition whose scheme is unsafe by #; the visible text of the link stays. Applied to the prose between fenced blocks, code spans included: a link written inside backticks is literal text, so changing it costs nothing and removes any doubt about what is code.
_escape_angle_brackets
_code_spansThe (start, end) of every inline code span of one line (a backtick run closed by the nearest run of the same length), or None when some backtick run finds no partner on the line: that run may pair with one on another line, or be literal, and parsers disagree about which.
_escape_lineEscapes < and > in one line, keeping the content of the given code spans (None = no span is trusted and everything is escaped). Escaping inside a real span only shows the entity as text: a cosmetic cost.
_escape_prose_blockThe prose between two fenced blocks: links with an unsafe destination are neutralized over the whole block (a destination may start on the line after the opening parenthesis), then the lines are escaped. Code spans are trusted only if EVERY line of the block is unambiguous (_code_spans): an unpaired run on one line can pair with a run on the next, which moves the boundary of the spans there, so one ambiguous line makes the whole block plain prose.
escape_markdown_proseThe documentation text made safe for any Markdown renderer (see the module docstring). Fenced code blocks (a line of three or more backticks or tildes opens one, a line of at least as many of the same character closes it, an unclosed fence runs to the end) are returned unchanged; so are unambiguous inline code spans (_escape_line).
yaml_stringA value for a YAML front matter line: a double-quoted scalar in which a quote, a backslash and every control character are escaped (K13, CR-12). A JSON string is a valid YAML double-quoted scalar; the three Unicode line separators that JSON leaves as they are would break a line in YAML, so they are escaped too.
code_spanAn inline code span holding text that the text itself cannot close: the fence is one backtick longer than the longest backtick run inside, and a space pads a text that starts or ends with a backtick (CommonMark). Line breaks become spaces, because a code span lives inside one paragraph.

Generated with Flude

Copyright © 2026

Directory & Entity Index

Entity NameSummary / Description
_code_spans function

The (start, end) of every inline code span of one line (a backtick run closed by the nearest run of the same length), or None when some backtick run finds no partner on the line: that run may pair with one on another line, or be literal, and parsers disagree about which.

Methods

_code_spans

_code_spans(line: str) -> Optional[List[Tuple[int, int]]]

The (start, end) of every inline code span of one line (a backtick run closed by the nearest run of the same length), or None when some backtick run finds no partner on the line: that run may pair with one on another line, or be literal, and parsers disagree about which.

_destination_span function

The (start, end) of the link destination that begins after the “(” at text[start - 1]: either <...> or a run without whitespace in which parentheses balance (CommonMark), with backslash escapes.

Methods

_destination_span

_destination_span(text: str, start: int) -> Optional[Tuple[int, int]]

The (start, end) of the link destination that begins after the “(” at text[start - 1]: either <...> or a run without whitespace in which parentheses balance (CommonMark), with backslash escapes.

_escape_angle_brackets function

Methods

_escape_angle_brackets

_escape_angle_brackets(text: str) -> str

ParameterTypeDescription
textstr

Generated with Flude

Copyright © 2026

_escape_line function

Escapes < and > in one line, keeping the content of the given code spans (None = no span is trusted and everything is escaped). Escaping inside a real span only shows the entity as text: a cosmetic cost.

Methods

_escape_line

_escape_line(line: str, spans: Optional]]) -> str

Escapes < and > in one line, keeping the content of the given code spans (None = no span is trusted and everything is escaped). Escaping inside a real span only shows the entity as text: a cosmetic cost.

_escape_prose_block function

The prose between two fenced blocks: links with an unsafe destination are neutralized over the whole block (a destination may start on the line after the opening parenthesis), then the lines are escaped. Code spans are trusted only if EVERY line of the block is unambiguous (_code_spans): an unpaired run on one line can pair with a run on the next, which moves the boundary of the spans there, so one ambiguous line makes the whole block plain prose.

code_span function

An inline code span holding text that the text itself cannot close: the fence is one backtick longer than the longest backtick run inside, and a space pads a text that starts or ends with a backtick (CommonMark). Line breaks become spaces, because a code span lives inside one paragraph.

Methods

code_span

code_span(text: object) -> str

An inline code span holding text that the text itself cannot close: the fence is one backtick longer than the longest backtick run inside, and a space pads a text that starts or ends with a backtick (CommonMark). Line breaks become spaces, because a code span lives inside one paragraph.

escape_markdown_prose function

The documentation text made safe for any Markdown renderer (see the module docstring). Fenced code blocks (a line of three or more backticks or tildes opens one, a line of at least as many of the same character closes it, an unclosed fence runs to the end) are returned unchanged; so are unambiguous inline code spans (_escape_line).

Methods

escape_markdown_prose

escape_markdown_prose(text: str) -> str

The documentation text made safe for any Markdown renderer (see the module docstring). Fenced code blocks (a line of three or more backticks or tildes opens one, a line of at least as many of the same character closes it, an unclosed fence runs to the end) are returned unchanged; so are unambiguous inline code spans (_escape_line).

link_destination_is_unsafe function

True when a link destination has a scheme that is not in SAFE_LINK_SCHEMES, after the tricks a browser (or a Markdown renderer) undoes: HTML entities (&#106;avascript:), percent-escapes, invisible and control characters, letter case.

Methods

link_destination_is_unsafe(destination: str) -> bool

True when a link destination has a scheme that is not in SAFE_LINK_SCHEMES, after the tricks a browser (or a Markdown renderer) undoes: HTML entities (&#106;avascript:), percent-escapes, invisible and control characters, letter case.

neutralize_unsafe_links function

Replaces the destination of every inline link or image and every reference definition whose scheme is unsafe by #; the visible text of the link stays. Applied to the prose between fenced blocks, code spans included: a link written inside backticks is literal text, so changing it costs nothing and removes any doubt about what is code.

Methods

neutralize_unsafe_links(text: str) -> str

Replaces the destination of every inline link or image and every reference definition whose scheme is unsafe by #; the visible text of the link stays. Applied to the prose between fenced blocks, code spans included: a link written inside backticks is literal text, so changing it costs nothing and removes any doubt about what is code.

yaml_string function

A value for a YAML front matter line: a double-quoted scalar in which a quote, a backslash and every control character are escaped (K13, CR-12). A JSON string is a valid YAML double-quoted scalar; the three Unicode line separators that JSON leaves as they are would break a line in YAML, so they are escaped too.

Methods

yaml_string

yaml_string(text: object) -> str

A value for a YAML front matter line: a double-quoted scalar in which a quote, a backslash and every control character are escaped (K13, CR-12). A JSON string is a valid YAML double-quoted scalar; the three Unicode line separators that JSON leaves as they are would break a line in YAML, so they are escaped too.