Markdown Conversion¶
Markdown conversion utilities for TeXSmith.
MarkdownConversionError ¶
Bases: Exception
Raised when Markdown cannot be converted into HTML.
MarkdownDocument
dataclass
¶
MarkdownDocument(html: str, front_matter: dict[str, Any])
Result of converting Markdown into HTML.
deduplicate_markdown_extensions ¶
deduplicate_markdown_extensions(
values: Iterable[str],
) -> list[str]
Remove duplicate extensions while preserving order and case.
Source code in src/texsmith/adapters/markdown/__init__.py
160 161 162 163 164 165 166 167 168 169 170 171 172 | |
normalize_markdown_extensions ¶
normalize_markdown_extensions(
values: Iterable[str] | str | None,
) -> list[str]
Normalise extension names from CLI-friendly strings into a flat list.
Source code in src/texsmith/adapters/markdown/__init__.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
render_markdown ¶
render_markdown(
source: str,
extensions: Sequence[str] | None = None,
*,
base_path: str | Path | None = None,
) -> MarkdownDocument
Convert Markdown source into HTML while collecting front matter.
Source code in src/texsmith/adapters/markdown/__init__.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
resolve_markdown_extensions ¶
resolve_markdown_extensions(
requested: Iterable[str] | None,
disabled: Iterable[str] | None,
*,
template: Iterable[str] | None = None,
) -> list[str]
Return the active Markdown extension list after applying overrides.
template carries extensions declared by the selected template's manifest.
They are layered on top of the defaults but below the CLI-requested ones, and
can still be turned off through disabled (--disable-extension).
Source code in src/texsmith/adapters/markdown/__init__.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
split_front_matter ¶
split_front_matter(
source: str,
) -> tuple[dict[str, Any], str]
Split YAML front matter from Markdown content, returning metadata and body.
Source code in src/texsmith/adapters/markdown/__init__.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
TeXSmith's bundled Python-Markdown extensions.
Each submodule ships a markdown.Extension (and, for index, an MkDocs
plugin). The authoritative list of extensions enabled by the conversion
pipeline lives in
:data:texsmith.adapters.markdown.DEFAULT_MARKDOWN_EXTENSIONS; the same entries
are also exposed to third-party Markdown/MkDocs setups via the entry points
declared in pyproject.toml.
Extension to capture undefined Markdown footnotes.
MissingFootnotesExtension ¶
MissingFootnotesExtension(**kwargs: Any)
Bases: Extension
Detect footnote references lacking explicit definitions.
Source code in src/texsmith/extensions/missing_footnotes.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
build_placeholder ¶
build_placeholder(
identifier: str, pattern: Any
) -> ElementTree.Element
Construct the XML placeholder inserted for missing footnotes.
Source code in src/texsmith/extensions/missing_footnotes.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
extendMarkdown ¶
extendMarkdown(md: Any) -> None
Patch the inline footnote processor to capture missing notes.
Source code in src/texsmith/extensions/missing_footnotes.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
reset ¶
reset() -> None
Reset cached state before each Markdown conversion.
Source code in src/texsmith/extensions/missing_footnotes.py
38 39 40 | |
makeExtension ¶
makeExtension(**kwargs: Any) -> MissingFootnotesExtension
Entry point exposed to Python-Markdown.
Source code in src/texsmith/extensions/missing_footnotes.py
123 124 125 | |