mdhtml2docx 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mdhtml2docx/__init__.py +3 -0
- mdhtml2docx/asvocab.py +88 -0
- mdhtml2docx/convert.py +919 -0
- mdhtml2docx/hilite.py +27 -0
- mdhtml2docx/schemas/SOURCES.md +7 -0
- mdhtml2docx/schemas/dml-chart.xsd +1499 -0
- mdhtml2docx/schemas/dml-chartDrawing.xsd +146 -0
- mdhtml2docx/schemas/dml-diagram.xsd +1085 -0
- mdhtml2docx/schemas/dml-lockedCanvas.xsd +11 -0
- mdhtml2docx/schemas/dml-main.xsd +3081 -0
- mdhtml2docx/schemas/dml-picture.xsd +23 -0
- mdhtml2docx/schemas/dml-wordprocessingDrawing.xsd +287 -0
- mdhtml2docx/schemas/shared-commonSimpleTypes.xsd +172 -0
- mdhtml2docx/schemas/shared-customXmlSchemaProperties.xsd +18 -0
- mdhtml2docx/schemas/shared-math.xsd +582 -0
- mdhtml2docx/schemas/shared-relationshipReference.xsd +25 -0
- mdhtml2docx/schemas/wml.xsd +3643 -0
- mdhtml2docx/schemas/xml.xsd +287 -0
- mdhtml2docx/styles.py +85 -0
- mdhtml2docx/templates/reference.docx +0 -0
- mdhtml2docx/validate.py +38 -0
- mdhtml2docx/wml.py +110 -0
- mdhtml2docx/word.py +136 -0
- mdhtml2docx/word.sdef +9661 -0
- mdhtml2docx-0.1.0.dist-info/METADATA +96 -0
- mdhtml2docx-0.1.0.dist-info/RECORD +29 -0
- mdhtml2docx-0.1.0.dist-info/WHEEL +5 -0
- mdhtml2docx-0.1.0.dist-info/licenses/LICENSE +202 -0
- mdhtml2docx-0.1.0.dist-info/top_level.txt +1 -0
mdhtml2docx/hilite.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Optional syntax scopes for code blocks, via fastpylight (Jeremy's tree-sitter highlighter).
|
|
2
|
+
When fastpylight is absent or the language unknown, callers fall back to plain runs, so the
|
|
3
|
+
package keeps its lxml-only hard dependency. Colors live in the reference doc's Hl* character
|
|
4
|
+
styles (see styles.theme_styles); this module only tokenizes."""
|
|
5
|
+
|
|
6
|
+
# theme_colors is probed too: a pre-theme_colors fastpylight is treated as absent, not half-working
|
|
7
|
+
try: from fastpylight import tokenize, theme_colors # chkstyle: ignore
|
|
8
|
+
except ImportError: tokenize = None
|
|
9
|
+
|
|
10
|
+
__all__ = ['segments']
|
|
11
|
+
|
|
12
|
+
def segments(code, lang):
|
|
13
|
+
"""Split `code` into [(text, scope)] using fastpylight's byte-offset tokens, or None when
|
|
14
|
+
fastpylight or `lang` is unavailable (caller then emits plain runs)"""
|
|
15
|
+
if tokenize is None or not lang: return None
|
|
16
|
+
try: toks = tokenize(code, lang)
|
|
17
|
+
except ValueError: return None
|
|
18
|
+
b = code.encode()
|
|
19
|
+
out, pos = [], 0
|
|
20
|
+
def emit(s, e, scope=None):
|
|
21
|
+
if e > s: out.append((b[s:e].decode(), scope))
|
|
22
|
+
for s, e, scope in toks:
|
|
23
|
+
emit(pos, s)
|
|
24
|
+
emit(s, e, scope)
|
|
25
|
+
pos = e
|
|
26
|
+
emit(pos, len(b))
|
|
27
|
+
return out
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Schema provenance
|
|
2
|
+
|
|
3
|
+
The `*.xsd` files except `xml.xsd` are the wordprocessing import closure (12 of 26 files) of the ECMA-376 Part 4 5th edition transitional schema set, from `OfficeOpenXML-XMLSchema-Transitional.zip` inside https://ecma-international.org/wp-content/uploads/ECMA-376-4_5th_edition_december_2016.zip (sml/pml and their closures omitted: spreadsheets and presentations are out of scope).
|
|
4
|
+
|
|
5
|
+
`xml.xsd` is the W3C schema for the XML namespace, from https://www.w3.org/2001/xml.xsd.
|
|
6
|
+
|
|
7
|
+
Local modification, needed because lxml cannot resolve a namespace-only import: in `wml.xsd` and `shared-math.xsd`, the `<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>` element gained `schemaLocation="xml.xsd"`. No other edits.
|