mdhtml 0.1.43__tar.gz → 0.1.44__tar.gz
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.
- {mdhtml-0.1.43 → mdhtml-0.1.44}/Cargo.lock +4 -4
- {mdhtml-0.1.43 → mdhtml-0.1.44}/Cargo.toml +1 -1
- {mdhtml-0.1.43 → mdhtml-0.1.44}/DEV.md +1 -1
- {mdhtml-0.1.43 → mdhtml-0.1.44}/PKG-INFO +27 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/README.md +26 -1
- {mdhtml-0.1.43 → mdhtml-0.1.44}/docs/DIALECT.md +34 -3
- {mdhtml-0.1.43 → mdhtml-0.1.44}/docs/sample.html +21 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/sample-clean.md +14 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/sample-render.md +26 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/sample.md +16 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/py/src/lib.rs +69 -21
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/export.py +7 -4
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/md.py +6 -4
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/md2html.py +2 -1
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/readme.py +7 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/typst.py +21 -21
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/viewmd.py +5 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/ast.rs +38 -6
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/block.rs +5 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/export_html.rs +4 -3
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/html.rs +8 -8
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/import.rs +4 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/inline.rs +14 -28
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/lib.rs +1 -1
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/render.rs +38 -5
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/resolve.rs +205 -76
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/write_md.rs +24 -3
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/resolve.rs +61 -14
- mdhtml-0.1.44/tests/test_bibliography.py +64 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_focused.py +2 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_readme.py +4 -2
- {mdhtml-0.1.43 → mdhtml-0.1.44}/.cargo/config.toml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/.github/workflows/ci.yml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/.gitignore +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/.nojekyll +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/CHANGELOG.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/LICENSE +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/_config.yml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/_layouts/default.html +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/docs/puppy.jpg +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/README.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/demo.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/examples.ipynb +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/filldemo.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo-bound.docx +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo-filled.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo-filled.pdf +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo-form.docx +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo-render.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.docx +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.html +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.ipynb +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.pdf +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/legal_demo.typ +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/nbsample.ipynb +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/puppy.jpg +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/render_demo.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/sample.css +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/examples/sample.js +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/py/Cargo.toml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/py/build.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/pyproject.toml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/__init__.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/__main__.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/_cli.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/chunk.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/controls.html +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/fill.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/mustache.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/page.css +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/tools.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/view.css +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/view.js +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/python/mdhtml/wrap.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/rustfmt.toml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/attrs.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/chunk.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/diagnostic.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/entity.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/frontmatter.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/highlight.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/inline_spans.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/line.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/markdown.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/preview.css +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/scan.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/template.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/tmpl.css +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/wikitext.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/src/wrap.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/canonical.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/fixtures/dialect.html +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/fixtures/dialect.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/helpers.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/cmark-gfm/README.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/cmark-gfm/extensions.txt +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/cmark-gfm/spec.txt +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/kramdown.txt +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/markdowntests.md +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/mf.txt +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/pandoc-grid-tables.txt +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Abbr.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Abbr.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks Special Cases.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks Special Cases.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Definition Lists.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Definition Lists.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Emphasis.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Emphasis.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Footnotes.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Footnotes.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Headers with attributes.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Headers with attributes.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Inline HTML with Markdown content.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Inline HTML with Markdown content.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Link & Image Attributes.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Link & Image Attributes.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tables.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tables.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks Special Cases.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks Special Cases.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks.text +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks.xhtml +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_chunk.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_conformance.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_export.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_fill.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_pathological.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_python.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_typst.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/test_wrap.py +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/wasm.mjs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/wikitext.rs +0 -0
- {mdhtml-0.1.43 → mdhtml-0.1.44}/tests/wrap.rs +0 -0
|
@@ -131,7 +131,7 @@ dependencies = [
|
|
|
131
131
|
|
|
132
132
|
[[package]]
|
|
133
133
|
name = "mdhtml-crate"
|
|
134
|
-
version = "0.1.
|
|
134
|
+
version = "0.1.44"
|
|
135
135
|
dependencies = [
|
|
136
136
|
"base64",
|
|
137
137
|
"fast5ever",
|
|
@@ -141,7 +141,7 @@ dependencies = [
|
|
|
141
141
|
|
|
142
142
|
[[package]]
|
|
143
143
|
name = "mdhtml-py"
|
|
144
|
-
version = "0.1.
|
|
144
|
+
version = "0.1.44"
|
|
145
145
|
dependencies = [
|
|
146
146
|
"mdhtml-crate",
|
|
147
147
|
"pyo3",
|
|
@@ -150,7 +150,7 @@ dependencies = [
|
|
|
150
150
|
|
|
151
151
|
[[package]]
|
|
152
152
|
name = "mdhtml-wasm"
|
|
153
|
-
version = "0.1.
|
|
153
|
+
version = "0.1.44"
|
|
154
154
|
dependencies = [
|
|
155
155
|
"mdhtml-crate",
|
|
156
156
|
]
|
|
@@ -529,7 +529,7 @@ checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
|
|
|
529
529
|
|
|
530
530
|
[[package]]
|
|
531
531
|
name = "xtask"
|
|
532
|
-
version = "0.1.
|
|
532
|
+
version = "0.1.44"
|
|
533
533
|
dependencies = [
|
|
534
534
|
"anyhow",
|
|
535
535
|
"serde_json",
|
|
@@ -57,7 +57,7 @@ The Python binding uses public semantic model, encoder, writer and resolver APIs
|
|
|
57
57
|
|
|
58
58
|
Public conversion names use `x2y`, with both representations explicit: `md2mdhtml`, `mdhtml2md`, `wiki2mdhtml`, `md2gfm`, `mdhtml2gfm`, `mdhtml2html`, `mdhtml2typst`, `mdhtml2pdf`, external `mdhtml2docx`, `md2dom`, and `mdhtml2dom`. Operations within a representation, including `bake_mdhtml`, `blocks`, `rewrite`, and `fill_md`, keep ordinary verbs.
|
|
59
59
|
|
|
60
|
-
`src/write_md.rs` contains one Document-based md/GFM writer. `mdhtml2md` and `dom2md` import HTML then call it; they have no separate serializer. `resolve::
|
|
60
|
+
`src/write_md.rs` contains one Document-based md/GFM writer. `mdhtml2md` and `dom2md` import HTML then call it; they have no separate serializer. `resolve::prepare_document` assigns numbers, lowers bibliography layout and resolves citations, returning the reference index and warnings. `ReferenceIndex::plan` supplies ordinary inline content and native-field instructions. Typst/DOCX consume this plan without citation-specific logic. `resolve::bake_document` also resolves the remaining cross-references for static formats. Python retains an immutable native Document and projects values for format-specific emission. Bibliography records contain explicit citation-author text, optional year text and formatted block bodies; no bibliographic fields are inferred from prose.
|
|
61
61
|
|
|
62
62
|
`Document.frontmatter` retains the complete recognized fenced YAML. `Document::meta()` derives simple flat string pairs. Python's MDHTML result carries the same `frontmatter` and exposes a derived read-only `meta` mapping. Recognition and splitting live in `src/frontmatter.rs`; filling parses the selected payload with the existing string-preserving loader. Notebook metadata selection and merging remain notebook-specific.
|
|
63
63
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdhtml
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.44
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Requires-Dist: fast5ever>=0.1.5
|
|
@@ -67,6 +67,7 @@ The dialect deviates from CommonMark for three reasons:
|
|
|
67
67
|
- Raw passthrough: a Pandoc-style raw attribute names the payload's format. Use exactly `{=name}` as a fenced code block's info string or immediately after inline code. Both forms render as an inert `<script type="application/vnd.mdhtml.raw" data-format="name">`. Payload text stays literal unless it contains an HTML script-data hazard. [The dialect specification](docs/DIALECT.md#converter-specific-raw-data) defines the encoding rule.
|
|
68
68
|
- Template tokens: Jinja, Mustache, or other configured delimiters. Token recognition is opt-in. Tokens become semantic operations in inert HTML template elements. Overlapping opening delimiters use the longest match. Optional balanced scanning handles nested expressions.
|
|
69
69
|
- Cross-references: Quarto-style bracketed references to identified elements. `[@sec-pay]` renders as `<a data-ref href="#sec-pay"></a>`. Each converter resolves the reference for its output format. `[-@sec-pay]` adds the independent `bare` token. `[Clause @sec-pay]` supplies override text. `[@sec-a; @sec-b]` groups references in a `span` marked with `data-refs`. A trailing `{ref=page}` selects the `page` variant. The parser never resolves numbers or checks that targets exist.
|
|
70
|
+
- Bibliographies: `::: bibliography` contains a definition list. Each term supplies citation-author text, an id, and optional `year` text. Each definition supplies a formatted `md` entry. Citations use the existing reference syntax, with author-year or numeric presentation.
|
|
70
71
|
- Table captions and figures: place `: caption {attrs}` immediately after the table's last row, with no blank line. This uses Quarto's caption format but requires the caption to follow the table. The attributes apply to the table. With `implicit_figures=True`, a paragraph containing only one image becomes a Figure with a structured caption and plain-text image alt. The image's id and classes move to the Figure. Both the caption and original alt are retained by MDHTML encoding.
|
|
71
72
|
- Inline footnotes: pandoc-style `^[an inline note]`, numbered together with `[^id]` references.
|
|
72
73
|
|
|
@@ -241,12 +242,36 @@ typst = mdhtml2typst(document)
|
|
|
241
242
|
- Math has `tex`; inline math also has `display`. References have symbolic `items`, each with a target, tokens and optional authored prefix.
|
|
242
243
|
- Operations have `syntax`, `action`, `name`, block-capable `args`, and an optional selected `content` argument index. Their operands are inert unless a renderer explicitly uses them.
|
|
243
244
|
|
|
244
|
-
`document.bake(...)` returns a new Document with assigned numbers and reference text computed in Rust. It accepts `reftypes`, `number_headings`, `refs` and `
|
|
245
|
+
`document.bake(...)` returns a new Document with assigned numbers and reference text computed in Rust. It accepts `reftypes`, `number_headings`, `refs`, `links` and `cite_style`. `document.index(...)` supplies target information. `document.prepare(...)` returns `(document, index)` with citation text and bibliography layout prepared, retaining symbolic cross-references. Typst and DOCX render the index's shared plan of ordinary inline content and native `reference_field` instructions. Section and page fields remain live.
|
|
245
246
|
|
|
246
247
|
`document.mdhtml(callbacks=...)` encodes MDHTML; `document.markdown()` writes canonical md. For GFM, use `document.bake(links=False).markdown(gfm=True, tmpl=...)` or the `mdhtml2gfm` convenience. `document.map_urls(callback)` returns a rewritten Document and leaves operation operands inert. Complete YAML, derived `meta`, and `warnings` remain attached.
|
|
247
248
|
|
|
248
249
|
`Document.from_mdhtml(...)` and `import_mdhtml(...)` import symbolic MDHTML. Finished numbered output is not symbolic interchange input. Import normalizes a complete HTML5 fragment, not individual tag strings. Source positions and spellings remain available separately through `blocks`, `inlines`, and `rewrite`.
|
|
249
250
|
|
|
251
|
+
### Citations and bibliographies
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See also [see @merity2017, p. 3].
|
|
255
|
+
|
|
256
|
+
::: bibliography
|
|
257
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
258
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
259
|
+
|
|
260
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
261
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
262
|
+
:::
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The term is explicit citation-author text. `year` is an optional string, including values such as `2018a`, `n.d.` or `forthcoming`. The definition is the complete formatted entry. No author names, dates, or publication fields are inferred from prose. Bibliography generators own entry formatting, author abbreviation and date disambiguation. Definitions use the dialect's existing single-line definition syntax.
|
|
266
|
+
|
|
267
|
+
`[@howard2018]` produces `(Howard and Ruder, 2018)`. `{ref=text}` selects `Howard and Ruder (2018)`. `[-@howard2018]` suppresses the author and produces `(2018)`. Prefix and suffix text are supported per item, as in `[see @howard2018, p. 3; @merity2017]`. Ordinary cross-references also retain suffix text.
|
|
268
|
+
|
|
269
|
+
Use frontmatter `cite_style: numeric`, or `cite_style='numeric'` on an exporter, for `[1]` citations and numbered entries. Author-year is the default. Numbers follow bibliography order across the document, all entries remain included, and citation groups retain their authored order. HTML, GFM, Typst, PDF, DOCX and terminal output share the Rust preparation machinery. Exporter options override frontmatter.
|
|
270
|
+
|
|
271
|
+
Bibliography entries expose `attrs`, inline `author`, optional `year` and block `body` in `Document.blocks`. Canonical md and symbolic MDHTML retain these fields. Preparation lowers bibliography layout to ordinary blocks and citations to ordinary text and links. A prepared document no longer contains the original citation data. Change styles by preparing the original document again.
|
|
272
|
+
|
|
273
|
+
An entry requires an id and author text. A malformed bibliography, duplicate target id, unknown citation style, or invalid reference produces a conversion error. `refs='lenient'` preserves unresolved references as ids with warnings. Citation groups cannot mix bibliography entries and other targets. A narrative citation requires one work and no prefix. Citations do not support `page`, `leaf`, or `rel`.
|
|
274
|
+
|
|
250
275
|
### md chunks
|
|
251
276
|
|
|
252
277
|
Choose among three chunking algorithms:
|
|
@@ -35,6 +35,7 @@ The dialect deviates from CommonMark for three reasons:
|
|
|
35
35
|
- Raw passthrough: a Pandoc-style raw attribute names the payload's format. Use exactly `{=name}` as a fenced code block's info string or immediately after inline code. Both forms render as an inert `<script type="application/vnd.mdhtml.raw" data-format="name">`. Payload text stays literal unless it contains an HTML script-data hazard. [The dialect specification](docs/DIALECT.md#converter-specific-raw-data) defines the encoding rule.
|
|
36
36
|
- Template tokens: Jinja, Mustache, or other configured delimiters. Token recognition is opt-in. Tokens become semantic operations in inert HTML template elements. Overlapping opening delimiters use the longest match. Optional balanced scanning handles nested expressions.
|
|
37
37
|
- Cross-references: Quarto-style bracketed references to identified elements. `[@sec-pay]` renders as `<a data-ref href="#sec-pay"></a>`. Each converter resolves the reference for its output format. `[-@sec-pay]` adds the independent `bare` token. `[Clause @sec-pay]` supplies override text. `[@sec-a; @sec-b]` groups references in a `span` marked with `data-refs`. A trailing `{ref=page}` selects the `page` variant. The parser never resolves numbers or checks that targets exist.
|
|
38
|
+
- Bibliographies: `::: bibliography` contains a definition list. Each term supplies citation-author text, an id, and optional `year` text. Each definition supplies a formatted `md` entry. Citations use the existing reference syntax, with author-year or numeric presentation.
|
|
38
39
|
- Table captions and figures: place `: caption {attrs}` immediately after the table's last row, with no blank line. This uses Quarto's caption format but requires the caption to follow the table. The attributes apply to the table. With `implicit_figures=True`, a paragraph containing only one image becomes a Figure with a structured caption and plain-text image alt. The image's id and classes move to the Figure. Both the caption and original alt are retained by MDHTML encoding.
|
|
39
40
|
- Inline footnotes: pandoc-style `^[an inline note]`, numbered together with `[^id]` references.
|
|
40
41
|
|
|
@@ -209,12 +210,36 @@ typst = mdhtml2typst(document)
|
|
|
209
210
|
- Math has `tex`; inline math also has `display`. References have symbolic `items`, each with a target, tokens and optional authored prefix.
|
|
210
211
|
- Operations have `syntax`, `action`, `name`, block-capable `args`, and an optional selected `content` argument index. Their operands are inert unless a renderer explicitly uses them.
|
|
211
212
|
|
|
212
|
-
`document.bake(...)` returns a new Document with assigned numbers and reference text computed in Rust. It accepts `reftypes`, `number_headings`, `refs` and `
|
|
213
|
+
`document.bake(...)` returns a new Document with assigned numbers and reference text computed in Rust. It accepts `reftypes`, `number_headings`, `refs`, `links` and `cite_style`. `document.index(...)` supplies target information. `document.prepare(...)` returns `(document, index)` with citation text and bibliography layout prepared, retaining symbolic cross-references. Typst and DOCX render the index's shared plan of ordinary inline content and native `reference_field` instructions. Section and page fields remain live.
|
|
213
214
|
|
|
214
215
|
`document.mdhtml(callbacks=...)` encodes MDHTML; `document.markdown()` writes canonical md. For GFM, use `document.bake(links=False).markdown(gfm=True, tmpl=...)` or the `mdhtml2gfm` convenience. `document.map_urls(callback)` returns a rewritten Document and leaves operation operands inert. Complete YAML, derived `meta`, and `warnings` remain attached.
|
|
215
216
|
|
|
216
217
|
`Document.from_mdhtml(...)` and `import_mdhtml(...)` import symbolic MDHTML. Finished numbered output is not symbolic interchange input. Import normalizes a complete HTML5 fragment, not individual tag strings. Source positions and spellings remain available separately through `blocks`, `inlines`, and `rewrite`.
|
|
217
218
|
|
|
219
|
+
### Citations and bibliographies
|
|
220
|
+
|
|
221
|
+
```markdown
|
|
222
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See also [see @merity2017, p. 3].
|
|
223
|
+
|
|
224
|
+
::: bibliography
|
|
225
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
226
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
227
|
+
|
|
228
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
229
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
230
|
+
:::
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The term is explicit citation-author text. `year` is an optional string, including values such as `2018a`, `n.d.` or `forthcoming`. The definition is the complete formatted entry. No author names, dates, or publication fields are inferred from prose. Bibliography generators own entry formatting, author abbreviation and date disambiguation. Definitions use the dialect's existing single-line definition syntax.
|
|
234
|
+
|
|
235
|
+
`[@howard2018]` produces `(Howard and Ruder, 2018)`. `{ref=text}` selects `Howard and Ruder (2018)`. `[-@howard2018]` suppresses the author and produces `(2018)`. Prefix and suffix text are supported per item, as in `[see @howard2018, p. 3; @merity2017]`. Ordinary cross-references also retain suffix text.
|
|
236
|
+
|
|
237
|
+
Use frontmatter `cite_style: numeric`, or `cite_style='numeric'` on an exporter, for `[1]` citations and numbered entries. Author-year is the default. Numbers follow bibliography order across the document, all entries remain included, and citation groups retain their authored order. HTML, GFM, Typst, PDF, DOCX and terminal output share the Rust preparation machinery. Exporter options override frontmatter.
|
|
238
|
+
|
|
239
|
+
Bibliography entries expose `attrs`, inline `author`, optional `year` and block `body` in `Document.blocks`. Canonical md and symbolic MDHTML retain these fields. Preparation lowers bibliography layout to ordinary blocks and citations to ordinary text and links. A prepared document no longer contains the original citation data. Change styles by preparing the original document again.
|
|
240
|
+
|
|
241
|
+
An entry requires an id and author text. A malformed bibliography, duplicate target id, unknown citation style, or invalid reference produces a conversion error. `refs='lenient'` preserves unresolved references as ids with warnings. Citation groups cannot mix bibliography entries and other targets. A narrative citation requires one work and no prefix. Citations do not support `page`, `leaf`, or `rel`.
|
|
242
|
+
|
|
218
243
|
### md chunks
|
|
219
244
|
|
|
220
245
|
Choose among three chunking algorithms:
|
|
@@ -239,7 +239,7 @@ MDHTML:
|
|
|
239
239
|
|
|
240
240
|
Definition lists use `dl`, `dt`, and `dd`. They are a leaf block: glued term lines followed by glued single-line `: definition` lines, with inline-only definitions and no loose form (a blank line ends the run, though adjacent lists merge into one `dl`). Only `:` marks a definition line. A term line may end with an attribute block, which binds to its `dt` exactly as a trailing attribute block binds to a heading. Block content in a definition is written as raw `<dl>` soup or a fenced div. Fenced divs follow Pandoc's opening syntax: an opening fence has at least three colons and attributes, a bare class word, or — deviating from Pandoc, which allows one or the other — both, merged: `::: details {#x open=''}` and `::: {.details #x open=''}` are the same opener. The bare word means that one class. A closing fence is a colon-only line of exactly the opening fence's length, so a longer outer fence can contain a shorter colon-only line as literal text.
|
|
241
241
|
|
|
242
|
-
A fenced div is ordinarily a `div` in MDHTML. The panel modifiers below are interpreted by the `md` importer; `math` remains a reserved class for the display-math carrier. Other class words are author styling, not implicit converter instructions.
|
|
242
|
+
A fenced div is ordinarily a `div` in MDHTML. The panel modifiers below and `bibliography` containers are interpreted by the `md` importer; `math` remains a reserved class for the display-math carrier. Other class words are author styling, not implicit converter instructions.
|
|
243
243
|
|
|
244
244
|
### Panels: callouts and disclosures
|
|
245
245
|
|
|
@@ -373,7 +373,7 @@ See [@sec-payment], [-@tbl-stages], [Clause @sec-late], and
|
|
|
373
373
|
<span data-refs=""><a href="#sec-payment" data-ref=""></a><a href="#sec-late" data-ref=""></a></span>. Page <a href="#sec-late" data-ref="bare page"></a>.</p>
|
|
374
374
|
```
|
|
375
375
|
|
|
376
|
-
References are recognized only inside bracket groups. An id starts with an ASCII letter or digit and continues with ASCII letters, digits, `-`, or `_`.
|
|
376
|
+
References are recognized only inside bracket groups. An id starts with an ASCII letter or digit and continues with ASCII letters, digits, `-`, or `_`. Each semicolon-separated item may carry prefix text before `@`, separated by whitespace, and suffix text after its id. A cross-reference prefix overrides its automatic prefix word. The suffix follows the resolved reference verbatim and is encoded as `data-suffix` on the anchor. Explicit link syntax wins. A group that fails this grammar remains literal text. Thus `[@sec-x](url)` is a link and `[user@host]` is ordinary text.
|
|
377
377
|
|
|
378
378
|
The presence of `data-ref` marks a reference. No token selects the default full rendering. `bare` independently suppresses the prefix word, and at most one of `page`, `text`, `leaf`, or `rel` selects another rendering. Token order is insignificant. Bare `data-ref` and `data-ref=""` are the same DOM value; html5ever serializes it as `data-ref=""`. Unknown or conflicting tokens are MDHTML errors and converters report them as conversion errors. A group uses `data-refs` on its containing `span`.
|
|
379
379
|
|
|
@@ -387,6 +387,37 @@ The shipped exporters use Rust's shared reference vocabulary through `mdhtml.exp
|
|
|
387
387
|
|
|
388
388
|
`mdhtml2html` also offers `refs='ids'` for live-preview contexts where targets may sit outside the fragment: each reference bakes as a working link showing its target id (class `xref`), with no registry, numbering, or failure modes - and captions render as authored, since per-fragment numbers would lie. `id_prefix` namespaces the fragment's ids against a host page (the authored id kept in `data-id`), and `fn_salt` adds a further prefix to the `fn-*`/`fnref-*` footnote namespace only, keeping footnote pairs distinct across fragments that share one `id_prefix`.
|
|
389
389
|
|
|
390
|
+
## Citations and bibliographies
|
|
391
|
+
|
|
392
|
+
A fenced `bibliography` div contains one definition list, with one term per entry:
|
|
393
|
+
|
|
394
|
+
```markdown
|
|
395
|
+
::: bibliography
|
|
396
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
397
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*.
|
|
398
|
+
:::
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
The term supplies citation-author text, its id supplies the key, and `year` supplies optional citation-date text. The date is an uninterpreted nonempty string. The definition supplies the complete formatted entry using the ordinary definition-list syntax. Author abbreviation, date disambiguation, publication formatting, and bibliography generation belong to the producer. mdhtml never recovers bibliographic fields from prose. Missing ids, empty author text, malformed bibliography structure and duplicate target ids are conversion errors.
|
|
402
|
+
|
|
403
|
+
Symbolic MDHTML uses `<div class="bibliography"><dl><dt id="howard2018" year="2018">Howard and Ruder</dt><dd>...</dd></dl></div>`. The semantic `Bibliography` block retains entries with attributes, inline author text, optional year, and block body. The class `bibliography` is reserved for this structure. Finished output uses ordinary blocks with the styling class `bibliography-entries`.
|
|
404
|
+
|
|
405
|
+
A reference to a bibliography entry is a citation. It shares the reference parser, target index, validation and link machinery with other references. The default style is `author-year`. Frontmatter `cite_style: numeric` or an exporter's `cite_style` argument selects numeric style. An explicit argument overrides frontmatter. Unknown styles are errors in all exporters.
|
|
406
|
+
|
|
407
|
+
| Source | Author-year | Numeric |
|
|
408
|
+
|:--|:--|:--|
|
|
409
|
+
| `[@howard2018]` | (Howard and Ruder, 2018) | [1] |
|
|
410
|
+
| `[@howard2018]{ref=text}` | Howard and Ruder (2018) | Howard and Ruder [1] |
|
|
411
|
+
| `[-@howard2018]` | (2018) | [1] |
|
|
412
|
+
| `[-@howard2018]{ref=text}` | 2018 | [1] |
|
|
413
|
+
| `[see @howard2018, p. 3]` | (see Howard and Ruder, 2018, p. 3) | see [1, p. 3] |
|
|
414
|
+
|
|
415
|
+
With no year, author-year citations use the author text alone; `bare` does not remove it. Parenthetical groups share one pair of delimiters and preserve authored item order. Author-year groups use `; `. Numeric groups use `, ` when every suffix is empty, otherwise `; `. In numeric style the first item's prefix precedes the brackets; other prefixes precede their items. A suffix retains its authored punctuation. `text` requires one citation and no prefix. `page`, `leaf`, and `rel` are invalid for citations. A group cannot mix citations and other reference kinds. An unknown key alongside a known citation retains citation grouping in lenient mode and produces a warning.
|
|
416
|
+
|
|
417
|
+
All bibliography entries appear in authored order, including uncited entries. Numeric style numbers them in that order across all bibliographies in the document. Author-year output renders each formatted body without its citation-author term. Numeric output prefixes each body with its number. Formats supporting internal links link citations to their entries; GFM and terminal output use plain citation text.
|
|
418
|
+
|
|
419
|
+
Rust preparation assigns numbers, lowers bibliography layout to ordinary blocks, and resolves citations to ordinary inline content. It returns the prepared document and reference index. Remaining cross-references stay symbolic; the shared reference plan contains ordinary inline content and native-field instructions. Typst and DOCX emit native fields for these remaining references. Static baking resolves them as well. Preparation does not mutate the original document. Reformat the original document when changing citation style.
|
|
420
|
+
|
|
390
421
|
## Raw HTML and md in HTML
|
|
391
422
|
|
|
392
423
|
Raw HTML participates in the final whole-fragment HTML5 parse. There is no separate balance operation.
|
|
@@ -591,7 +622,7 @@ Beyond the element mapping above, a few structural patterns carry a *meaning* ev
|
|
|
591
622
|
- **Range markers.** Template `section`/`inverted` and `end` operations are paired siblings around the content they control. Converters render unfilled range instructions visibly when appropriate; the content between markers remains normal flow content.
|
|
592
623
|
- **Active-code carriers.** A `text/<lang>-block` script is template code, not content: dropped from final documents by default, echoable as code where an audit register wants it, and never executed by any converter (`instantiate` alone executes).
|
|
593
624
|
|
|
594
|
-
The class words with assigned converter behavior — `math` for math carriers
|
|
625
|
+
The class words with assigned converter behavior — `math` for math carriers, `footnotes` on the footnote `section`, and `bibliography` on a bibliography container — are reserved by this section. `details` and `callout-*` are authoring aliases normalized to panels by the `md` importer, not class-based export rules. Other class words are inert data for styling.
|
|
595
626
|
|
|
596
627
|
## Warnings
|
|
597
628
|
|
|
@@ -321,6 +321,27 @@ page [-@sec-late]{ref=page}, paragraph [-@sec-late]{ref=leaf} of
|
|
|
321
321
|
<h3 id="sec-payment">Payment terms</h3>
|
|
322
322
|
<h4 id="sec-late">Late fees</h4>
|
|
323
323
|
<p>Interest accrues per <a href="#sec-late" data-ref=""></a>, within <a href="#sec-payment" data-ref="bare"></a>, as set out in <a href="#sec-late" data-ref="">Clause</a>. The terms in <span data-refs=""><a href="#sec-payment" data-ref=""></a><a href="#sec-late" data-ref=""></a></span> survive termination. See also <a href="#fig-diagram" data-ref=""></a> and <a href="#tbl-stages" data-ref="bare"></a>, or the mixed pair <span data-refs=""><a href="#fig-diagram" data-ref=""></a><a href="#tbl-stages" data-ref=""></a></span>. Variants: the <a href="#sec-late" data-ref="bare text"></a> clause, on page <a href="#sec-late" data-ref="bare page"></a>, paragraph <a href="#sec-late" data-ref="bare leaf"></a> of <a href="#sec-late" data-ref="bare rel"></a>.</p>
|
|
324
|
+
<h2>Citations and bibliographies</h2>
|
|
325
|
+
<p>Bibliography terms contain explicit citation-author text, keys and optional year text. Their definitions are formatted entries. Use <code>cite_style: numeric</code> in frontmatter for numbered citations in bibliography order.</p>
|
|
326
|
+
<pre><code class="language-markdown">The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See [see @merity2017, p. 3], or suppress the author with [-@howard2018].
|
|
327
|
+
|
|
328
|
+
::: bibliography
|
|
329
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
330
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
331
|
+
|
|
332
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
333
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
334
|
+
:::
|
|
335
|
+
</code></pre>
|
|
336
|
+
<p>The method builds on <a href="#howard2018" data-ref=""></a>. <a href="#howard2018" data-ref="text"></a> report the results. See <a href="#merity2017" data-ref="" data-suffix=", p. 3">see</a>, or suppress the author with <a href="#howard2018" data-ref="bare"></a>.</p>
|
|
337
|
+
<div class="bibliography">
|
|
338
|
+
<dl>
|
|
339
|
+
<dt id="howard2018" year="2018">Howard and Ruder</dt>
|
|
340
|
+
<dd>Jeremy Howard and Sebastian Ruder. 2018. <em>Universal Language Model Fine-tuning for Text Classification</em>. Proceedings of ACL.</dd>
|
|
341
|
+
<dt id="merity2017" year="forthcoming">Merity et al.</dt>
|
|
342
|
+
<dd>Stephen Merity et al. <em>Regularizing and Optimizing LSTM Language Models</em>.</dd>
|
|
343
|
+
</dl>
|
|
344
|
+
</div>
|
|
324
345
|
<h2>Raw passthrough</h2>
|
|
325
346
|
<p>A fenced block whose info string is <code>{=name}</code>, or inline code followed by <code>{=name}</code>, passes through for the converter that understands that format; everyone else drops it:</p>
|
|
326
347
|
<pre><code class="language-markdown">```{=docx}
|
|
@@ -255,6 +255,20 @@ See also [@fig-diagram] and [-@tbl-stages], or the mixed pair
|
|
|
255
255
|
page [-@sec-late]{ref=page}, paragraph [-@sec-late]{ref=leaf} of
|
|
256
256
|
[-@sec-late]{ref=rel}.
|
|
257
257
|
|
|
258
|
+
## Citations and bibliographies
|
|
259
|
+
|
|
260
|
+
Bibliography terms contain explicit citation-author text, keys and optional year text. Their definitions are formatted entries. Use `cite_style: numeric` in frontmatter for numbered citations in bibliography order.
|
|
261
|
+
|
|
262
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See [see @merity2017, p. 3], or suppress the author with [-@howard2018].
|
|
263
|
+
|
|
264
|
+
::: bibliography
|
|
265
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
266
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
267
|
+
|
|
268
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
269
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
270
|
+
:::
|
|
271
|
+
|
|
258
272
|
## Raw passthrough
|
|
259
273
|
|
|
260
274
|
A fenced block whose info string is `{=name}`, or inline code followed by
|
|
@@ -466,6 +466,32 @@ See also [@fig-diagram] and [-@tbl-stages], or the mixed pair
|
|
|
466
466
|
page [-@sec-late]{ref=page}, paragraph [-@sec-late]{ref=leaf} of
|
|
467
467
|
[-@sec-late]{ref=rel}.
|
|
468
468
|
|
|
469
|
+
## Citations and bibliographies
|
|
470
|
+
|
|
471
|
+
Bibliography terms contain explicit citation-author text, keys and optional year text. Their definitions are formatted entries. Use `cite_style: numeric` in frontmatter for numbered citations in bibliography order.
|
|
472
|
+
|
|
473
|
+
`````markdown
|
|
474
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See [see @merity2017, p. 3], or suppress the author with [-@howard2018].
|
|
475
|
+
|
|
476
|
+
::: bibliography
|
|
477
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
478
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
479
|
+
|
|
480
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
481
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
482
|
+
:::
|
|
483
|
+
`````
|
|
484
|
+
|
|
485
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See [see @merity2017, p. 3], or suppress the author with [-@howard2018].
|
|
486
|
+
|
|
487
|
+
::: bibliography
|
|
488
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
489
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
490
|
+
|
|
491
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
492
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
493
|
+
:::
|
|
494
|
+
|
|
469
495
|
## Raw passthrough
|
|
470
496
|
|
|
471
497
|
A fenced block whose info string is `{=name}`, or inline code followed by
|
|
@@ -297,6 +297,22 @@ page [-@sec-late]{ref=page}, paragraph [-@sec-late]{ref=leaf} of
|
|
|
297
297
|
[-@sec-late]{ref=rel}.
|
|
298
298
|
`````
|
|
299
299
|
|
|
300
|
+
## Citations and bibliographies
|
|
301
|
+
|
|
302
|
+
Bibliography terms contain explicit citation-author text, keys and optional year text. Their definitions are formatted entries. Use `cite_style: numeric` in frontmatter for numbered citations in bibliography order.
|
|
303
|
+
|
|
304
|
+
`````markdown
|
|
305
|
+
The method builds on [@howard2018]. [@howard2018]{ref=text} report the results. See [see @merity2017, p. 3], or suppress the author with [-@howard2018].
|
|
306
|
+
|
|
307
|
+
::: bibliography
|
|
308
|
+
Howard and Ruder {#howard2018 year=2018}
|
|
309
|
+
: Jeremy Howard and Sebastian Ruder. 2018. *Universal Language Model Fine-tuning for Text Classification*. Proceedings of ACL.
|
|
310
|
+
|
|
311
|
+
Merity et al. {#merity2017 year=forthcoming}
|
|
312
|
+
: Stephen Merity et al. *Regularizing and Optimizing LSTM Language Models*.
|
|
313
|
+
:::
|
|
314
|
+
`````
|
|
315
|
+
|
|
300
316
|
## Raw passthrough
|
|
301
317
|
|
|
302
318
|
A fenced block whose info string is `{=name}`, or inline code followed by
|
|
@@ -49,15 +49,31 @@ impl PyDocument {
|
|
|
49
49
|
doc.map_urls(&mut |url, image| rewrite.call1((url, image))?.extract::<Option<String>>())?;
|
|
50
50
|
Ok(Self { doc })
|
|
51
51
|
}
|
|
52
|
-
#[pyo3(signature = (reftypes=None, number_headings=None))]
|
|
53
|
-
fn index(
|
|
54
|
-
|
|
52
|
+
#[pyo3(signature = (reftypes=None, number_headings=None, cite_style=None))]
|
|
53
|
+
fn index(
|
|
54
|
+
&self, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, cite_style: Option<&str>
|
|
55
|
+
) -> PyResult<PyReferenceIndex> {
|
|
56
|
+
Ok(PyReferenceIndex {
|
|
57
|
+
inner: resolve::ReferenceIndex::new(&self.doc, reftypes, parse_number_headings(number_headings)?, parse_cite_style(cite_style)?).map_err(vr)? })
|
|
55
58
|
}
|
|
56
|
-
|
|
59
|
+
/// Prepare numbers, citation text and bibliography layout; retain other references for native fields.
|
|
60
|
+
#[pyo3(signature = (reftypes=None, number_headings=None, cite_style=None))]
|
|
61
|
+
fn prepare(
|
|
62
|
+
&self, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, cite_style: Option<&str>
|
|
63
|
+
) -> PyResult<(Self, PyReferenceIndex)> {
|
|
64
|
+
let options = resolve::BakeOptions { reftypes, number_headings: parse_number_headings(number_headings)?, cite_style: parse_cite_style(cite_style)?,
|
|
65
|
+
..Default::default() };
|
|
66
|
+
let mut doc = self.doc.clone();
|
|
67
|
+
let (inner, warnings) = resolve::prepare_document(&mut doc, &options).map_err(vr)?;
|
|
68
|
+
doc.diagnostics.extend(warnings.into_iter().map(|w| mdhtml::Diagnostic::warning("reference", w)));
|
|
69
|
+
Ok((Self { doc }, PyReferenceIndex { inner }))
|
|
70
|
+
}
|
|
71
|
+
#[pyo3(signature = (reftypes=None, number_headings=None, refs="resolve", links=true, cite_style=None))]
|
|
57
72
|
fn bake(
|
|
58
|
-
&self, py: Python<'_>, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, refs: &str, links: bool
|
|
59
|
-
|
|
60
|
-
let options = resolve::BakeOptions { reftypes, number_headings: parse_number_headings(number_headings)?, refs: parse_refs(refs)?, links
|
|
73
|
+
&self, py: Python<'_>, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, refs: &str, links: bool,
|
|
74
|
+
cite_style: Option<&str>) -> PyResult<Self> {
|
|
75
|
+
let options = resolve::BakeOptions { reftypes, number_headings: parse_number_headings(number_headings)?, refs: parse_refs(refs)?, links,
|
|
76
|
+
cite_style: parse_cite_style(cite_style)? };
|
|
61
77
|
let mut doc = self.doc.clone();
|
|
62
78
|
let warnings = py.detach(|| resolve::bake_document(&mut doc, &options)).map_err(vr)?;
|
|
63
79
|
doc.diagnostics.extend(warnings.into_iter().map(|w| mdhtml::Diagnostic::warning("reference", w)));
|
|
@@ -131,21 +147,36 @@ impl PyReferenceIndex {
|
|
|
131
147
|
fn plan(&self, py: Python<'_>, items: Vec<Bound<'_, PyDict>>) -> PyResult<Vec<Py<PyDict>>> {
|
|
132
148
|
let items = items.iter().map(reference_from_py).collect::<PyResult<Vec<_>>>()?;
|
|
133
149
|
let (parts, _) = self.inner.plan(&items, resolve::RefsMode::Resolve).map_err(vr)?;
|
|
134
|
-
parts.into_iter().map(|part| {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
parts.into_iter().map(|part| match part {
|
|
151
|
+
resolve::ReferencePart::Content(inline) => inline_node(py, &inline).map(Bound::unbind),
|
|
152
|
+
resolve::ReferencePart::Field { reference, target, prefix, variant, bare } => {
|
|
153
|
+
let d = target_node(py, target)?;
|
|
154
|
+
d.set_item("type", "reference_field")?;
|
|
155
|
+
d.set_item("target", &reference.target)?;
|
|
156
|
+
d.set_item("prefix", prefix)?;
|
|
157
|
+
d.set_item("variant", variant)?;
|
|
158
|
+
d.set_item("bare", bare)?;
|
|
159
|
+
Ok(d.unbind())
|
|
160
|
+
}
|
|
142
161
|
}).collect()
|
|
143
162
|
}
|
|
163
|
+
#[getter]
|
|
164
|
+
fn cite_style(&self) -> &'static str {
|
|
165
|
+
match self.inner.cite_style { resolve::CiteStyle::AuthorYear => "author-year", resolve::CiteStyle::Numeric => "numeric" }
|
|
166
|
+
}
|
|
167
|
+
/// A reference group resolved to inline nodes in `resolve` mode: plain text, or links with `links=True`.
|
|
168
|
+
#[pyo3(signature = (items, links=false))]
|
|
169
|
+
fn resolve(&self, py: Python<'_>, items: Vec<Bound<'_, PyDict>>, links: bool) -> PyResult<Vec<Py<PyDict>>> {
|
|
170
|
+
let items = items.iter().map(reference_from_py).collect::<PyResult<Vec<_>>>()?;
|
|
171
|
+
let (inlines, _) = self.inner.resolve(&items, resolve::RefsMode::Resolve, links).map_err(vr)?;
|
|
172
|
+
inline_nodes(py, &inlines)
|
|
173
|
+
}
|
|
144
174
|
}
|
|
145
175
|
|
|
146
176
|
fn reference_from_py(node: &Bound<'_, PyDict>) -> PyResult<mdhtml::Reference> {
|
|
147
177
|
let get = |key| node.get_item(key)?.ok_or_else(|| PyKeyError::new_err(key));
|
|
148
|
-
Ok(mdhtml::Reference { target: get("target")?.extract()?, tokens: get("tokens")?.extract()?, prefix: get("prefix")?.extract()
|
|
178
|
+
Ok(mdhtml::Reference { target: get("target")?.extract()?, tokens: get("tokens")?.extract()?, prefix: get("prefix")?.extract()?,
|
|
179
|
+
suffix: get("suffix")?.extract()? })
|
|
149
180
|
}
|
|
150
181
|
|
|
151
182
|
fn canonical_mdhtml(html: &str) -> String { mdhtml::fast5ever::parse_fragment(html, "body").to_html(mdhtml::fast5ever::DOCUMENT) }
|
|
@@ -291,12 +322,13 @@ fn block_span_node(py: Python<'_>, span: BlockSpan, start: usize, end: usize) ->
|
|
|
291
322
|
/// `strip_trailing_attr` would consume, as the dialect's own grammar judges it.
|
|
292
323
|
#[pyfunction]
|
|
293
324
|
fn trailing_attr_span(line: &str) -> Option<(usize, usize)> { mdhtml::trailing_attr_span(line) }
|
|
294
|
-
fn xref_refs(py: Python<'_>, refs: Vec<mdhtml::
|
|
325
|
+
fn xref_refs(py: Python<'_>, refs: Vec<mdhtml::Reference>) -> PyResult<Vec<Py<PyDict>>> {
|
|
295
326
|
refs.into_iter().map(|r| {
|
|
296
327
|
let rd = PyDict::new(py);
|
|
297
328
|
rd.set_item("target", r.target)?;
|
|
298
|
-
rd.set_item("
|
|
329
|
+
rd.set_item("tokens", r.tokens)?;
|
|
299
330
|
rd.set_item("prefix", r.prefix)?;
|
|
331
|
+
rd.set_item("suffix", r.suffix)?;
|
|
300
332
|
Ok(rd.unbind())
|
|
301
333
|
}).collect()
|
|
302
334
|
}
|
|
@@ -534,6 +566,7 @@ fn target_node<'py>(py: Python<'py>, target: &resolve::Target) -> PyResult<Bound
|
|
|
534
566
|
d.set_item("kind", target.kind.as_str())?;
|
|
535
567
|
d.set_item("text", &target.text)?;
|
|
536
568
|
d.set_item("number", number_node(py, target.number.as_ref())?)?;
|
|
569
|
+
d.set_item("year", &target.year)?;
|
|
537
570
|
Ok(d)
|
|
538
571
|
}
|
|
539
572
|
|
|
@@ -602,6 +635,18 @@ fn block_node<'py>(py: Python<'py>, block: &Block) -> PyResult<Bound<'py, PyDict
|
|
|
602
635
|
d.set_item("items", items)?;
|
|
603
636
|
"definition_list"
|
|
604
637
|
}
|
|
638
|
+
Block::Bibliography { entries, .. } => {
|
|
639
|
+
let entries = entries.iter().map(|entry| -> PyResult<Py<PyDict>> {
|
|
640
|
+
let value = PyDict::new(py);
|
|
641
|
+
value.set_item("attrs", semantic_attrs(py, Some(&entry.attrs))?)?;
|
|
642
|
+
value.set_item("author", inline_nodes(py, &entry.author)?)?;
|
|
643
|
+
value.set_item("year", &entry.year)?;
|
|
644
|
+
value.set_item("body", block_nodes(py, &entry.body)?)?;
|
|
645
|
+
Ok(value.unbind())
|
|
646
|
+
}).collect::<PyResult<Vec<_>>>()?;
|
|
647
|
+
d.set_item("entries", entries)?;
|
|
648
|
+
"bibliography"
|
|
649
|
+
}
|
|
605
650
|
Block::Table { aligns, head, rows, foot, caption, number, .. } => {
|
|
606
651
|
let columns = mdhtml::ast::table_columns(aligns, head, rows, foot);
|
|
607
652
|
d.set_item("columns", columns)?;
|
|
@@ -735,6 +780,7 @@ fn reference_node(py: Python<'_>, item: &mdhtml::Reference) -> PyResult<Py<PyDic
|
|
|
735
780
|
d.set_item("target", &item.target)?;
|
|
736
781
|
d.set_item("tokens", &item.tokens)?;
|
|
737
782
|
d.set_item("prefix", &item.prefix)?;
|
|
783
|
+
d.set_item("suffix", &item.suffix)?;
|
|
738
784
|
Ok(d.unbind())
|
|
739
785
|
}
|
|
740
786
|
|
|
@@ -773,6 +819,8 @@ fn callback_node<'py>(py: Python<'py>, node: mdhtml::render::EncodeNode<'_>) ->
|
|
|
773
819
|
// HTML exporter (src/export_html.rs) binding
|
|
774
820
|
// ---------------------------------------------------------------------------
|
|
775
821
|
|
|
822
|
+
fn parse_cite_style(value: Option<&str>) -> PyResult<Option<resolve::CiteStyle>> { value.map(|name| resolve::CiteStyle::parse(name).map_err(vr)).transpose() }
|
|
823
|
+
|
|
776
824
|
fn parse_number_headings(value: Option<&Bound<'_, PyAny>>) -> PyResult<Option<resolve::NumberHeadings>> {
|
|
777
825
|
use resolve::NumberHeadings;
|
|
778
826
|
Ok(match value {
|
|
@@ -794,11 +842,11 @@ fn parse_refs(refs: &str) -> PyResult<resolve::RefsMode> {
|
|
|
794
842
|
}
|
|
795
843
|
|
|
796
844
|
#[pyfunction]
|
|
797
|
-
#[pyo3(signature = (document, reftypes, number_headings, hl, toc, refs, id_prefix, fn_salt, hl_lang, code_wrap, hl_fn, auto_ids, gh_ids))]
|
|
845
|
+
#[pyo3(signature = (document, reftypes, number_headings, hl, toc, refs, id_prefix, fn_salt, hl_lang, code_wrap, hl_fn, auto_ids, gh_ids, cite_style))]
|
|
798
846
|
fn export_html(
|
|
799
847
|
py: Python<'_>, document: &PyDocument, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, hl: Option<&str>,
|
|
800
848
|
toc: bool, refs: &str, id_prefix: &str, fn_salt: &str, hl_lang: Option<Py<PyAny>>, code_wrap: Option<Py<PyAny>>, hl_fn: Option<Py<PyAny>>, auto_ids: bool,
|
|
801
|
-
gh_ids: bool) -> PyResult<(String, Vec<String>)> {
|
|
849
|
+
gh_ids: bool, cite_style: Option<&str>) -> PyResult<(String, Vec<String>)> {
|
|
802
850
|
use mdhtml::export_html::{HlMode, HtmlExportOptions};
|
|
803
851
|
let number_headings = parse_number_headings(number_headings)?;
|
|
804
852
|
let hook_err: std::sync::Mutex<Option<PyErr>> = std::sync::Mutex::new(None);
|
|
@@ -821,7 +869,7 @@ fn export_html(
|
|
|
821
869
|
let opts = HtmlExportOptions { reftypes, number_headings, hl: match hl {
|
|
822
870
|
None => None, Some("spans") => Some(HlMode::Spans), Some(_) => Some(HlMode::Api)
|
|
823
871
|
}, toc, refs: parse_refs(refs)?, id_prefix: id_prefix.to_string(), fn_salt: fn_salt.to_string(), hl_lang: hl_lang_c.as_ref().map(|c| c as _),
|
|
824
|
-
code_wrap: code_wrap_c.as_ref().map(|c| c as _), hl_fn: hl_fn_c.as_ref().map(|c| c as _), auto_ids, gh_ids };
|
|
872
|
+
code_wrap: code_wrap_c.as_ref().map(|c| c as _), hl_fn: hl_fn_c.as_ref().map(|c| c as _), auto_ids, gh_ids, cite_style: parse_cite_style(cite_style)? };
|
|
825
873
|
let result = if hl_lang.is_none() && code_wrap.is_none() && hl_fn.is_none() {
|
|
826
874
|
py.detach(|| mdhtml::export_html::export_document(&document.doc, &opts))
|
|
827
875
|
} else { mdhtml::export_html::export_document(&document.doc, &opts) };
|
|
@@ -24,10 +24,10 @@ def math_js(fn=None, **opts):
|
|
|
24
24
|
return _math_js(fn, "".join(f", {k}: {json.dumps(v)}" for k, v in opts.items()))
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def bake_mdhtml(src, reftypes=None, number_headings=None, refs='resolve', links=True):
|
|
27
|
+
def bake_mdhtml(src, reftypes=None, number_headings=None, refs='resolve', links=True, cite_style=None):
|
|
28
28
|
r"Bake symbolic MDHTML once; links=False emits reference text without anchors. Built-in exporters bake their own input."
|
|
29
29
|
from . import Mdhtml
|
|
30
|
-
document = import_mdhtml(src).bake(reftypes=reftypes, number_headings=number_headings, refs=refs, links=links)
|
|
30
|
+
document = import_mdhtml(src).bake(reftypes=reftypes, number_headings=number_headings, refs=refs, links=links, cite_style=cite_style)
|
|
31
31
|
return Mdhtml(document.mdhtml(), document.warnings, document.frontmatter)
|
|
32
32
|
|
|
33
33
|
|
|
@@ -68,7 +68,8 @@ def _hl_fn(hl):
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def mdhtml2html(src, dest=None, reftypes: dict | None = None, number_headings=None, hl: str | None = "spans", auto_ids: bool = True,
|
|
71
|
-
toc: bool = False, refs: str = "resolve", id_prefix: str = "", fn_salt: str = "", hl_lang=None, code_wrap=None, gh_ids: bool = False
|
|
71
|
+
toc: bool = False, refs: str = "resolve", id_prefix: str = "", fn_salt: str = "", hl_lang=None, code_wrap=None, gh_ids: bool = False,
|
|
72
|
+
cite_style: str | None = None) -> Html:
|
|
72
73
|
"""Lower MDHTML (a string or DocumentFragment; never mutated) to finished HTML: cross-references
|
|
73
74
|
baked as links, headings and captions numbered, `{=html}` raw data spliced, `colwidths` lowered,
|
|
74
75
|
and code highlighted. A `div[data-panel]` with open/closed disclosure lowers to `<details>`,
|
|
@@ -95,12 +96,14 @@ def mdhtml2html(src, dest=None, reftypes: dict | None = None, number_headings=No
|
|
|
95
96
|
may return replacement markup for the highlighted block (None keeps it; `text` is unescaped).
|
|
96
97
|
Highlighting comes from the optional fastpylight package (`pip install 'mdhtml[hl]'`);
|
|
97
98
|
without it, code blocks render plain and a warning reports it.
|
|
99
|
+
`cite_style` selects author-year or numeric citations; None inherits metadata, defaulting to author-year.
|
|
98
100
|
`number_headings=None` inherits the input's metadata setting, else numbers automatically when
|
|
99
101
|
a reference needs it. `False` disables heading numbering, including automatic numbering.
|
|
100
102
|
Returns an `Html` str carrying `.warnings`; `dest` also writes it to a file."""
|
|
101
103
|
document = import_mdhtml(src)
|
|
102
104
|
hl_fn = None if hl is None else _hl_fn(hl)
|
|
103
|
-
out, warnings = _export_html(document, reftypes, number_headings, hl, toc, refs, id_prefix, fn_salt, hl_lang, code_wrap, hl_fn,
|
|
105
|
+
out, warnings = _export_html(document, reftypes, number_headings, hl, toc, refs, id_prefix, fn_salt, hl_lang, code_wrap, hl_fn,
|
|
106
|
+
auto_ids, gh_ids, cite_style)
|
|
104
107
|
res = Html(out, warnings)
|
|
105
108
|
if dest is not None: Path(dest).write_text(res, encoding="utf-8")
|
|
106
109
|
return res
|
|
@@ -60,14 +60,15 @@ class _GfmFiles:
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def mdhtml2gfm(src, dest=None, reftypes: dict | None = None, number_headings=None, tmpl=None,
|
|
63
|
-
raw: tuple = ("md", "gfm"), imgdir=None, link=None) -> Md:
|
|
63
|
+
raw: tuple = ("md", "gfm"), imgdir=None, link=None, cite_style=None) -> Md:
|
|
64
64
|
r"""Export a Document or symbolic MDHTML as GitHub Markdown, with shared Rust numbering and reference text.
|
|
65
65
|
|
|
66
66
|
`raw` selects passthrough formats; other raw payloads are omitted. `tmpl(node)` renders semantic operations.
|
|
67
67
|
`imgdir` extracts data-URI images. `link(url)` rewrites other URLs. Complete YAML frontmatter is retained.
|
|
68
|
+
`cite_style` selects author-year or numeric citations; None inherits metadata, defaulting to author-year.
|
|
68
69
|
"""
|
|
69
70
|
document = import_mdhtml(src)
|
|
70
|
-
prepared = document.bake(reftypes=reftypes, number_headings=number_headings, links=False)
|
|
71
|
+
prepared = document.bake(reftypes=reftypes, number_headings=number_headings, links=False, cite_style=cite_style)
|
|
71
72
|
if imgdir is not None or link is not None:
|
|
72
73
|
files = _GfmFiles(None if imgdir is None else Path(imgdir), Path(dest).parent if dest is not None else Path("."), link)
|
|
73
74
|
prepared = prepared.map_urls(files.rewrite)
|
|
@@ -77,8 +78,9 @@ def mdhtml2gfm(src, dest=None, reftypes: dict | None = None, number_headings=Non
|
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
def md2gfm(src, dest=None, reftypes: dict | None = None, number_headings=None, math: str = "brackets",
|
|
80
|
-
implicit_figures: bool = False, templates=None, tmpl=None, raw: tuple = ("md", "gfm"), imgdir=None, link=None) -> Md:
|
|
81
|
+
implicit_figures: bool = False, templates=None, tmpl=None, raw: tuple = ("md", "gfm"), imgdir=None, link=None, cite_style=None) -> Md:
|
|
81
82
|
"Convert md to GitHub Markdown through the shared MDHTML representation."
|
|
82
83
|
from . import parse_md
|
|
83
84
|
document = parse_md(src, math=math, implicit_figures=implicit_figures, templates=templates)
|
|
84
|
-
return mdhtml2gfm(document, dest=dest, reftypes=reftypes, number_headings=number_headings, tmpl=tmpl, raw=raw, imgdir=imgdir, link=link
|
|
85
|
+
return mdhtml2gfm(document, dest=dest, reftypes=reftypes, number_headings=number_headings, tmpl=tmpl, raw=raw, imgdir=imgdir, link=link,
|
|
86
|
+
cite_style=cite_style)
|
|
@@ -86,6 +86,7 @@ def main(
|
|
|
86
86
|
fragment: bool = False, # Emit the body fragment alone, with no page shell
|
|
87
87
|
refs: RefsMode = RefsMode.ids, # Bake references as target ids, with numbering ('resolve'), or numbering that degrades to ids ('lenient')
|
|
88
88
|
number_headings: NumMode = None, # Heading numbering scheme (default: the frontmatter's `number_headings:`, else automatic)
|
|
89
|
+
cite_style: str = None, # Citation style: author-year or numeric; None uses metadata
|
|
89
90
|
toc: bool = False, # Prepend a table of contents
|
|
90
91
|
hl: HlMode = HlMode.spans, # Code highlighting: classed spans, the Highlight API, or off
|
|
91
92
|
theme: str = "vscode_light", # Code colors in light mode: any name from `fastpylight.themes()`
|
|
@@ -100,7 +101,7 @@ def main(
|
|
|
100
101
|
"Read Markdown and write a finished HTML page"
|
|
101
102
|
tmpl = dict(templates=MUSTACHE, callbacks={'operation': mustache_pill}) if templates else {}
|
|
102
103
|
src = md2mdhtml(read_src(file), implicit_figures=implicit_figures, frontmatter=frontmatter, **tmpl, **kwargs)
|
|
103
|
-
html = mdhtml2html(src, auto_ids=auto_ids, gh_ids=gh_ids, refs=refs, number_headings=number_headings, toc=toc,
|
|
104
|
+
html = mdhtml2html(src, auto_ids=auto_ids, gh_ids=gh_ids, refs=refs, number_headings=number_headings, toc=toc, cite_style=cite_style,
|
|
104
105
|
hl=None if hl == HlMode.off else hl, code_wrap=_code_wrap)
|
|
105
106
|
for w in [*src.warnings, *html.warnings]: print(w, file=sys.stderr)
|
|
106
107
|
if src.meta: html = meta_table(src.meta) + html
|