multimark 0.1.3__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
multimark/__init__.py ADDED
@@ -0,0 +1,96 @@
1
+ """multimark — Python bindings to the cmark-gfm CommonMark/GFM C library.
2
+
3
+ Provides parsing and rendering of CommonMark and GitHub Flavored Markdown
4
+ to HTML, LaTeX, groff man, XML, and normalized CommonMark.
5
+ """
6
+ from enum import IntFlag
7
+ from importlib.metadata import PackageNotFoundError, version as _get_version
8
+
9
+ try:
10
+ __version__ = _get_version("multimark")
11
+ except PackageNotFoundError:
12
+ __version__ = "0.0.0"
13
+
14
+ from multimark._cmark import (
15
+ markdown_to_html,
16
+ markdown_to_latex,
17
+ markdown_to_man,
18
+ markdown_to_commonmark,
19
+ markdown_to_xml,
20
+ cmark_version,
21
+ VALID_EXTENSIONS,
22
+ )
23
+ from multimark._binding import lib
24
+
25
+
26
+ class Options(IntFlag):
27
+ """CommonMark/GFM parsing and rendering options.
28
+
29
+ An `IntFlag` enumeration of all option flags supported by the cmark-gfm library.
30
+ Options can be combined using the bitwise OR operator (`|`) and passed to any
31
+ renderer's `options=` parameter. This provides a composable, lower-level alternative
32
+ to the named boolean keyword arguments available on each renderer function.
33
+
34
+ Most users will prefer the named keyword arguments (e.g., `smart=True`) for common
35
+ options. The `Options` bitmask is useful when you need to combine multiple flags
36
+ into a single reusable value, or when working with GFM-specific flags that do not
37
+ have dedicated keyword arguments.
38
+
39
+ Examples
40
+ --------
41
+ Combine multiple flags with the `|` operator:
42
+
43
+ ```{python}
44
+ from multimark import markdown_to_html, Options
45
+
46
+ opts = Options.SMART | Options.UNSAFE
47
+ markdown_to_html('"Hello" -- world', options=opts)
48
+ ```
49
+
50
+ Mix a bitmask with named keyword arguments (they are OR'd together):
51
+
52
+ ```{python}
53
+ text = "Here's some *text* to convert"
54
+ markdown_to_html(text, options=Options.SMART, footnotes=True)
55
+ ```
56
+
57
+ Use GFM-specific flags that have no keyword shortcut:
58
+
59
+ ```{python}
60
+ markdown_to_html(
61
+ "~~deleted~~",
62
+ options=Options.STRIKETHROUGH_DOUBLE_TILDE,
63
+ extensions=["strikethrough"],
64
+ )
65
+ ```
66
+ """
67
+
68
+ DEFAULT = lib.CMARK_OPT_DEFAULT
69
+ SOURCEPOS = lib.CMARK_OPT_SOURCEPOS
70
+ HARDBREAKS = lib.CMARK_OPT_HARDBREAKS
71
+ SAFE = lib.CMARK_OPT_SAFE
72
+ UNSAFE = lib.CMARK_OPT_UNSAFE
73
+ NOBREAKS = lib.CMARK_OPT_NOBREAKS
74
+ NORMALIZE = lib.CMARK_OPT_NORMALIZE
75
+ VALIDATE_UTF8 = lib.CMARK_OPT_VALIDATE_UTF8
76
+ SMART = lib.CMARK_OPT_SMART
77
+ # GFM-specific options
78
+ GITHUB_PRE_LANG = lib.CMARK_OPT_GITHUB_PRE_LANG
79
+ LIBERAL_HTML_TAG = lib.CMARK_OPT_LIBERAL_HTML_TAG
80
+ FOOTNOTES = lib.CMARK_OPT_FOOTNOTES
81
+ STRIKETHROUGH_DOUBLE_TILDE = lib.CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE
82
+ TABLE_PREFER_STYLE_ATTRIBUTES = lib.CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES
83
+ FULL_INFO_STRING = lib.CMARK_OPT_FULL_INFO_STRING
84
+
85
+
86
+ __all__ = [
87
+ "markdown_to_html",
88
+ "markdown_to_latex",
89
+ "markdown_to_man",
90
+ "markdown_to_commonmark",
91
+ "markdown_to_xml",
92
+ "cmark_version",
93
+ "Options",
94
+ "VALID_EXTENSIONS",
95
+ "__version__",
96
+ ]
multimark/_binding.pyd ADDED
Binary file
@@ -0,0 +1,48 @@
1
+ """CFFI build script — compiles the vendored cmark-gfm C library + extensions."""
2
+ import os
3
+ import glob
4
+ from cffi import FFI
5
+
6
+ ffi = FFI()
7
+
8
+ here = os.path.dirname(os.path.abspath(__file__))
9
+
10
+ # Read the CFFI declarations
11
+ with open(os.path.join(here, "cmark.cffi.h")) as f:
12
+ ffi.cdef(f.read())
13
+
14
+ # Locate vendored cmark-gfm C sources (use relative paths from project root for setuptools)
15
+ project_root = os.path.normpath(os.path.join(here, "..", ".."))
16
+ src_dir_abs = os.path.join(project_root, "third_party", "cmark-gfm", "src")
17
+ ext_dir_abs = os.path.join(project_root, "third_party", "cmark-gfm", "extensions")
18
+ src_dir_rel = os.path.join("third_party", "cmark-gfm", "src")
19
+ ext_dir_rel = os.path.join("third_party", "cmark-gfm", "extensions")
20
+
21
+ # Core library sources (exclude main.c)
22
+ src_sources_abs = sorted(glob.glob(os.path.join(src_dir_abs, "*.c")))
23
+ src_sources = [
24
+ os.path.join(src_dir_rel, os.path.basename(s))
25
+ for s in src_sources_abs
26
+ if not s.endswith("main.c")
27
+ ]
28
+
29
+ # Extension sources
30
+ ext_sources_abs = sorted(glob.glob(os.path.join(ext_dir_abs, "*.c")))
31
+ ext_sources = [
32
+ os.path.join(ext_dir_rel, os.path.basename(s))
33
+ for s in ext_sources_abs
34
+ ]
35
+
36
+ ffi.set_source(
37
+ "multimark._binding",
38
+ """
39
+ #include "cmark-gfm.h"
40
+ #include "cmark-gfm-core-extensions.h"
41
+ """,
42
+ sources=src_sources + ext_sources,
43
+ include_dirs=[src_dir_abs, ext_dir_abs],
44
+ define_macros=[("CMARK_GFM_STATIC_DEFINE", None)],
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ ffi.compile(verbose=True)
multimark/_cmark.py ADDED
@@ -0,0 +1,736 @@
1
+ """Low-level CFFI wrapper around the cmark-gfm C library."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Sequence
5
+
6
+ from multimark._binding import ffi, lib
7
+
8
+ # Register all built-in GFM extensions once at import time.
9
+ lib.cmark_gfm_core_extensions_ensure_registered()
10
+
11
+ # Valid extension names recognized by cmark-gfm.
12
+ VALID_EXTENSIONS = frozenset(
13
+ ["table", "strikethrough", "autolink", "tagfilter", "tasklist"]
14
+ )
15
+
16
+
17
+ def _build_options(
18
+ options: int,
19
+ hardbreaks: bool,
20
+ smart: bool,
21
+ normalize: bool,
22
+ sourcepos: bool,
23
+ unsafe: bool,
24
+ footnotes: bool,
25
+ ) -> int:
26
+ """Combine named boolean flags with a raw options bitmask."""
27
+ if hardbreaks:
28
+ options |= lib.CMARK_OPT_HARDBREAKS
29
+ if smart:
30
+ options |= lib.CMARK_OPT_SMART
31
+ if normalize:
32
+ options |= lib.CMARK_OPT_NORMALIZE
33
+ if sourcepos:
34
+ options |= lib.CMARK_OPT_SOURCEPOS
35
+ if unsafe:
36
+ options |= lib.CMARK_OPT_UNSAFE
37
+ if footnotes:
38
+ options |= lib.CMARK_OPT_FOOTNOTES
39
+ return options
40
+
41
+
42
+ def _parse_with_extensions(
43
+ encoded: bytes, opts: int, extensions: Sequence[str]
44
+ ):
45
+ """Parse markdown using the streaming parser with extensions attached.
46
+
47
+ Returns (node, parser) — caller must free both.
48
+ """
49
+ parser = lib.cmark_parser_new(opts)
50
+ if parser == ffi.NULL:
51
+ raise MemoryError("Failed to create parser")
52
+
53
+ for ext_name in extensions:
54
+ ext = lib.cmark_find_syntax_extension(ext_name.encode("utf-8"))
55
+ if ext == ffi.NULL:
56
+ lib.cmark_parser_free(parser)
57
+ raise ValueError(f"Unknown extension: {ext_name!r}")
58
+ lib.cmark_parser_attach_syntax_extension(parser, ext)
59
+
60
+ lib.cmark_parser_feed(parser, encoded, len(encoded))
61
+ node = lib.cmark_parser_finish(parser)
62
+ if node == ffi.NULL:
63
+ lib.cmark_parser_free(parser)
64
+ raise MemoryError("Failed to parse document")
65
+ return node, parser
66
+
67
+
68
+ def markdown_to_html(
69
+ text: str,
70
+ *,
71
+ hardbreaks: bool = False,
72
+ smart: bool = False,
73
+ normalize: bool = False,
74
+ sourcepos: bool = False,
75
+ unsafe: bool = False,
76
+ footnotes: bool = False,
77
+ extensions: Sequence[str] = (),
78
+ options: int = 0,
79
+ ) -> str:
80
+ """Parse CommonMark/GFM and render as HTML.
81
+
82
+ Takes a Markdown string and returns the corresponding HTML output. By default,
83
+ raw HTML embedded in the Markdown is stripped for security (replaced with an HTML
84
+ comment). Set `unsafe=True` to allow raw HTML passthrough.
85
+
86
+ The parser is fully [CommonMark spec](https://spec.commonmark.org/) compliant. When
87
+ GFM extensions are enabled via `extensions=`, additional syntax is recognized
88
+ (tables, strikethrough, autolinks, tag filtering, and task lists).
89
+
90
+ Parameters
91
+ ----------
92
+ text : str
93
+ The Markdown string to parse and render. Can be any length, from a single
94
+ inline fragment to a full document. Must be a Python `str` (not bytes).
95
+
96
+ hardbreaks : bool
97
+ Render soft line breaks (single newlines within a paragraph) as `<br />` tags.
98
+ By default, this is `False` and soft breaks are rendered as spaces, matching the
99
+ CommonMark specification behavior.
100
+
101
+ smart : bool
102
+ Convert straight quotes to curly quotes, `--` to en-dashes, `---` to em-dashes,
103
+ and `...` to ellipses. By default, this is `False`.
104
+
105
+ normalize : bool
106
+ Consolidate adjacent text nodes in the parsed AST before rendering. This can
107
+ produce slightly cleaner output in edge cases. By default, this is `False`.
108
+
109
+ sourcepos : bool
110
+ Include `data-sourcepos` attributes on block-level HTML elements indicating
111
+ their line/column positions in the original Markdown source. Useful for building
112
+ editors or source-mapping tools. By default, this is `False`.
113
+
114
+ unsafe : bool
115
+ Allow raw HTML and potentially dangerous links to pass through to the output
116
+ without sanitization. When `False` (the default), raw HTML blocks and inline
117
+ HTML are replaced with a comment `<!-- raw HTML omitted -->`, and dangerous
118
+ URLs (e.g., `javascript:`) are suppressed.
119
+
120
+ footnotes : bool
121
+ Enable footnote syntax parsing. When `True`, `[^label]` markers and
122
+ `[^label]: content` definitions are recognized and rendered as numbered
123
+ footnotes with backlinks. By default, this is `False`.
124
+
125
+ extensions : Sequence[str]
126
+ A sequence of GFM extension names to enable during parsing. Valid names are
127
+ `"table"`, `"strikethrough"`, `"autolink"`, `"tagfilter"`, and `"tasklist"`.
128
+ An empty sequence (the default) parses standard CommonMark only.
129
+
130
+ options : int
131
+ An integer bitmask of `Options` flags. Build it by OR-ing flags together, e.g.,
132
+ `Options.SMART | Options.UNSAFE`. This value is combined (via OR) with any named
133
+ boolean parameters that are set to `True`, so you can mix both styles freely.
134
+ Defaults to `0` (no additional flags beyond those set by keyword arguments).
135
+
136
+ Keyword Arguments vs. Options Flags
137
+ ------------------------------------
138
+ The boolean keyword arguments (`smart`, `unsafe`, `hardbreaks`, etc.) are convenience
139
+ shortcuts for the most common `Options` flags. Using `smart=True` is equivalent to
140
+ passing `options=Options.SMART`. When both are provided, they are merged:
141
+ `markdown_to_html(text, smart=True, options=Options.UNSAFE)` is the same as
142
+ `options=Options.SMART | Options.UNSAFE`.
143
+
144
+ Some flags (like `Options.GITHUB_PRE_LANG`, `Options.STRIKETHROUGH_DOUBLE_TILDE`,
145
+ and `Options.LIBERAL_HTML_TAG`) have no keyword shortcut and can only be set via
146
+ the `options` parameter.
147
+
148
+ Returns
149
+ -------
150
+ str
151
+ The rendered HTML string. Block-level elements end with a trailing newline.
152
+
153
+ Examples
154
+ --------
155
+ Render basic Markdown to HTML:
156
+
157
+ ```{python}
158
+ from multimark import markdown_to_html
159
+
160
+ markdown_to_html("**bold** and *italic*")
161
+ ```
162
+
163
+ Enable smart punctuation:
164
+
165
+ ```{python}
166
+ markdown_to_html('"Hello" -- world...', smart=True)
167
+ ```
168
+
169
+ Allow raw HTML passthrough:
170
+
171
+ ```{python}
172
+ markdown_to_html("<div>custom</div>", unsafe=True)
173
+ ```
174
+
175
+ Use GFM table extension:
176
+
177
+ ```{python}
178
+ markdown_to_html(
179
+ "| A | B |\\n|---|---|\\n| 1 | 2 |\\n",
180
+ extensions=["table"],
181
+ )
182
+ ```
183
+
184
+ Combine multiple features:
185
+
186
+ ```{python}
187
+ markdown_to_html(
188
+ "~~old~~ -> new\\n\\nVisit https://example.com\\n",
189
+ extensions=["strikethrough", "autolink"],
190
+ smart=True,
191
+ )
192
+ ```
193
+ """
194
+ opts = _build_options(options, hardbreaks, smart, normalize, sourcepos, unsafe, footnotes)
195
+ encoded = text.encode("utf-8")
196
+
197
+ if extensions:
198
+ node, parser = _parse_with_extensions(encoded, opts, extensions)
199
+ ext_list = lib.cmark_parser_get_syntax_extensions(parser)
200
+ try:
201
+ result_ptr = lib.cmark_render_html(node, opts, ext_list)
202
+ if result_ptr == ffi.NULL:
203
+ raise MemoryError("Failed to render document")
204
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
205
+ lib.free(result_ptr)
206
+ return result
207
+ finally:
208
+ lib.cmark_node_free(node)
209
+ lib.cmark_parser_free(parser)
210
+ else:
211
+ node = lib.cmark_parse_document(encoded, len(encoded), opts)
212
+ if node == ffi.NULL:
213
+ raise MemoryError("Failed to parse document")
214
+ try:
215
+ result_ptr = lib.cmark_render_html(node, opts, ffi.NULL)
216
+ if result_ptr == ffi.NULL:
217
+ raise MemoryError("Failed to render document")
218
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
219
+ lib.free(result_ptr)
220
+ return result
221
+ finally:
222
+ lib.cmark_node_free(node)
223
+
224
+
225
+ def markdown_to_xml(
226
+ text: str,
227
+ *,
228
+ hardbreaks: bool = False,
229
+ smart: bool = False,
230
+ normalize: bool = False,
231
+ sourcepos: bool = False,
232
+ unsafe: bool = False,
233
+ footnotes: bool = False,
234
+ extensions: Sequence[str] = (),
235
+ options: int = 0,
236
+ ) -> str:
237
+ """Parse CommonMark/GFM and render as XML.
238
+
239
+ Produces an XML representation of the parsed abstract syntax tree (AST). Each
240
+ Markdown construct is represented as a named element (e.g., `<paragraph>`,
241
+ `<strong>`, `<code_block>`), with text content preserved in `<text>` elements.
242
+
243
+ The XML output conforms to the CommonMark DTD and includes an XML declaration and
244
+ DOCTYPE. This format is useful for debugging, AST inspection, or piping into
245
+ XML-based toolchains.
246
+
247
+ Parameters
248
+ ----------
249
+ text : str
250
+ The Markdown string to parse and render. Must be a Python `str`.
251
+
252
+ hardbreaks : bool
253
+ Render soft line breaks as hard breaks in the AST. By default, this is `False`.
254
+
255
+ smart : bool
256
+ Convert straight quotes to curly quotes, `--` to en-dashes, `---` to em-dashes,
257
+ and `...` to ellipses. By default, this is `False`.
258
+
259
+ normalize : bool
260
+ Consolidate adjacent text nodes in the parsed AST. By default, this is `False`.
261
+
262
+ sourcepos : bool
263
+ Include `sourcepos` attributes on elements indicating their line/column
264
+ positions in the original Markdown source. By default, this is `False`.
265
+
266
+ unsafe : bool
267
+ Allow raw HTML to pass through. By default, this is `False`.
268
+
269
+ footnotes : bool
270
+ Enable footnote syntax parsing. By default, this is `False`.
271
+
272
+ extensions : Sequence[str]
273
+ A sequence of GFM extension names to enable. Valid names are `"table"`,
274
+ `"strikethrough"`, `"autolink"`, `"tagfilter"`, and `"tasklist"`.
275
+
276
+ options : int
277
+ An integer bitmask of `Options` flags (e.g., `Options.SMART | Options.UNSAFE`).
278
+ Merged via OR with any boolean keyword arguments set to `True`.
279
+ Defaults to `0`.
280
+
281
+ Keyword Arguments vs. Options Flags
282
+ ------------------------------------
283
+ The boolean keyword arguments (`smart`, `unsafe`, `hardbreaks`, etc.) are convenience
284
+ shortcuts for the most common `Options` flags. When both styles are provided, they
285
+ are merged via OR. See `markdown_to_html()` for a detailed explanation.
286
+
287
+ Returns
288
+ -------
289
+ str
290
+ The rendered XML string, including the XML declaration and DOCTYPE.
291
+
292
+ Examples
293
+ --------
294
+ Inspect the AST structure of a simple document:
295
+
296
+ ```{python}
297
+ from multimark import markdown_to_xml
298
+
299
+ print(markdown_to_xml("**hello**"))
300
+ ```
301
+
302
+ Add source position information:
303
+
304
+ ```{python}
305
+ markdown_to_xml("# Title\\n\\nBody text\\n", sourcepos=True)
306
+ ```
307
+ """
308
+ opts = _build_options(options, hardbreaks, smart, normalize, sourcepos, unsafe, footnotes)
309
+ encoded = text.encode("utf-8")
310
+
311
+ if extensions:
312
+ node, parser = _parse_with_extensions(encoded, opts, extensions)
313
+ try:
314
+ result_ptr = lib.cmark_render_xml(node, opts)
315
+ if result_ptr == ffi.NULL:
316
+ raise MemoryError("Failed to render document")
317
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
318
+ lib.free(result_ptr)
319
+ return result
320
+ finally:
321
+ lib.cmark_node_free(node)
322
+ lib.cmark_parser_free(parser)
323
+ else:
324
+ node = lib.cmark_parse_document(encoded, len(encoded), opts)
325
+ if node == ffi.NULL:
326
+ raise MemoryError("Failed to parse document")
327
+ try:
328
+ result_ptr = lib.cmark_render_xml(node, opts)
329
+ if result_ptr == ffi.NULL:
330
+ raise MemoryError("Failed to render document")
331
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
332
+ lib.free(result_ptr)
333
+ return result
334
+ finally:
335
+ lib.cmark_node_free(node)
336
+
337
+
338
+ def markdown_to_latex(
339
+ text: str,
340
+ *,
341
+ hardbreaks: bool = False,
342
+ smart: bool = False,
343
+ normalize: bool = False,
344
+ unsafe: bool = False,
345
+ footnotes: bool = False,
346
+ extensions: Sequence[str] = (),
347
+ width: int = 0,
348
+ options: int = 0,
349
+ ) -> str:
350
+ """Parse CommonMark/GFM and render as LaTeX.
351
+
352
+ Converts Markdown to LaTeX source suitable for inclusion in a `.tex` document.
353
+ Inline formatting maps to LaTeX commands (`\\textbf{}`, `\\emph{}`, `\\texttt{}`),
354
+ headings become sectioning commands (`\\section{}`, `\\subsection{}`, etc.), and
355
+ links use `\\href{}{}`.
356
+
357
+ The output is a fragment (not a full document): it does not include
358
+ `\\documentclass`, `\\begin{document}`, or preamble. You can concatenate it into
359
+ your own LaTeX document structure.
360
+
361
+ Parameters
362
+ ----------
363
+ text : str
364
+ The Markdown string to parse and render. Must be a Python `str`.
365
+
366
+ hardbreaks : bool
367
+ Render soft line breaks as hard breaks (`\\\\`). By default, this is `False`.
368
+
369
+ smart : bool
370
+ Convert straight quotes to curly quotes, `--` to en-dashes, `---` to em-dashes,
371
+ and `...` to ellipses. By default, this is `False`.
372
+
373
+ normalize : bool
374
+ Consolidate adjacent text nodes in the parsed AST. By default, this is `False`.
375
+
376
+ unsafe : bool
377
+ Allow raw HTML to pass through. Since LaTeX is the target format, raw HTML is
378
+ typically irrelevant. By default, this is `False`.
379
+
380
+ footnotes : bool
381
+ Enable footnote syntax parsing. By default, this is `False`.
382
+
383
+ extensions : Sequence[str]
384
+ A sequence of GFM extension names to enable. Valid names are `"table"`,
385
+ `"strikethrough"`, `"autolink"`, `"tagfilter"`, and `"tasklist"`.
386
+
387
+ width : int
388
+ The column at which to wrap output lines. Set to `0` (the default) to disable
389
+ line wrapping entirely. A value like `80` produces lines of at most 80
390
+ characters where possible.
391
+
392
+ options : int
393
+ An integer bitmask of `Options` flags (e.g., `Options.SMART | Options.UNSAFE`).
394
+ Merged via OR with any boolean keyword arguments set to `True`.
395
+ Defaults to `0`.
396
+
397
+ Keyword Arguments vs. Options Flags
398
+ ------------------------------------
399
+ The boolean keyword arguments (`smart`, `unsafe`, `hardbreaks`, etc.) are convenience
400
+ shortcuts for the most common `Options` flags. When both styles are provided, they
401
+ are merged via OR. See `markdown_to_html()` for a detailed explanation.
402
+
403
+ Returns
404
+ -------
405
+ str
406
+ The rendered LaTeX string.
407
+
408
+ Examples
409
+ --------
410
+ Render inline formatting:
411
+
412
+ ```{python}
413
+ from multimark import markdown_to_latex
414
+
415
+ markdown_to_latex("**bold** and *italic*")
416
+ ```
417
+
418
+ Render a heading:
419
+
420
+ ```{python}
421
+ markdown_to_latex("# Introduction")
422
+ ```
423
+
424
+ Enable line wrapping at 72 columns:
425
+
426
+ ```{python}
427
+ long_text = "This is a very long paragraph. " * 10
428
+ print(markdown_to_latex(long_text, width=72))
429
+ ```
430
+
431
+ Use smart punctuation for typographic output:
432
+
433
+ ```{python}
434
+ markdown_to_latex('"Hello," she said --- "goodbye."', smart=True)
435
+ ```
436
+ """
437
+ opts = _build_options(options, hardbreaks, smart, normalize, False, unsafe, footnotes)
438
+ encoded = text.encode("utf-8")
439
+
440
+ if extensions:
441
+ node, parser = _parse_with_extensions(encoded, opts, extensions)
442
+ try:
443
+ result_ptr = lib.cmark_render_latex(node, opts, width)
444
+ if result_ptr == ffi.NULL:
445
+ raise MemoryError("Failed to render document")
446
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
447
+ lib.free(result_ptr)
448
+ return result
449
+ finally:
450
+ lib.cmark_node_free(node)
451
+ lib.cmark_parser_free(parser)
452
+ else:
453
+ node = lib.cmark_parse_document(encoded, len(encoded), opts)
454
+ if node == ffi.NULL:
455
+ raise MemoryError("Failed to parse document")
456
+ try:
457
+ result_ptr = lib.cmark_render_latex(node, opts, width)
458
+ if result_ptr == ffi.NULL:
459
+ raise MemoryError("Failed to render document")
460
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
461
+ lib.free(result_ptr)
462
+ return result
463
+ finally:
464
+ lib.cmark_node_free(node)
465
+
466
+
467
+ def markdown_to_man(
468
+ text: str,
469
+ *,
470
+ hardbreaks: bool = False,
471
+ smart: bool = False,
472
+ normalize: bool = False,
473
+ unsafe: bool = False,
474
+ footnotes: bool = False,
475
+ extensions: Sequence[str] = (),
476
+ width: int = 0,
477
+ options: int = 0,
478
+ ) -> str:
479
+ """Parse CommonMark/GFM and render as a groff man page.
480
+
481
+ Produces groff-format output suitable for use with the `man` command or inclusion
482
+ in manual page source files. Inline formatting maps to font switching requests
483
+ (`\\f[B]`, `\\f[I]`, `\\f[CR]`), paragraphs use `.PP`, and headings use `.SH` or
484
+ `.SS` macros.
485
+
486
+ The output is a fragment and does not include a `.TH` title header. Wrap it in your
487
+ own man page structure to produce a complete manual page.
488
+
489
+ Parameters
490
+ ----------
491
+ text : str
492
+ The Markdown string to parse and render. Must be a Python `str`.
493
+
494
+ hardbreaks : bool
495
+ Render soft line breaks as hard breaks (`.br`). By default, this is `False`.
496
+
497
+ smart : bool
498
+ Convert straight quotes to curly quotes, `--` to en-dashes, `---` to em-dashes,
499
+ and `...` to ellipses. By default, this is `False`.
500
+
501
+ normalize : bool
502
+ Consolidate adjacent text nodes in the parsed AST. By default, this is `False`.
503
+
504
+ unsafe : bool
505
+ Allow raw HTML to pass through. Since groff is the target format, raw HTML is
506
+ typically irrelevant. By default, this is `False`.
507
+
508
+ footnotes : bool
509
+ Enable footnote syntax parsing. By default, this is `False`.
510
+
511
+ extensions : Sequence[str]
512
+ A sequence of GFM extension names to enable. Valid names are `"table"`,
513
+ `"strikethrough"`, `"autolink"`, `"tagfilter"`, and `"tasklist"`.
514
+
515
+ width : int
516
+ The column at which to wrap output lines. Set to `0` (the default) to disable
517
+ line wrapping entirely.
518
+
519
+ options : int
520
+ An integer bitmask of `Options` flags (e.g., `Options.SMART | Options.UNSAFE`).
521
+ Merged via OR with any boolean keyword arguments set to `True`.
522
+ Defaults to `0`.
523
+
524
+ Keyword Arguments vs. Options Flags
525
+ ------------------------------------
526
+ The boolean keyword arguments (`smart`, `unsafe`, `hardbreaks`, etc.) are convenience
527
+ shortcuts for the most common `Options` flags. When both styles are provided, they
528
+ are merged via OR. See `markdown_to_html()` for a detailed explanation.
529
+
530
+ Returns
531
+ -------
532
+ str
533
+ The rendered groff man page string.
534
+
535
+ Examples
536
+ --------
537
+ Render a paragraph with bold and italic:
538
+
539
+ ```{python}
540
+ from multimark import markdown_to_man
541
+
542
+ markdown_to_man("**bold** and *italic*")
543
+ ```
544
+
545
+ Render a heading:
546
+
547
+ ```{python}
548
+ markdown_to_man("## Options")
549
+ ```
550
+
551
+ Wrap at 72 columns:
552
+
553
+ ```{python}
554
+ long_paragraph = "This is a long paragraph of text. " * 10
555
+ print(markdown_to_man(long_paragraph, width=72))
556
+ ```
557
+ """
558
+ opts = _build_options(options, hardbreaks, smart, normalize, False, unsafe, footnotes)
559
+ encoded = text.encode("utf-8")
560
+
561
+ if extensions:
562
+ node, parser = _parse_with_extensions(encoded, opts, extensions)
563
+ try:
564
+ result_ptr = lib.cmark_render_man(node, opts, width)
565
+ if result_ptr == ffi.NULL:
566
+ raise MemoryError("Failed to render document")
567
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
568
+ lib.free(result_ptr)
569
+ return result
570
+ finally:
571
+ lib.cmark_node_free(node)
572
+ lib.cmark_parser_free(parser)
573
+ else:
574
+ node = lib.cmark_parse_document(encoded, len(encoded), opts)
575
+ if node == ffi.NULL:
576
+ raise MemoryError("Failed to parse document")
577
+ try:
578
+ result_ptr = lib.cmark_render_man(node, opts, width)
579
+ if result_ptr == ffi.NULL:
580
+ raise MemoryError("Failed to render document")
581
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
582
+ lib.free(result_ptr)
583
+ return result
584
+ finally:
585
+ lib.cmark_node_free(node)
586
+
587
+
588
+ def markdown_to_commonmark(
589
+ text: str,
590
+ *,
591
+ hardbreaks: bool = False,
592
+ smart: bool = False,
593
+ normalize: bool = False,
594
+ unsafe: bool = False,
595
+ footnotes: bool = False,
596
+ extensions: Sequence[str] = (),
597
+ width: int = 0,
598
+ options: int = 0,
599
+ ) -> str:
600
+ """Parse CommonMark/GFM and render back as normalized CommonMark.
601
+
602
+ Parses the input Markdown into an AST and re-renders it as CommonMark. This
603
+ effectively normalizes the formatting: different but semantically equivalent
604
+ Markdown inputs (e.g., `*italic*` vs `_italic_`, varying list indentation) will
605
+ produce a canonical output form.
606
+
607
+ This is useful for round-trip testing, canonical formatting, or cleaning up
608
+ inconsistently formatted documents. The output of this function, when parsed again,
609
+ produces the same AST as the original input.
610
+
611
+ Parameters
612
+ ----------
613
+ text : str
614
+ The Markdown string to parse and normalize. Must be a Python `str`.
615
+
616
+ hardbreaks : bool
617
+ Render soft line breaks as hard breaks (backslash-newline). By default, this is
618
+ `False`.
619
+
620
+ smart : bool
621
+ Convert straight quotes to curly quotes, `--` to en-dashes, `---` to em-dashes,
622
+ and `...` to ellipses. By default, this is `False`.
623
+
624
+ normalize : bool
625
+ Consolidate adjacent text nodes in the parsed AST. By default, this is `False`.
626
+
627
+ unsafe : bool
628
+ Allow raw HTML to pass through. By default, this is `False`, which replaces raw
629
+ HTML with a comment placeholder.
630
+
631
+ footnotes : bool
632
+ Enable footnote syntax parsing. By default, this is `False`.
633
+
634
+ extensions : Sequence[str]
635
+ A sequence of GFM extension names to enable. Valid names are `"table"`,
636
+ `"strikethrough"`, `"autolink"`, `"tagfilter"`, and `"tasklist"`.
637
+
638
+ width : int
639
+ The column at which to wrap output lines. Set to `0` (the default) to disable
640
+ line wrapping entirely. This is useful for producing line-wrapped output for
641
+ version-control-friendly diffs.
642
+
643
+ options : int
644
+ An integer bitmask of `Options` flags (e.g., `Options.SMART | Options.UNSAFE`).
645
+ Merged via OR with any boolean keyword arguments set to `True`.
646
+ Defaults to `0`.
647
+
648
+ Keyword Arguments vs. Options Flags
649
+ ------------------------------------
650
+ The boolean keyword arguments (`smart`, `unsafe`, `hardbreaks`, etc.) are convenience
651
+ shortcuts for the most common `Options` flags. When both styles are provided, they
652
+ are merged via OR. See `markdown_to_html()` for a detailed explanation.
653
+
654
+ Returns
655
+ -------
656
+ str
657
+ The normalized CommonMark string.
658
+
659
+ Examples
660
+ --------
661
+ Normalize inconsistent formatting:
662
+
663
+ ```{python}
664
+ from multimark import markdown_to_commonmark
665
+
666
+ markdown_to_commonmark("_hello_ **world**")
667
+ ```
668
+
669
+ Verify round-trip stability (parse, render, re-parse produces the same HTML):
670
+
671
+ ```{python}
672
+ from multimark import markdown_to_commonmark, markdown_to_html
673
+
674
+ original = "**bold** and *italic*"
675
+ normalized = markdown_to_commonmark(original)
676
+ assert markdown_to_html(original) == markdown_to_html(normalized)
677
+ ```
678
+
679
+ Wrap at 80 columns for version-control-friendly output:
680
+
681
+ ```{python}
682
+ long_document = "This is a long sentence for demonstration. " * 10
683
+ print(markdown_to_commonmark(long_document, width=80))
684
+ ```
685
+ """
686
+ opts = _build_options(options, hardbreaks, smart, normalize, False, unsafe, footnotes)
687
+ encoded = text.encode("utf-8")
688
+
689
+ if extensions:
690
+ node, parser = _parse_with_extensions(encoded, opts, extensions)
691
+ try:
692
+ result_ptr = lib.cmark_render_commonmark(node, opts, width)
693
+ if result_ptr == ffi.NULL:
694
+ raise MemoryError("Failed to render document")
695
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
696
+ lib.free(result_ptr)
697
+ return result
698
+ finally:
699
+ lib.cmark_node_free(node)
700
+ lib.cmark_parser_free(parser)
701
+ else:
702
+ node = lib.cmark_parse_document(encoded, len(encoded), opts)
703
+ if node == ffi.NULL:
704
+ raise MemoryError("Failed to parse document")
705
+ try:
706
+ result_ptr = lib.cmark_render_commonmark(node, opts, width)
707
+ if result_ptr == ffi.NULL:
708
+ raise MemoryError("Failed to render document")
709
+ result = ffi.string(result_ptr).decode("utf-8", errors="replace")
710
+ lib.free(result_ptr)
711
+ return result
712
+ finally:
713
+ lib.cmark_node_free(node)
714
+
715
+
716
+ def cmark_version() -> str:
717
+ """Return the version string of the vendored cmark-gfm library.
718
+
719
+ Reports the version of the bundled cmark-gfm C library that multimark was compiled
720
+ against. This is useful for debugging or confirming which release of the underlying
721
+ parser is in use.
722
+
723
+ Returns
724
+ -------
725
+ str
726
+ A version string in the format `"X.Y.Z.gfm.N"` (e.g., `"0.29.0.gfm.13"`).
727
+
728
+ Examples
729
+ --------
730
+ ```{python}
731
+ from multimark import cmark_version
732
+
733
+ cmark_version()
734
+ ```
735
+ """
736
+ return ffi.string(lib.cmark_version_string()).decode("utf-8")
multimark/cmark.cffi.h ADDED
@@ -0,0 +1,54 @@
1
+ /* Core types */
2
+ typedef struct cmark_node cmark_node;
3
+ typedef struct cmark_parser cmark_parser;
4
+ typedef struct cmark_syntax_extension cmark_syntax_extension;
5
+ typedef struct _cmark_llist {
6
+ struct _cmark_llist *next;
7
+ void *data;
8
+ } cmark_llist;
9
+
10
+ /* Parser API (streaming with extension support) */
11
+ cmark_parser *cmark_parser_new(int options);
12
+ void cmark_parser_free(cmark_parser *parser);
13
+ void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len);
14
+ cmark_node *cmark_parser_finish(cmark_parser *parser);
15
+ int cmark_parser_attach_syntax_extension(cmark_parser *parser, cmark_syntax_extension *extension);
16
+ cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser);
17
+
18
+ /* Simple parsing (no extensions) */
19
+ cmark_node *cmark_parse_document(const char *buffer, size_t len, int options);
20
+ void cmark_node_free(cmark_node *node);
21
+
22
+ /* Extension registration */
23
+ void cmark_gfm_core_extensions_ensure_registered(void);
24
+ cmark_syntax_extension *cmark_find_syntax_extension(const char *name);
25
+
26
+ /* Rendering */
27
+ char *cmark_render_html(cmark_node *root, int options, cmark_llist *extensions);
28
+ char *cmark_render_latex(cmark_node *root, int options, int width);
29
+ char *cmark_render_man(cmark_node *root, int options, int width);
30
+ char *cmark_render_commonmark(cmark_node *root, int options, int width);
31
+ char *cmark_render_xml(cmark_node *root, int options);
32
+
33
+ const char *cmark_version_string(void);
34
+
35
+ void free(void *ptr);
36
+
37
+ /* Core options */
38
+ #define CMARK_OPT_DEFAULT ...
39
+ #define CMARK_OPT_SOURCEPOS ...
40
+ #define CMARK_OPT_HARDBREAKS ...
41
+ #define CMARK_OPT_SAFE ...
42
+ #define CMARK_OPT_UNSAFE ...
43
+ #define CMARK_OPT_NOBREAKS ...
44
+ #define CMARK_OPT_NORMALIZE ...
45
+ #define CMARK_OPT_VALIDATE_UTF8 ...
46
+ #define CMARK_OPT_SMART ...
47
+
48
+ /* GFM-specific options */
49
+ #define CMARK_OPT_GITHUB_PRE_LANG ...
50
+ #define CMARK_OPT_LIBERAL_HTML_TAG ...
51
+ #define CMARK_OPT_FOOTNOTES ...
52
+ #define CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE ...
53
+ #define CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES ...
54
+ #define CMARK_OPT_FULL_INFO_STRING ...
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: multimark
3
+ Version: 0.1.3
4
+ Summary: Python bindings to cmark — CommonMark parsing and rendering (HTML, LaTeX, man, XML)
5
+ Author: Rich Iannone
6
+ License: MIT AND BSD-2-Clause
7
+ Project-URL: Homepage, https://github.com/rich-iannone/multimark
8
+ Project-URL: Issues, https://github.com/rich-iannone/multimark/issues
9
+ Keywords: markdown,commonmark,cmark-gfm,html,latex,gfm
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: C
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: cffi>=1.15
26
+ Dynamic: license-file
27
+
28
+ <a href="https://pypi.org/project/multimark/"><img src="https://img.shields.io/pypi/v/multimark?logo=python&logoColor=white&color=orange" alt="PyPI"></a>
29
+ <a href="https://pypi.org/project/multimark/"><img src="https://img.shields.io/pypi/pyversions/multimark.svg" alt="Python versions"></a>
30
+ <a href="https://pypistats.org/packages/multimark"><img src="https://img.shields.io/pypi/dm/multimark" alt="Downloads"></a>
31
+ <a href="https://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License"></a>
32
+ <a href="https://github.com/rich-iannone/multimark/actions/workflows/ci.yml"><img src="https://github.com/rich-iannone/multimark/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
33
+ </p>
34
+
35
+ # multimark
36
+
37
+ Python bindings to [cmark-gfm](https://github.com/github/cmark-gfm), the C reference implementation of [CommonMark](https://commonmark.org/) with GitHub Flavored Markdown extensions.
38
+
39
+ Renders Markdown to **HTML**, **LaTeX**, **groff man**, **XML**, and **normalized CommonMark**: all from a single, lightweight package.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install multimark
45
+ ```
46
+
47
+ Wheels are available for Linux, macOS, and Windows (Python 3.9+). No system dependencies required.
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from multimark import markdown_to_html, markdown_to_latex
53
+
54
+ html = markdown_to_html("**Hello**, *world*!")
55
+ # '<p><strong>Hello</strong>, <em>world</em>!</p>\n'
56
+
57
+ latex = markdown_to_latex("**Hello**, *world*!")
58
+ # '\\textbf{Hello}, \\emph{world}!\n'
59
+ ```
60
+
61
+ ## Renderers
62
+
63
+ | Function | Output Format |
64
+ |----------|---------------|
65
+ | `markdown_to_html()` | HTML |
66
+ | `markdown_to_latex()` | LaTeX |
67
+ | `markdown_to_man()` | groff man page |
68
+ | `markdown_to_commonmark()` | Normalized CommonMark |
69
+ | `markdown_to_xml()` | XML (AST representation) |
70
+
71
+ ## Options
72
+
73
+ Use named boolean keyword arguments for common settings:
74
+
75
+ ```python
76
+ from multimark import markdown_to_html, markdown_to_latex
77
+
78
+ # Smart punctuation (curly quotes, em-dashes)
79
+ markdown_to_html('"Hello" -- world...', smart=True)
80
+ # '<p>\u201cHello\u201d \u2013 world\u2026</p>\n'
81
+
82
+ # Allow raw HTML passthrough (safe mode is the default)
83
+ markdown_to_html('<div>hi</div>', unsafe=True)
84
+ # '<div>hi</div>\n'
85
+
86
+ # Source position attributes
87
+ markdown_to_html('**Hello**', sourcepos=True)
88
+ # '<p data-sourcepos="1:1-1:9"><strong>Hello</strong></p>\n'
89
+
90
+ # Line wrapping (LaTeX, man, and commonmark renderers)
91
+ markdown_to_latex('**Hello**, *world*!', width=80)
92
+ # '\\textbf{Hello}, \\emph{world}!\n'
93
+
94
+ # Footnotes
95
+ markdown_to_html('Text[^1]\n\n[^1]: A footnote\n', footnotes=True)
96
+ # '<p>Text<sup class="footnote-ref">...</sup></p>\n<section class="footnotes">...\n'
97
+ ```
98
+
99
+ Or compose flags with the `Options` bitmask:
100
+
101
+ ```python
102
+ from multimark import markdown_to_html, Options
103
+
104
+ html = markdown_to_html(text, options=Options.SMART | Options.UNSAFE)
105
+ ```
106
+
107
+ ## GFM Extensions
108
+
109
+ Enable GitHub Flavored Markdown extensions by name:
110
+
111
+ ```python
112
+ from multimark import markdown_to_html
113
+
114
+ # Tables
115
+ markdown_to_html('| A | B |\n|---|---|\n| 1 | 2 |\n', extensions=["table"])
116
+ # '<table>\n<thead>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>...\n'
117
+
118
+ # Strikethrough
119
+ markdown_to_html('~~deleted~~', extensions=["strikethrough"])
120
+ # '<p><del>deleted</del></p>\n'
121
+
122
+ # Multiple extensions
123
+ html = markdown_to_html(text, extensions=["table", "strikethrough", "autolink", "tasklist", "tagfilter"])
124
+ ```
125
+
126
+ Available extensions: `table`, `strikethrough`, `autolink`, `tagfilter`, `tasklist`.
127
+
128
+ ## All Renderer Parameters
129
+
130
+ Every renderer accepts:
131
+
132
+ - **`text`** — Markdown string
133
+ - **`options`** — Raw bitmask (default `0`)
134
+ - **`extensions`** — List of GFM extension names (default `()`)
135
+ - **`smart`** — Smart punctuation
136
+ - **`hardbreaks`** — Render soft breaks as `<br>`
137
+ - **`unsafe`** — Allow raw HTML
138
+ - **`normalize`** — Consolidate adjacent text nodes
139
+ - **`footnotes`** — Enable footnote syntax
140
+
141
+ Additional parameters:
142
+
143
+ - **`sourcepos`** — Source position attributes (HTML and XML only)
144
+ - **`width`** — Line wrap column (LaTeX, man, and commonmark only; `0` = no wrap)
145
+
146
+ ## License
147
+
148
+ MIT (Python wrapper) and BSD-2-Clause (vendored cmark-gfm).
@@ -0,0 +1,10 @@
1
+ multimark/__init__.py,sha256=5Lu-Bm2H7FLhiF_up8hk1aZKa7YaogXFGuqRqEijuEY,3090
2
+ multimark/_binding.pyd,sha256=R9sowqDXu4Uxry6MYUp6MdgSst5TpyxdreJ5O3ESrrk,257024
3
+ multimark/_build_cmark.py,sha256=htF0h-BKdZA6e24QcIVChmhcRig48Xij8rriAuWXkI8,1550
4
+ multimark/_cmark.py,sha256=t32m1B34bScCeruhq1nsFjKxpfzrcI-NJ0jaMe_XhwQ,26086
5
+ multimark/cmark.cffi.h,sha256=WFeUy7jIBdguzdtbrBZMc8Bgd6SyHdbohE_gPvtyqJk,2065
6
+ multimark-0.1.3.dist-info/licenses/LICENSE,sha256=oZ-E9N_3BiSH7UpO--6QxymIcDMpzrCEoGN-X3lWjRo,6120
7
+ multimark-0.1.3.dist-info/METADATA,sha256=98DLue-RZWaNRQ1C58v9QAbGCSHam8HwTS0QTIXt0Zs,5366
8
+ multimark-0.1.3.dist-info/WHEEL,sha256=x5Wpw_tLx5PQKiWdxpqvs0e7Sg-SO0mTWdEADYDGPGA,101
9
+ multimark-0.1.3.dist-info/top_level.txt,sha256=lcS6vQbZvnC-bJnymBpcBLwqvsfG_glKrrafN1zMXFQ,10
10
+ multimark-0.1.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1,128 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Richard Iannone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ The vendored cmark-gfm C library (third_party/cmark-gfm/) is distributed under
26
+ the following licenses:
27
+
28
+ Copyright (c) 2014, John MacFarlane
29
+
30
+ All rights reserved.
31
+
32
+ Redistribution and use in source and binary forms, with or without
33
+ modification, are permitted provided that the following conditions are met:
34
+
35
+ * Redistributions of source code must retain the above copyright
36
+ notice, this list of conditions and the following disclaimer.
37
+
38
+ * Redistributions in binary form must reproduce the above
39
+ copyright notice, this list of conditions and the following
40
+ disclaimer in the documentation and/or other materials provided
41
+ with the distribution.
42
+
43
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+
55
+ -----
56
+
57
+ houdini.h, houdini_href_e.c, houdini_html_e.c, houdini_html_u.c
58
+
59
+ derive from https://github.com/vmg/houdini (with some modifications)
60
+
61
+ Copyright (C) 2012 Vicent Martí
62
+
63
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
64
+ this software and associated documentation files (the "Software"), to deal in
65
+ the Software without restriction, including without limitation the rights to
66
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
67
+ of the Software, and to permit persons to whom the Software is furnished to do
68
+ so, subject to the following conditions:
69
+
70
+ The above copyright notice and this permission notice shall be included in all
71
+ copies or substantial portions of the Software.
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
75
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
76
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
78
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
79
+ SOFTWARE.
80
+
81
+ -----
82
+
83
+ buffer.h, buffer.c, chunk.h
84
+
85
+ are derived from code (C) 2012 Github, Inc.
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
88
+ this software and associated documentation files (the "Software"), to deal in
89
+ the Software without restriction, including without limitation the rights to
90
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
91
+ of the Software, and to permit persons to whom the Software is furnished to do
92
+ so, subject to the following conditions:
93
+
94
+ The above copyright notice and this permission notice shall be included in all
95
+ copies or substantial portions of the Software.
96
+
97
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
98
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
99
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
100
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
101
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
102
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
103
+ SOFTWARE.
104
+
105
+ -----
106
+
107
+ utf8.c and utf8.h
108
+
109
+ are derived from utf8proc (http://www.public-software-group.org/utf8proc),
110
+ (C) 2009 Public Software Group e. V., Berlin, Germany.
111
+
112
+ Permission is hereby granted, free of charge, to any person obtaining a
113
+ copy of this software and associated documentation files (the "Software"),
114
+ to deal in the Software without restriction, including without limitation
115
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
116
+ and/or sell copies of the Software, and to permit persons to whom the
117
+ Software is furnished to do so, subject to the following conditions:
118
+
119
+ The above copyright notice and this permission notice shall be included in
120
+ all copies or substantial portions of the Software.
121
+
122
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
123
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
124
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
125
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
126
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
127
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
128
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ multimark