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
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
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
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
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
183 184 185 186 187 188 189 190 191 192 193 194 195 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 | |
resolve_markdown_extensions ¶
resolve_markdown_extensions(
requested: Iterable[str] | None,
disabled: Iterable[str] | None,
) -> list[str]
Return the active Markdown extension list after applying overrides.
Source code in src/texsmith/adapters/markdown/__init__.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
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
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 265 266 267 268 269 270 271 272 273 | |
Central registry for TeXSmith's bundled Markdown extensions.
ExtensionSpec
dataclass
¶
ExtensionSpec(
slug: str,
markdown_entry: str,
renderer_entry: str | None = None,
mkdocs_entry: str | None = None,
description: str | None = None,
)
Describe how to import Markdown and renderer hooks for an extension.
iter_entry_points ¶
iter_entry_points() -> Iterable[str]
Yield configured entry points for documentation/debugging.
Source code in src/texsmith/extensions/__init__.py
54 55 56 57 58 59 60 | |
available_extensions ¶
available_extensions() -> list[ExtensionSpec]
Return the registered extension specs sorted by slug.
Source code in src/texsmith/extensions/__init__.py
121 122 123 | |
get_extension_spec ¶
get_extension_spec(name: str) -> ExtensionSpec
Look up the runtime spec for a given extension slug or qualified name.
Source code in src/texsmith/extensions/__init__.py
126 127 128 129 130 131 132 | |
load_markdown_extension ¶
load_markdown_extension(name: str, **config: Any) -> Any
Instantiate a Python-Markdown extension by slug or qualified name.
Source code in src/texsmith/extensions/__init__.py
135 136 137 138 139 | |
load_mkdocs_plugin ¶
load_mkdocs_plugin(name: str) -> type[Any] | None
Return the MkDocs plugin class for an extension, if any.
Source code in src/texsmith/extensions/__init__.py
151 152 153 154 155 156 157 | |
register_all_renderers ¶
register_all_renderers(renderer: object) -> None
Register every available renderer hook on the provided renderer.
Source code in src/texsmith/extensions/__init__.py
142 143 144 145 146 147 148 | |
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 | |