mdhtml 0.1.44__tar.gz → 0.1.45__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.44 → mdhtml-0.1.45}/Cargo.lock +20 -20
- {mdhtml-0.1.44 → mdhtml-0.1.45}/Cargo.toml +1 -1
- {mdhtml-0.1.44 → mdhtml-0.1.45}/PKG-INFO +7 -4
- {mdhtml-0.1.44 → mdhtml-0.1.45}/README.md +5 -2
- {mdhtml-0.1.44 → mdhtml-0.1.45}/py/src/lib.rs +51 -54
- {mdhtml-0.1.44 → mdhtml-0.1.45}/pyproject.toml +1 -1
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/viewmd.py +7 -3
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/block.rs +25 -22
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/chunk.rs +3 -2
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/export_html.rs +5 -3
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/frontmatter.rs +2 -1
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/import.rs +4 -3
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/inline.rs +21 -19
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/inline_spans.rs +3 -2
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/markdown.rs +6 -5
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/render.rs +5 -6
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/resolve.rs +16 -11
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/wikitext.rs +5 -4
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/wrap.rs +3 -4
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/write_md.rs +8 -5
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_export.py +3 -3
- {mdhtml-0.1.44 → mdhtml-0.1.45}/.cargo/config.toml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/.github/workflows/ci.yml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/.gitignore +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/.nojekyll +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/CHANGELOG.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/DEV.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/LICENSE +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/_config.yml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/_layouts/default.html +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/docs/DIALECT.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/docs/puppy.jpg +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/docs/sample.html +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/README.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/demo.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/examples.ipynb +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/filldemo.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo-bound.docx +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo-filled.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo-filled.pdf +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo-form.docx +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo-render.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.docx +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.html +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.ipynb +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.pdf +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/legal_demo.typ +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/nbsample.ipynb +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/puppy.jpg +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/render_demo.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/sample-clean.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/sample-render.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/sample.css +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/sample.js +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/examples/sample.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/py/Cargo.toml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/py/build.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/__init__.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/__main__.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/_cli.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/chunk.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/controls.html +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/export.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/fill.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/md.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/md2html.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/mustache.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/page.css +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/readme.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/tools.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/typst.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/view.css +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/view.js +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/python/mdhtml/wrap.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/rustfmt.toml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/ast.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/attrs.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/diagnostic.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/entity.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/highlight.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/html.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/lib.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/line.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/preview.css +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/scan.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/template.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/src/tmpl.css +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/canonical.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/fixtures/dialect.html +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/fixtures/dialect.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/helpers.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/resolve.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/cmark-gfm/README.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/cmark-gfm/extensions.txt +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/cmark-gfm/spec.txt +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/kramdown.txt +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/markdowntests.md +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/mf.txt +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/pandoc-grid-tables.txt +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Abbr.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Abbr.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks Special Cases.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks Special Cases.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Backtick Fenced Code Blocks.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Definition Lists.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Definition Lists.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Emphasis.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Emphasis.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Footnotes.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Footnotes.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Headers with attributes.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Headers with attributes.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Inline HTML with Markdown content.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Inline HTML with Markdown content.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Link & Image Attributes.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Link & Image Attributes.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tables.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tables.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks Special Cases.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks Special Cases.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks.text +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/source/php-markdown-extra.mdtest/Tilde Fenced Code Blocks.xhtml +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_bibliography.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_chunk.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_conformance.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_fill.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_focused.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_pathological.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_python.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_readme.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_typst.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/test_wrap.py +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/wasm.mjs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/wikitext.rs +0 -0
- {mdhtml-0.1.44 → mdhtml-0.1.45}/tests/wrap.rs +0 -0
|
@@ -114,9 +114,9 @@ dependencies = [
|
|
|
114
114
|
|
|
115
115
|
[[package]]
|
|
116
116
|
name = "log"
|
|
117
|
-
version = "0.4.
|
|
117
|
+
version = "0.4.35"
|
|
118
118
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
-
checksum = "
|
|
119
|
+
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
|
120
120
|
|
|
121
121
|
[[package]]
|
|
122
122
|
name = "markup5ever"
|
|
@@ -131,7 +131,7 @@ dependencies = [
|
|
|
131
131
|
|
|
132
132
|
[[package]]
|
|
133
133
|
name = "mdhtml-crate"
|
|
134
|
-
version = "0.1.
|
|
134
|
+
version = "0.1.45"
|
|
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.45"
|
|
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.45"
|
|
154
154
|
dependencies = [
|
|
155
155
|
"mdhtml-crate",
|
|
156
156
|
]
|
|
@@ -383,9 +383,9 @@ dependencies = [
|
|
|
383
383
|
|
|
384
384
|
[[package]]
|
|
385
385
|
name = "serde_spanned"
|
|
386
|
-
version = "1.1.
|
|
386
|
+
version = "1.1.3"
|
|
387
387
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
388
|
-
checksum = "
|
|
388
|
+
checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782"
|
|
389
389
|
dependencies = [
|
|
390
390
|
"serde_core",
|
|
391
391
|
]
|
|
@@ -398,9 +398,9 @@ checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
|
|
|
398
398
|
|
|
399
399
|
[[package]]
|
|
400
400
|
name = "smallvec"
|
|
401
|
-
version = "1.16.
|
|
401
|
+
version = "1.16.5"
|
|
402
402
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
403
|
-
checksum = "
|
|
403
|
+
checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
|
|
404
404
|
|
|
405
405
|
[[package]]
|
|
406
406
|
name = "string_cache"
|
|
@@ -454,9 +454,9 @@ dependencies = [
|
|
|
454
454
|
|
|
455
455
|
[[package]]
|
|
456
456
|
name = "toml"
|
|
457
|
-
version = "1.1
|
|
457
|
+
version = "1.2.1+spec-1.1.0"
|
|
458
458
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
459
|
-
checksum = "
|
|
459
|
+
checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7"
|
|
460
460
|
dependencies = [
|
|
461
461
|
"indexmap",
|
|
462
462
|
"serde_core",
|
|
@@ -469,9 +469,9 @@ dependencies = [
|
|
|
469
469
|
|
|
470
470
|
[[package]]
|
|
471
471
|
name = "toml_datetime"
|
|
472
|
-
version = "1.1.
|
|
472
|
+
version = "1.1.3+spec-1.1.0"
|
|
473
473
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
474
|
-
checksum = "
|
|
474
|
+
checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49"
|
|
475
475
|
dependencies = [
|
|
476
476
|
"serde_core",
|
|
477
477
|
]
|
|
@@ -487,9 +487,9 @@ dependencies = [
|
|
|
487
487
|
|
|
488
488
|
[[package]]
|
|
489
489
|
name = "toml_writer"
|
|
490
|
-
version = "1.
|
|
490
|
+
version = "1.2.0+spec-1.1.0"
|
|
491
491
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
492
|
-
checksum = "
|
|
492
|
+
checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a"
|
|
493
493
|
|
|
494
494
|
[[package]]
|
|
495
495
|
name = "unicode-ident"
|
|
@@ -499,9 +499,9 @@ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
|
499
499
|
|
|
500
500
|
[[package]]
|
|
501
501
|
name = "unicode-properties"
|
|
502
|
-
version = "0.1.
|
|
502
|
+
version = "0.1.5"
|
|
503
503
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
504
|
-
checksum = "
|
|
504
|
+
checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833"
|
|
505
505
|
|
|
506
506
|
[[package]]
|
|
507
507
|
name = "web_atoms"
|
|
@@ -523,13 +523,13 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
|
523
523
|
|
|
524
524
|
[[package]]
|
|
525
525
|
name = "winnow"
|
|
526
|
-
version = "1.0.
|
|
526
|
+
version = "1.0.5"
|
|
527
527
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
528
|
-
checksum = "
|
|
528
|
+
checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef"
|
|
529
529
|
|
|
530
530
|
[[package]]
|
|
531
531
|
name = "xtask"
|
|
532
|
-
version = "0.1.
|
|
532
|
+
version = "0.1.45"
|
|
533
533
|
dependencies = [
|
|
534
534
|
"anyhow",
|
|
535
535
|
"serde_json",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdhtml
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.45
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Requires-Dist: fast5ever>=0.1.5
|
|
7
7
|
Requires-Dist: fastcore>=2.2.7
|
|
8
8
|
Requires-Dist: aidialog>=0.0.22
|
|
9
|
-
Requires-Dist: aihist>=0.1.
|
|
9
|
+
Requires-Dist: aihist>=0.1.3
|
|
10
10
|
Requires-Dist: pyyaml>=6.0.3
|
|
11
11
|
Requires-Dist: fastws-cli>=0.0.20 ; extra == 'dev'
|
|
12
12
|
Requires-Dist: fastship>=0.1.5 ; extra == 'dev'
|
|
@@ -148,6 +148,8 @@ Use `--head` to inline additional `.css` and `.js` files. `examples/sample.css`
|
|
|
148
148
|
|
|
149
149
|
Pass a `.ipynb` file to view a Jupyter notebook. Code cells appear as highlighted Python blocks. A bordered `output` section below each cell shows its stored outputs. Streams, results, and tracebacks appear as text. HTML display objects, such as DataFrames, render as HTML. Images are inlined. Markdown cells support cross-references, footnotes, math, and frontmatter. See `examples/nbsample.ipynb` for a demonstration.
|
|
150
150
|
|
|
151
|
+
Use `--fill` to view a Markdown or notebook template filled from its `formdata`. This executes the template's participating code, as `fillmd` does. Unresolved fields remain visible and produce warnings. Filled notebooks use exported messages when any exist, otherwise non-pinned messages.
|
|
152
|
+
|
|
151
153
|
In Solveit dialogs, each prompt appears in a bordered `prompt` section. Its AI reply is indented below it in a `reply` section. Tool calls encoded as fastllm fenced JSON blocks appear as folded details with code-span labels.
|
|
152
154
|
|
|
153
155
|
```bash
|
|
@@ -155,6 +157,7 @@ viewmd README.md
|
|
|
155
157
|
viewmd draft.md --refs=ids
|
|
156
158
|
viewmd examples/sample.md --head examples/sample.css --head examples/sample.js
|
|
157
159
|
viewmd examples/nbsample.ipynb
|
|
160
|
+
viewmd template.ipynb --fill
|
|
158
161
|
```
|
|
159
162
|
|
|
160
163
|
### Filling templates
|
|
@@ -569,7 +572,7 @@ html = mdhtml2html(md2mdhtml(markdown), number_headings='legal')
|
|
|
569
572
|
|
|
570
573
|
In `resolve` mode, cross-references become links with resolved text. `[@sec-pay]` becomes `<a href="#sec-pay">Section 1.</a>`. Groups use text such as "Sections 1. and 1.(a)". Figure and table references use text such as "Figure 1".
|
|
571
574
|
|
|
572
|
-
`reftypes=dict(
|
|
575
|
+
The built-in reference types are `sec` (Section/Sections), `fig` (Figure/Figures), `tbl` (Table/Tables), `eq` (Equation/Equations), and `exh` (Exhibit/Exhibits). Use `reftypes=dict(app=('Appendix', 'Appendices'))` to add prefix words for another type. Missing targets, unknown tokens, and unknown types that need a prefix raise errors. The Word-only `page` and `rel` variants display the full number.
|
|
573
576
|
|
|
574
577
|
Two other modes support previews and drafts:
|
|
575
578
|
|
|
@@ -687,7 +690,7 @@ cat input.md | md2mdhtml --math=dollars
|
|
|
687
690
|
from mdhtml import mdhtml2pdf, mdhtml2typst
|
|
688
691
|
|
|
689
692
|
typ = mdhtml2typst(md2mdhtml(markdown), number_headings='legal')
|
|
690
|
-
mdhtml2pdf(md2mdhtml(markdown), 'out.pdf'
|
|
693
|
+
mdhtml2pdf(md2mdhtml(markdown), 'out.pdf')
|
|
691
694
|
```
|
|
692
695
|
|
|
693
696
|
Typst resolves references at compile time. `[@sec-pay]` becomes `#ref(<sec-pay>, supplement: [Section])`. Reference numbers update when you edit and recompile the `.typ` file. This differs from exporters that resolve reference text during export.
|
|
@@ -116,6 +116,8 @@ Use `--head` to inline additional `.css` and `.js` files. `examples/sample.css`
|
|
|
116
116
|
|
|
117
117
|
Pass a `.ipynb` file to view a Jupyter notebook. Code cells appear as highlighted Python blocks. A bordered `output` section below each cell shows its stored outputs. Streams, results, and tracebacks appear as text. HTML display objects, such as DataFrames, render as HTML. Images are inlined. Markdown cells support cross-references, footnotes, math, and frontmatter. See `examples/nbsample.ipynb` for a demonstration.
|
|
118
118
|
|
|
119
|
+
Use `--fill` to view a Markdown or notebook template filled from its `formdata`. This executes the template's participating code, as `fillmd` does. Unresolved fields remain visible and produce warnings. Filled notebooks use exported messages when any exist, otherwise non-pinned messages.
|
|
120
|
+
|
|
119
121
|
In Solveit dialogs, each prompt appears in a bordered `prompt` section. Its AI reply is indented below it in a `reply` section. Tool calls encoded as fastllm fenced JSON blocks appear as folded details with code-span labels.
|
|
120
122
|
|
|
121
123
|
```bash
|
|
@@ -123,6 +125,7 @@ viewmd README.md
|
|
|
123
125
|
viewmd draft.md --refs=ids
|
|
124
126
|
viewmd examples/sample.md --head examples/sample.css --head examples/sample.js
|
|
125
127
|
viewmd examples/nbsample.ipynb
|
|
128
|
+
viewmd template.ipynb --fill
|
|
126
129
|
```
|
|
127
130
|
|
|
128
131
|
### Filling templates
|
|
@@ -537,7 +540,7 @@ html = mdhtml2html(md2mdhtml(markdown), number_headings='legal')
|
|
|
537
540
|
|
|
538
541
|
In `resolve` mode, cross-references become links with resolved text. `[@sec-pay]` becomes `<a href="#sec-pay">Section 1.</a>`. Groups use text such as "Sections 1. and 1.(a)". Figure and table references use text such as "Figure 1".
|
|
539
542
|
|
|
540
|
-
`reftypes=dict(
|
|
543
|
+
The built-in reference types are `sec` (Section/Sections), `fig` (Figure/Figures), `tbl` (Table/Tables), `eq` (Equation/Equations), and `exh` (Exhibit/Exhibits). Use `reftypes=dict(app=('Appendix', 'Appendices'))` to add prefix words for another type. Missing targets, unknown tokens, and unknown types that need a prefix raise errors. The Word-only `page` and `rel` variants display the full number.
|
|
541
544
|
|
|
542
545
|
Two other modes support previews and drafts:
|
|
543
546
|
|
|
@@ -655,7 +658,7 @@ cat input.md | md2mdhtml --math=dollars
|
|
|
655
658
|
from mdhtml import mdhtml2pdf, mdhtml2typst
|
|
656
659
|
|
|
657
660
|
typ = mdhtml2typst(md2mdhtml(markdown), number_headings='legal')
|
|
658
|
-
mdhtml2pdf(md2mdhtml(markdown), 'out.pdf'
|
|
661
|
+
mdhtml2pdf(md2mdhtml(markdown), 'out.pdf')
|
|
659
662
|
```
|
|
660
663
|
|
|
661
664
|
Typst resolves references at compile time. `[@sec-pay]` becomes `#ref(<sec-pay>, supplement: [Section])`. Reference numbers update when you edit and recompile the `.typ` file. This differs from exporters that resolve reference text during export.
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
use mdhtml::render::EncodeNode;
|
|
2
|
+
use mdhtml::{Diagnostic, Disclosure, Operation, Reference, TableEntry, frontmatter, import, write_md};
|
|
3
|
+
use resolve::{BakeOptions, CiteStyle, NumberHeadings, ReferenceIndex, ReferencePart, RefsMode};
|
|
4
|
+
use std::cell::RefCell;
|
|
1
5
|
use std::panic::{AssertUnwindSafe, catch_unwind};
|
|
6
|
+
use std::sync::Mutex;
|
|
2
7
|
|
|
3
8
|
use pyo3::exceptions::{PyKeyError, PyRuntimeError, PyValueError};
|
|
4
9
|
use pyo3::prelude::*;
|
|
@@ -7,10 +12,7 @@ use pyo3::types::PyDict;
|
|
|
7
12
|
use std::collections::HashMap;
|
|
8
13
|
|
|
9
14
|
use mdhtml::ast::{Attr, Block, Document, Inline};
|
|
10
|
-
use mdhtml::resolve;
|
|
11
|
-
use mdhtml::{BlockSpan, InlineData, InlineNode, SourceNode};
|
|
12
|
-
use mdhtml::{MathMode, Options, TemplateDelimiter, TemplateForm};
|
|
13
|
-
use mdhtml::{plain, render as render_document};
|
|
15
|
+
use mdhtml::{BlockSpan, InlineData, InlineNode, MathMode, Options, SourceNode, TemplateDelimiter, TemplateForm, plain, render as render_document, resolve};
|
|
14
16
|
|
|
15
17
|
type TemplateArg = (String, String, String, Option<(String, String)>, String, Option<(String, String, String)>);
|
|
16
18
|
|
|
@@ -25,9 +27,9 @@ impl PyDocument {
|
|
|
25
27
|
#[staticmethod]
|
|
26
28
|
#[pyo3(signature = (mdhtml, frontmatter="", warnings=None))]
|
|
27
29
|
fn from_mdhtml(mdhtml: &str, frontmatter: &str, warnings: Option<Vec<String>>) -> Self {
|
|
28
|
-
let mut doc =
|
|
30
|
+
let mut doc = import::from_mdhtml(mdhtml);
|
|
29
31
|
doc.frontmatter = frontmatter.into();
|
|
30
|
-
doc.diagnostics.splice(0..0, warnings.unwrap_or_default().into_iter().map(|w|
|
|
32
|
+
doc.diagnostics.splice(0..0, warnings.unwrap_or_default().into_iter().map(|w| Diagnostic::warning("source", w)));
|
|
31
33
|
Self { doc }
|
|
32
34
|
}
|
|
33
35
|
#[getter]
|
|
@@ -54,36 +56,36 @@ impl PyDocument {
|
|
|
54
56
|
&self, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, cite_style: Option<&str>
|
|
55
57
|
) -> PyResult<PyReferenceIndex> {
|
|
56
58
|
Ok(PyReferenceIndex {
|
|
57
|
-
inner:
|
|
59
|
+
inner: ReferenceIndex::new(&self.doc, reftypes, parse_number_headings(number_headings)?, parse_cite_style(cite_style)?).map_err(vr)? })
|
|
58
60
|
}
|
|
59
61
|
/// Prepare numbers, citation text and bibliography layout; retain other references for native fields.
|
|
60
62
|
#[pyo3(signature = (reftypes=None, number_headings=None, cite_style=None))]
|
|
61
63
|
fn prepare(
|
|
62
64
|
&self, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, cite_style: Option<&str>
|
|
63
65
|
) -> PyResult<(Self, PyReferenceIndex)> {
|
|
64
|
-
let options =
|
|
65
|
-
..Default::default() };
|
|
66
|
+
let options =
|
|
67
|
+
BakeOptions { reftypes, number_headings: parse_number_headings(number_headings)?, cite_style: parse_cite_style(cite_style)?, ..Default::default() };
|
|
66
68
|
let mut doc = self.doc.clone();
|
|
67
69
|
let (inner, warnings) = resolve::prepare_document(&mut doc, &options).map_err(vr)?;
|
|
68
|
-
doc.diagnostics.extend(warnings.into_iter().map(|w|
|
|
70
|
+
doc.diagnostics.extend(warnings.into_iter().map(|w| Diagnostic::warning("reference", w)));
|
|
69
71
|
Ok((Self { doc }, PyReferenceIndex { inner }))
|
|
70
72
|
}
|
|
71
73
|
#[pyo3(signature = (reftypes=None, number_headings=None, refs="resolve", links=true, cite_style=None))]
|
|
72
74
|
fn bake(
|
|
73
75
|
&self, py: Python<'_>, reftypes: Option<HashMap<String, (String, String)>>, number_headings: Option<&Bound<'_, PyAny>>, refs: &str, links: bool,
|
|
74
76
|
cite_style: Option<&str>) -> PyResult<Self> {
|
|
75
|
-
let options =
|
|
77
|
+
let options = BakeOptions { reftypes, number_headings: parse_number_headings(number_headings)?, refs: parse_refs(refs)?, links,
|
|
76
78
|
cite_style: parse_cite_style(cite_style)? };
|
|
77
79
|
let mut doc = self.doc.clone();
|
|
78
80
|
let warnings = py.detach(|| resolve::bake_document(&mut doc, &options)).map_err(vr)?;
|
|
79
|
-
doc.diagnostics.extend(warnings.into_iter().map(|w|
|
|
81
|
+
doc.diagnostics.extend(warnings.into_iter().map(|w| Diagnostic::warning("reference", w)));
|
|
80
82
|
Ok(Self { doc })
|
|
81
83
|
}
|
|
82
84
|
#[pyo3(signature = (callbacks=None))]
|
|
83
85
|
fn mdhtml(&self, py: Python<'_>, callbacks: Option<&Bound<'_, PyDict>>) -> PyResult<String> {
|
|
84
86
|
let Some(callbacks) = callbacks else { return Ok(canonical_mdhtml(&render_document(&self.doc))); };
|
|
85
|
-
let error =
|
|
86
|
-
let hook = |node:
|
|
87
|
+
let error = RefCell::new(None);
|
|
88
|
+
let hook = |node: EncodeNode<'_>, default: &str| -> Result<Option<String>, String> {
|
|
87
89
|
let result = callback_node(py, node).and_then(|node| {
|
|
88
90
|
let kind: String = node.get_item("type")?.unwrap().extract()?;
|
|
89
91
|
let Some(callback) = callbacks.get_item(kind)? else { return Ok(None); };
|
|
@@ -97,8 +99,8 @@ impl PyDocument {
|
|
|
97
99
|
}
|
|
98
100
|
#[pyo3(signature = (gfm=false, raw=None, tmpl=None))]
|
|
99
101
|
fn markdown(&self, py: Python<'_>, gfm: bool, raw: Option<Vec<String>>, tmpl: Option<Bound<'_, PyAny>>) -> PyResult<String> {
|
|
100
|
-
let error =
|
|
101
|
-
let render = |operation: &
|
|
102
|
+
let error = RefCell::new(None);
|
|
103
|
+
let render = |operation: &Operation, form: &str| -> Result<String, String> {
|
|
102
104
|
let result = operation_node(py, operation, form).and_then(|node| tmpl.as_ref().unwrap().call1((node,))?.extract::<Option<String>>());
|
|
103
105
|
result.map(Option::unwrap_or_default).map_err(|e| {
|
|
104
106
|
*error.borrow_mut() = Some(e);
|
|
@@ -107,15 +109,15 @@ impl PyDocument {
|
|
|
107
109
|
};
|
|
108
110
|
let raw = raw.unwrap_or_else(|| vec!["md".into(), "gfm".into()]);
|
|
109
111
|
let formats: Vec<_> = raw.iter().map(String::as_str).collect();
|
|
110
|
-
let options =
|
|
111
|
-
let result =
|
|
112
|
+
let options = write_md::MarkdownOptions { gfm, raw: &formats, template: tmpl.as_ref().map(|_| &render as _) };
|
|
113
|
+
let result = write_md::export_markdown(&self.doc, &options);
|
|
112
114
|
if let Some(error) = error.into_inner() { return Err(error); }
|
|
113
115
|
result.map_err(vr)
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
#[pyclass(frozen, name = "ReferenceIndex", module = "mdhtml._native")]
|
|
118
|
-
struct PyReferenceIndex { inner:
|
|
120
|
+
struct PyReferenceIndex { inner: ReferenceIndex }
|
|
119
121
|
|
|
120
122
|
#[pymethods]
|
|
121
123
|
impl PyReferenceIndex {
|
|
@@ -123,9 +125,9 @@ impl PyReferenceIndex {
|
|
|
123
125
|
fn number_headings(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
|
|
124
126
|
Ok(match &self.inner.number_headings {
|
|
125
127
|
None => py.None(),
|
|
126
|
-
Some(
|
|
127
|
-
Some(
|
|
128
|
-
Some(
|
|
128
|
+
Some(NumberHeadings::Off) => false.into_pyobject(py)?.to_owned().into_any().unbind(),
|
|
129
|
+
Some(NumberHeadings::Name(name)) => name.into_pyobject(py)?.into_any().unbind(),
|
|
130
|
+
Some(NumberHeadings::Scheme(scheme)) => {
|
|
129
131
|
let d = PyDict::new(py);
|
|
130
132
|
for (text, format) in scheme { d.set_item(text, format)?; }
|
|
131
133
|
d.into_any().unbind()
|
|
@@ -146,10 +148,10 @@ impl PyReferenceIndex {
|
|
|
146
148
|
fn validate(&self, reference: &Bound<'_, PyDict>) -> PyResult<()> { self.inner.validate(&reference_from_py(reference)?).map_err(vr) }
|
|
147
149
|
fn plan(&self, py: Python<'_>, items: Vec<Bound<'_, PyDict>>) -> PyResult<Vec<Py<PyDict>>> {
|
|
148
150
|
let items = items.iter().map(reference_from_py).collect::<PyResult<Vec<_>>>()?;
|
|
149
|
-
let (parts, _) = self.inner.plan(&items,
|
|
151
|
+
let (parts, _) = self.inner.plan(&items, RefsMode::Resolve).map_err(vr)?;
|
|
150
152
|
parts.into_iter().map(|part| match part {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
ReferencePart::Content(inline) => inline_node(py, &inline).map(Bound::unbind),
|
|
154
|
+
ReferencePart::Field { reference, target, prefix, variant, bare } => {
|
|
153
155
|
let d = target_node(py, target)?;
|
|
154
156
|
d.set_item("type", "reference_field")?;
|
|
155
157
|
d.set_item("target", &reference.target)?;
|
|
@@ -161,22 +163,19 @@ impl PyReferenceIndex {
|
|
|
161
163
|
}).collect()
|
|
162
164
|
}
|
|
163
165
|
#[getter]
|
|
164
|
-
fn cite_style(&self) -> &'static str {
|
|
165
|
-
match self.inner.cite_style { resolve::CiteStyle::AuthorYear => "author-year", resolve::CiteStyle::Numeric => "numeric" }
|
|
166
|
-
}
|
|
166
|
+
fn cite_style(&self) -> &'static str { match self.inner.cite_style { CiteStyle::AuthorYear => "author-year", CiteStyle::Numeric => "numeric" } }
|
|
167
167
|
/// A reference group resolved to inline nodes in `resolve` mode: plain text, or links with `links=True`.
|
|
168
168
|
#[pyo3(signature = (items, links=false))]
|
|
169
169
|
fn resolve(&self, py: Python<'_>, items: Vec<Bound<'_, PyDict>>, links: bool) -> PyResult<Vec<Py<PyDict>>> {
|
|
170
170
|
let items = items.iter().map(reference_from_py).collect::<PyResult<Vec<_>>>()?;
|
|
171
|
-
let (inlines, _) = self.inner.resolve(&items,
|
|
171
|
+
let (inlines, _) = self.inner.resolve(&items, RefsMode::Resolve, links).map_err(vr)?;
|
|
172
172
|
inline_nodes(py, &inlines)
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
fn reference_from_py(node: &Bound<'_, PyDict>) -> PyResult<
|
|
176
|
+
fn reference_from_py(node: &Bound<'_, PyDict>) -> PyResult<Reference> {
|
|
177
177
|
let get = |key| node.get_item(key)?.ok_or_else(|| PyKeyError::new_err(key));
|
|
178
|
-
Ok(
|
|
179
|
-
suffix: get("suffix")?.extract()? })
|
|
178
|
+
Ok(Reference { target: get("target")?.extract()?, tokens: get("tokens")?.extract()?, prefix: get("prefix")?.extract()?, suffix: get("suffix")?.extract()? })
|
|
180
179
|
}
|
|
181
180
|
|
|
182
181
|
fn canonical_mdhtml(html: &str) -> String { mdhtml::fast5ever::parse_fragment(html, "body").to_html(mdhtml::fast5ever::DOCUMENT) }
|
|
@@ -184,12 +183,12 @@ fn canonical_mdhtml(html: &str) -> String { mdhtml::fast5ever::parse_fragment(ht
|
|
|
184
183
|
/// The flat `meta` pairs of a leading frontmatter block, by the dialect's rule,
|
|
185
184
|
/// without parsing the document: `[]` when it opens with none.
|
|
186
185
|
#[pyfunction]
|
|
187
|
-
fn frontmatter_meta(src: &str) -> Meta {
|
|
186
|
+
fn frontmatter_meta(src: &str) -> Meta { frontmatter::extract(&src.replace("\r\n", "\n").replace('\r', "\n")).map(|(m, _)| m).unwrap_or_default() }
|
|
188
187
|
|
|
189
188
|
#[pyfunction]
|
|
190
189
|
fn split_frontmatter(src: &str) -> (String, String) {
|
|
191
190
|
let source = src.replace("\r\n", "\n").replace('\r', "\n");
|
|
192
|
-
let (payload, body) =
|
|
191
|
+
let (payload, body) = frontmatter::split(&source);
|
|
193
192
|
(payload.to_string(), body.to_string())
|
|
194
193
|
}
|
|
195
194
|
|
|
@@ -205,7 +204,7 @@ fn parse_md(
|
|
|
205
204
|
Options { math: parse_math_mode(math)?, bare_autolinks, implicit_figures, templates: parse_templates(templates)?, frontmatter, ..Options::default() };
|
|
206
205
|
if let Some(depth) = max_block_depth { options.max_block_depth = depth; }
|
|
207
206
|
if let Some(depth) = max_link_paren_depth { options.max_link_paren_depth = depth; }
|
|
208
|
-
let doc = guard("parsing markdown", || py.detach(||
|
|
207
|
+
let doc = guard("parsing markdown", || py.detach(|| import::parse_md(markdown, &options)))?;
|
|
209
208
|
Ok(PyDocument { doc })
|
|
210
209
|
}
|
|
211
210
|
|
|
@@ -322,7 +321,7 @@ fn block_span_node(py: Python<'_>, span: BlockSpan, start: usize, end: usize) ->
|
|
|
322
321
|
/// `strip_trailing_attr` would consume, as the dialect's own grammar judges it.
|
|
323
322
|
#[pyfunction]
|
|
324
323
|
fn trailing_attr_span(line: &str) -> Option<(usize, usize)> { mdhtml::trailing_attr_span(line) }
|
|
325
|
-
fn xref_refs(py: Python<'_>, refs: Vec<
|
|
324
|
+
fn xref_refs(py: Python<'_>, refs: Vec<Reference>) -> PyResult<Vec<Py<PyDict>>> {
|
|
326
325
|
refs.into_iter().map(|r| {
|
|
327
326
|
let rd = PyDict::new(py);
|
|
328
327
|
rd.set_item("target", r.target)?;
|
|
@@ -501,7 +500,7 @@ fn _native(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
501
500
|
}
|
|
502
501
|
|
|
503
502
|
#[pyfunction]
|
|
504
|
-
fn code_span(text: &str) -> String {
|
|
503
|
+
fn code_span(text: &str) -> String { write_md::code_span(text) }
|
|
505
504
|
|
|
506
505
|
fn parse_math_mode(mode: &str) -> PyResult<MathMode> {
|
|
507
506
|
match mode {
|
|
@@ -588,9 +587,7 @@ fn block_node<'py>(py: Python<'py>, block: &Block) -> PyResult<Bound<'py, PyDict
|
|
|
588
587
|
Block::Panel(panel) => {
|
|
589
588
|
d.set_item("kind", &panel.kind)?;
|
|
590
589
|
d.set_item("label", panel.label())?;
|
|
591
|
-
d.set_item("disclosure", match panel.disclosure {
|
|
592
|
-
mdhtml::Disclosure::Fixed => "fixed", mdhtml::Disclosure::Open => "open", mdhtml::Disclosure::Closed => "closed"
|
|
593
|
-
})?;
|
|
590
|
+
d.set_item("disclosure", match panel.disclosure { Disclosure::Fixed => "fixed", Disclosure::Open => "open", Disclosure::Closed => "closed" })?;
|
|
594
591
|
let title = panel.title.as_ref().map(|title| -> PyResult<Py<PyDict>> {
|
|
595
592
|
let value = PyDict::new(py);
|
|
596
593
|
value.set_item("attrs", semantic_attrs(py, Some(&title.attrs))?)?;
|
|
@@ -692,15 +689,15 @@ fn block_node<'py>(py: Python<'py>, block: &Block) -> PyResult<Bound<'py, PyDict
|
|
|
692
689
|
Ok(d)
|
|
693
690
|
}
|
|
694
691
|
|
|
695
|
-
fn table_nodes(py: Python<'_>, entries: &[
|
|
692
|
+
fn table_nodes(py: Python<'_>, entries: &[TableEntry], columns: usize) -> PyResult<Vec<Py<PyDict>>> {
|
|
696
693
|
entries.iter().map(|entry| {
|
|
697
694
|
let row = match entry {
|
|
698
|
-
|
|
695
|
+
TableEntry::Operation(op) => {
|
|
699
696
|
let value = operation_node(py, op, "row")?;
|
|
700
697
|
value.set_item("columns", columns)?;
|
|
701
698
|
return Ok(value.unbind());
|
|
702
699
|
}
|
|
703
|
-
|
|
700
|
+
TableEntry::Row(row) => row,
|
|
704
701
|
};
|
|
705
702
|
let value = PyDict::new(py);
|
|
706
703
|
value.set_item("type", "row")?;
|
|
@@ -775,7 +772,7 @@ fn inline_node<'py>(py: Python<'py>, item: &Inline) -> PyResult<Bound<'py, PyDic
|
|
|
775
772
|
Ok(d)
|
|
776
773
|
}
|
|
777
774
|
|
|
778
|
-
fn reference_node(py: Python<'_>, item: &
|
|
775
|
+
fn reference_node(py: Python<'_>, item: &Reference) -> PyResult<Py<PyDict>> {
|
|
779
776
|
let d = PyDict::new(py);
|
|
780
777
|
d.set_item("target", &item.target)?;
|
|
781
778
|
d.set_item("tokens", &item.tokens)?;
|
|
@@ -784,7 +781,7 @@ fn reference_node(py: Python<'_>, item: &mdhtml::Reference) -> PyResult<Py<PyDic
|
|
|
784
781
|
Ok(d.unbind())
|
|
785
782
|
}
|
|
786
783
|
|
|
787
|
-
fn operation_node<'py>(py: Python<'py>, op: &
|
|
784
|
+
fn operation_node<'py>(py: Python<'py>, op: &Operation, form: &str) -> PyResult<Bound<'py, PyDict>> {
|
|
788
785
|
let d = PyDict::new(py);
|
|
789
786
|
d.set_item("type", "operation")?;
|
|
790
787
|
d.set_item("form", form)?;
|
|
@@ -803,11 +800,11 @@ fn operation_node<'py>(py: Python<'py>, op: &mdhtml::Operation, form: &str) -> P
|
|
|
803
800
|
Ok(d)
|
|
804
801
|
}
|
|
805
802
|
|
|
806
|
-
fn callback_node<'py>(py: Python<'py>, node:
|
|
803
|
+
fn callback_node<'py>(py: Python<'py>, node: EncodeNode<'_>) -> PyResult<Bound<'py, PyDict>> {
|
|
807
804
|
match node {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
805
|
+
EncodeNode::Block(block) => block_node(py, block),
|
|
806
|
+
EncodeNode::Inline(inline) => inline_node(py, inline),
|
|
807
|
+
EncodeNode::Operation(op, form, columns) => {
|
|
811
808
|
let value = operation_node(py, op, form)?;
|
|
812
809
|
if let Some(columns) = columns { value.set_item("columns", columns)?; }
|
|
813
810
|
Ok(value)
|
|
@@ -819,9 +816,9 @@ fn callback_node<'py>(py: Python<'py>, node: mdhtml::render::EncodeNode<'_>) ->
|
|
|
819
816
|
// HTML exporter (src/export_html.rs) binding
|
|
820
817
|
// ---------------------------------------------------------------------------
|
|
821
818
|
|
|
822
|
-
fn parse_cite_style(value: Option<&str>) -> PyResult<Option<
|
|
819
|
+
fn parse_cite_style(value: Option<&str>) -> PyResult<Option<CiteStyle>> { value.map(|name| CiteStyle::parse(name).map_err(vr)).transpose() }
|
|
823
820
|
|
|
824
|
-
fn parse_number_headings(value: Option<&Bound<'_, PyAny>>) -> PyResult<Option<
|
|
821
|
+
fn parse_number_headings(value: Option<&Bound<'_, PyAny>>) -> PyResult<Option<NumberHeadings>> {
|
|
825
822
|
use resolve::NumberHeadings;
|
|
826
823
|
Ok(match value {
|
|
827
824
|
None => None,
|
|
@@ -834,9 +831,9 @@ fn parse_number_headings(value: Option<&Bound<'_, PyAny>>) -> PyResult<Option<re
|
|
|
834
831
|
})
|
|
835
832
|
}
|
|
836
833
|
|
|
837
|
-
fn parse_refs(refs: &str) -> PyResult<
|
|
834
|
+
fn parse_refs(refs: &str) -> PyResult<RefsMode> {
|
|
838
835
|
match refs {
|
|
839
|
-
"resolve" => Ok(
|
|
836
|
+
"resolve" => Ok(RefsMode::Resolve), "ids" => Ok(RefsMode::Ids), "lenient" => Ok(RefsMode::Lenient),
|
|
840
837
|
_ => Err(PyValueError::new_err(format!("unknown refs mode {refs:?}")))
|
|
841
838
|
}
|
|
842
839
|
}
|
|
@@ -849,7 +846,7 @@ fn export_html(
|
|
|
849
846
|
gh_ids: bool, cite_style: Option<&str>) -> PyResult<(String, Vec<String>)> {
|
|
850
847
|
use mdhtml::export_html::{HlMode, HtmlExportOptions};
|
|
851
848
|
let number_headings = parse_number_headings(number_headings)?;
|
|
852
|
-
let hook_err:
|
|
849
|
+
let hook_err: Mutex<Option<PyErr>> = Mutex::new(None);
|
|
853
850
|
let stash = |e: PyErr| -> String { *hook_err.lock().unwrap() = Some(e); "python hook raised".to_string() };
|
|
854
851
|
let hl_lang_c = hl_lang.as_ref().map(|f| {
|
|
855
852
|
move |text: &str, lang: Option<&str>| -> Result<Option<String>, String> {
|
|
@@ -8,7 +8,7 @@ dynamic = ["version"]
|
|
|
8
8
|
description = "A bounded-time, Pandoc-leaning Markdown parser with GFM, Extra/kramdown, math, fenced divs, and MDHTML output."
|
|
9
9
|
license = "Apache-2.0"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
|
-
dependencies = ["fast5ever>=0.1.5", "fastcore>=2.2.7", "aidialog>=0.0.22", "aihist>=0.1.
|
|
11
|
+
dependencies = ["fast5ever>=0.1.5", "fastcore>=2.2.7", "aidialog>=0.0.22", "aihist>=0.1.3", "pyyaml>=6.0.3"]
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
authors = [{name = "Jeremy Howard", email = "j@fast.ai"}]
|
|
14
14
|
classifiers = [
|
|
@@ -14,6 +14,7 @@ from fastcore.nbio import nb_frontmatter
|
|
|
14
14
|
from . import DASHES, replacements, mdhtml2html, md2mdhtml
|
|
15
15
|
from .export import _fastpylight
|
|
16
16
|
from .mustache import MUSTACHE, mustache_pill
|
|
17
|
+
from .fill import instantiate, instantiate_nb
|
|
17
18
|
from ._cli import parse_args, read_src
|
|
18
19
|
from . import meta_table
|
|
19
20
|
from .md2html import CACHE, HlMode, NumMode, RefsMode, _code_wrap, _inline_imgs, page
|
|
@@ -60,21 +61,24 @@ def main(
|
|
|
60
61
|
auto_ids: bool = True, # Derive ids for headings
|
|
61
62
|
implicit_figures: bool = True, # Promote image-only paragraphs to figures
|
|
62
63
|
frontmatter: bool = True, # Strip leading `key: value` frontmatter into the page title and a metadata table
|
|
64
|
+
fill: bool = False, # Instantiate the template from formdata, executing its participating code
|
|
63
65
|
head: Annotated[str, "File inlined into the page head: .css as <style>, .js as <script>, else raw HTML; repeatable", dict(action="append")] = None,
|
|
64
66
|
**kwargs):
|
|
65
67
|
"Render Markdown (or a Jupyter notebook) to a page with the viewer UI, and open it in a browser"
|
|
66
68
|
if file and file.endswith(".ipynb"):
|
|
67
69
|
nb = read_ipynb(file)
|
|
68
|
-
text = dlg2md(nb)
|
|
70
|
+
text = instantiate_nb(file, strict=False) if fill else dlg2md(nb)
|
|
69
71
|
meta = nb_frontmatter(nb, strvals=True)
|
|
70
72
|
if number_headings is None: number_headings = meta.get("number_headings")
|
|
71
73
|
if cite_style is None: cite_style = meta.get("cite_style")
|
|
72
|
-
else:
|
|
74
|
+
else:
|
|
75
|
+
text = read_src(file)
|
|
76
|
+
if fill: text = instantiate(text, strict=False)
|
|
73
77
|
src = md2mdhtml(text, implicit_figures=implicit_figures, frontmatter=frontmatter,
|
|
74
78
|
templates=MUSTACHE, callbacks={'operation': mustache_pill, 'text': replacements(*DASHES)}, **kwargs)
|
|
75
79
|
html = mdhtml2html(src, auto_ids=auto_ids, refs=refs, number_headings=number_headings, toc=True, cite_style=cite_style,
|
|
76
80
|
hl=None if hl == HlMode.off else hl, code_wrap=_copy_wrap)
|
|
77
|
-
for w in [*src.warnings, *html.warnings]: print(w)
|
|
81
|
+
for w in [*getattr(text, 'warnings', ()), *src.warnings, *html.warnings]: print(w)
|
|
78
82
|
base = Path(file).resolve().parent if file else Path.cwd()
|
|
79
83
|
if src.meta: html = meta_table(src.meta) + html
|
|
80
84
|
title = src.meta.get("title") or (Path(file).stem if file else "mdhtml")
|