mdhtml2docx 0.1.7__tar.gz → 0.1.8__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.
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/PKG-INFO +2 -2
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/__init__.py +1 -1
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/mdhtml2docx.py +11 -2
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/PKG-INFO +2 -2
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/requires.txt +1 -1
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/pyproject.toml +1 -1
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/tests/test_convert.py +13 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/LICENSE +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/README.md +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/_modidx.py +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/hilite.py +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/styles.py +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/templates/reference.docx +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx/wml.py +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/SOURCES.txt +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/dependency_links.txt +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/entry_points.txt +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/mdhtml2docx.egg-info/top_level.txt +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/setup.cfg +0 -0
- {mdhtml2docx-0.1.7 → mdhtml2docx-0.1.8}/tests/test_check_docx.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdhtml2docx
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Convert MDHTML to Word docx files
|
|
5
5
|
Author-email: Jeremy Howard <j@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
11
11
|
Requires-Python: >=3.11
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: mdhtml>=0.1.
|
|
14
|
+
Requires-Dist: mdhtml>=0.1.59
|
|
15
15
|
Requires-Dist: oxml>=0.1.4
|
|
16
16
|
Provides-Extra: dev
|
|
17
17
|
Requires-Dist: lxml; extra == "dev"
|
|
@@ -46,6 +46,7 @@ class Converter:
|
|
|
46
46
|
self.base = Path(base or '.')
|
|
47
47
|
self.warnings = []
|
|
48
48
|
self.bq = 0 # blockquote nesting depth
|
|
49
|
+
self.unnumbered = self.unlisted = False
|
|
49
50
|
self._bkid = 0 # bookmark id counter
|
|
50
51
|
self.nums = [] # (numId, abstractNumId, start) per list instance
|
|
51
52
|
self.fndefs = {} # footnote label -> semantic blocks
|
|
@@ -432,7 +433,12 @@ class Converter:
|
|
|
432
433
|
FIRST_AFTER = {'heading', 'block_quote', 'code_block', 'list', 'table', 'definition_list', 'thematic_break', 'math_block'}
|
|
433
434
|
|
|
434
435
|
def block(self, node, style='body', sid=None):
|
|
435
|
-
|
|
436
|
+
cls = _classes(node) if 'attrs' in node else ()
|
|
437
|
+
prev = (self.unnumbered, self.unlisted)
|
|
438
|
+
self.unnumbered |= 'unnumbered' in cls
|
|
439
|
+
self.unlisted |= 'unlisted' in cls
|
|
440
|
+
try: out = self._block(node, style, sid)
|
|
441
|
+
finally: self.unnumbered, self.unlisted = prev
|
|
436
442
|
if node['type'] in self.FIRST_AFTER: self.first = True
|
|
437
443
|
return out
|
|
438
444
|
|
|
@@ -440,7 +446,10 @@ class Converter:
|
|
|
440
446
|
kind = node['type']
|
|
441
447
|
if kind in ('paragraph', 'plain'):
|
|
442
448
|
return [self.prose(self.bookmark(node, self.runs(node['children'], {})), style, self.custom_style(node, 'paragraph') or sid)]
|
|
443
|
-
if kind == 'heading':
|
|
449
|
+
if kind == 'heading':
|
|
450
|
+
if self.unlisted: return [self.para(self.bookmark(node, self.runs(node['children'], {'b': True})), style)]
|
|
451
|
+
extra = [e.numPr(e.numId(val=0))] if self.unnumbered else None
|
|
452
|
+
return [self.para(self.bookmark(node, self.runs(node['children'], {})), f'h{node["level"]}', extra=extra)]
|
|
444
453
|
if kind == 'block_quote':
|
|
445
454
|
self.bq += 1
|
|
446
455
|
try: return self.block_nodes(node['children'], 'blockquote')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdhtml2docx
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Convert MDHTML to Word docx files
|
|
5
5
|
Author-email: Jeremy Howard <j@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
11
11
|
Requires-Python: >=3.11
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: mdhtml>=0.1.
|
|
14
|
+
Requires-Dist: mdhtml>=0.1.59
|
|
15
15
|
Requires-Dist: oxml>=0.1.4
|
|
16
16
|
Provides-Extra: dev
|
|
17
17
|
Requires-Dist: lxml; extra == "dev"
|
|
@@ -334,3 +334,16 @@ def test_template_lifecycle(tmp_path):
|
|
|
334
334
|
assert b'<ns0:name/>' in za.read('customXml/item1.xml') and b'<ns0:sal/>' not in za.read('customXml/item1.xml')
|
|
335
335
|
for name in names:
|
|
336
336
|
if name != 'customXml/item1.xml': assert za.read(name) == z.read(name)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def test_unnumbered_unlisted_headings(tmp_path):
|
|
340
|
+
src = md2mdhtml(
|
|
341
|
+
'## Preface {#sec-pre .unnumbered}\n\n## Body {#sec-body}\n\n'
|
|
342
|
+
'::: {.output .unlisted .unnumbered}\n### Sub {#sec-sub}\n:::\n\nSee [@sec-pre] and [@sec-body].\n')
|
|
343
|
+
out = tmp_path/'headings.docx'
|
|
344
|
+
doc = convert(src, out, number_headings='decimal')
|
|
345
|
+
root = xmlpart(out)
|
|
346
|
+
assert root.xpath('//w:p[w:pPr/w:pStyle/@w:val="Heading1" and w:pPr/w:numPr/w:numId/@w:val="0"]//w:t/text()', namespaces=NS) == ['Preface']
|
|
347
|
+
assert root.xpath('//w:p[w:pPr/w:pStyle/@w:val="Heading1" and not(w:pPr/w:numPr)]//w:t/text()', namespaces=NS) == ['Body']
|
|
348
|
+
assert root.xpath('//w:p[w:pPr/w:pStyle/@w:val="BodyText" and .//w:bookmarkStart/@w:name="sec_sub"]//w:r[w:rPr/w:b]/w:t/text()', namespaces=NS) == ['Sub']
|
|
349
|
+
assert {r'REF sec_pre \h', r'REF sec_body \w \h'} <= set(fields(doc))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|