Skip to main content

Module fallback

Module fallback 

Source
Expand description

docling-core’s FormattingFallbackMode (docling-core#661, #1205): how the Markdown export renders the formatting Markdown has no syntax for — underline, subscript and superscript. none (the default) drops it, as every docling Markdown has; html writes <u>…</u>, <sub>…</sub> and <sup>…</sup> (MarkdownParams.formatting_fallback_mode=HTML), in docling-core’s decoration order — bold, italic, underline, strikethrough, sub/superscript, then the link.

The flat nodes carry Markdown the backends rendered at conversion time, by when a run’s underline or script is gone. So the fallback is decided there too: while a conversion runs with_fallback (the converter’s markdown_formatting_fallback(Html)), a backend’s run renderer wraps such a run in invisible marks — Unicode noncharacters, which no interchanged text holds — through underline and script. The Markdown export turns the marks into the tags (render); every other export strips them (strip): DocLang, LaTeX, the chunks and the plain text read the same node text, and keep their own rendering of the runs (or none). Without the fallback no mark is ever written, so the default output is untouched.

Enums§

FormattingFallback
docling-core’s FormattingFallbackMode.

Functions§

active
Whether the current conversion writes the marks.
render
The Markdown export’s view of node text: the marks as tags under FormattingFallback::Html, dropped otherwise.
script
A run’s Markdown text with its script — wrapped for <sub> / <sup> under the fallback, unchanged otherwise. Call it after strikethrough, before the link (docling-core’s serialize_subscript / _superscript).
strip
text without the marks — every export but Markdown.
strip_owned
strip on an owned string, without a copy when there is nothing to do.
strip_value
strip over every string of a JSON value.
underline
An underlined run’s Markdown text — wrapped for <u> under the fallback, unchanged otherwise. Call it where docling-core’s serialize_underline sits: after italic, before strikethrough.
with_fallback
Run f — a backend’s conversion — with the HTML fallback on (on) or off; the previous state is restored afterwards, also on a panic.