markwright 0.1.0__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.
- markwright-0.1.0/LICENSE +21 -0
- markwright-0.1.0/LICENSE-Apache-2.0 +191 -0
- markwright-0.1.0/NOTICE +27 -0
- markwright-0.1.0/PKG-INFO +194 -0
- markwright-0.1.0/README.md +168 -0
- markwright-0.1.0/pyproject.toml +81 -0
- markwright-0.1.0/pyproject.toml.orig +65 -0
- markwright-0.1.0/src/markwright/__init__.py +0 -0
- markwright-0.1.0/src/markwright/_util.py +31 -0
- markwright-0.1.0/src/markwright/cli.py +147 -0
- markwright-0.1.0/src/markwright/codepen.py +206 -0
- markwright-0.1.0/src/markwright/fence.py +483 -0
- markwright-0.1.0/src/markwright/highlight.py +189 -0
- markwright-0.1.0/src/markwright/image_compare.py +128 -0
- markwright-0.1.0/src/markwright/instagram.py +193 -0
- markwright-0.1.0/src/markwright/py.typed +0 -0
- markwright-0.1.0/src/markwright/registry.py +133 -0
- markwright-0.1.0/src/markwright/slideshow.py +150 -0
- markwright-0.1.0/src/markwright/twitter.py +187 -0
- markwright-0.1.0/src/markwright/youtube.py +106 -0
markwright-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mason Egger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2022 DigitalOcean
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
markwright-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
markwright
|
|
2
|
+
Copyright 2026 Mason Egger
|
|
3
|
+
|
|
4
|
+
markwright as a whole is distributed under the MIT License (see LICENSE).
|
|
5
|
+
|
|
6
|
+
This project is a Python port of do-markdownit, originally developed by
|
|
7
|
+
DigitalOcean and licensed under the Apache License, Version 2.0.
|
|
8
|
+
|
|
9
|
+
Original project: https://github.com/digitalocean/do-markdownit
|
|
10
|
+
Copyright 2023 DigitalOcean
|
|
11
|
+
|
|
12
|
+
Portions of this project are derived from do-markdownit and remain subject
|
|
13
|
+
to the Apache License, Version 2.0, a copy of which is included in this
|
|
14
|
+
repository as LICENSE-Apache-2.0. The extensions reproduce do-markdownit's
|
|
15
|
+
markup syntax and HTML output, and specific portions were ported from the
|
|
16
|
+
original source: the compare control SVG, the slideshow navigation script,
|
|
17
|
+
and the Twitter and Instagram embed URL grammars.
|
|
18
|
+
|
|
19
|
+
Significant changes from the original (Apache License, Version 2.0,
|
|
20
|
+
Section 4(b)):
|
|
21
|
+
|
|
22
|
+
- Reimplemented in Python as Python-Markdown extensions rather than a
|
|
23
|
+
JavaScript markdown-it plugin.
|
|
24
|
+
- Added an mw command-line tool that exposes the extensions as pre and
|
|
25
|
+
post filter stages for use outside an in-process Python-Markdown render.
|
|
26
|
+
- Adapted extension behavior and output where the Python-Markdown
|
|
27
|
+
toolchain differs from markdown-it.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: markwright
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python-Markdown extensions ported from DigitalOcean's do-markdownit
|
|
5
|
+
Keywords: markdown,python-markdown,do-markdownit,mkdocs,hugo
|
|
6
|
+
Author: Mason Egger
|
|
7
|
+
Author-email: Mason Egger <mason@masonegger.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE-Apache-2.0
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
19
|
+
Requires-Dist: markdown>=3.4
|
|
20
|
+
Requires-Dist: pymdown-extensions>=10.5
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Project-URL: Homepage, https://github.com/MasonEgger/markwright
|
|
23
|
+
Project-URL: Repository, https://github.com/MasonEgger/markwright
|
|
24
|
+
Project-URL: Documentation, https://masonegger.github.io/markwright/
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# markwright
|
|
28
|
+
|
|
29
|
+
A Python port of DigitalOcean's [`do-markdownit`](https://github.com/digitalocean/do-markdownit) JavaScript library.
|
|
30
|
+
|
|
31
|
+
These are [Python-Markdown](https://python-markdown.github.io/) extensions that bring DigitalOcean's markdown syntax (highlighted text, labeled code fences, and a set of media embeds) to any tool built on Python-Markdown, including [MkDocs](https://www.mkdocs.org/), Flask, or a plain script.
|
|
32
|
+
The port maintains compatibility with the original `do-markdownit` HTML output, so rendered pages match what DigitalOcean produces.
|
|
33
|
+
A bundled command-line tool, `mw`, runs the same extensions as pre and post filters around any renderer, so the syntax also works in toolchains that are not built on Python-Markdown, like Hugo.
|
|
34
|
+
|
|
35
|
+
Full documentation and a live demo: https://masonegger.github.io/markwright/
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
Each extension is standalone and can be loaded on its own or alongside the others.
|
|
40
|
+
|
|
41
|
+
- **Highlight** wraps `<^>text<^>` in `<mark>`, and works inside inline code and fenced code blocks where `==text==` cannot reach.
|
|
42
|
+
- **Fence** adds labels, secondary labels, environment classes, and command-line prefixes (line numbers, `$`/`#` prompts, custom prefixes) to code blocks.
|
|
43
|
+
- **YouTube** turns `[youtube ID]` into a responsive iframe embed.
|
|
44
|
+
- **CodePen** embeds a pen with theme, default-tab, and layout options.
|
|
45
|
+
- **Twitter** embeds a tweet with theme and alignment options.
|
|
46
|
+
- **Instagram** embeds a post with caption and alignment options.
|
|
47
|
+
- **Slideshow** builds an image slideshow with navigation arrows.
|
|
48
|
+
- **Image Compare** renders two images with a draggable before/after slider.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv add markwright
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
or
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install markwright
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To work against a local checkout, install it editable:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv add --editable ../markwright
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
### With MkDocs
|
|
71
|
+
|
|
72
|
+
Add the extensions to `mkdocs.yml`.
|
|
73
|
+
Load `markwright.fence` after `pymdownx.superfences` and `pymdownx.highlight` so the code-block HTML is in the shape the fence postprocessor expects.
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
markdown_extensions:
|
|
77
|
+
- pymdownx.superfences
|
|
78
|
+
- pymdownx.highlight:
|
|
79
|
+
pygments_lang_class: true
|
|
80
|
+
- markwright.highlight
|
|
81
|
+
- markwright.fence:
|
|
82
|
+
allowed_environments:
|
|
83
|
+
- local
|
|
84
|
+
- second
|
|
85
|
+
- third
|
|
86
|
+
- markwright.youtube
|
|
87
|
+
- markwright.codepen
|
|
88
|
+
- markwright.twitter
|
|
89
|
+
- markwright.instagram
|
|
90
|
+
- markwright.slideshow
|
|
91
|
+
- markwright.image_compare
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Standalone
|
|
95
|
+
|
|
96
|
+
The extensions work with Python-Markdown directly, so you can use them in any Python program.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import markdown
|
|
100
|
+
|
|
101
|
+
md = markdown.Markdown(extensions=[
|
|
102
|
+
"pymdownx.superfences",
|
|
103
|
+
"pymdownx.highlight",
|
|
104
|
+
"markwright.highlight",
|
|
105
|
+
"markwright.fence",
|
|
106
|
+
"markwright.youtube",
|
|
107
|
+
"markwright.codepen",
|
|
108
|
+
"markwright.twitter",
|
|
109
|
+
"markwright.instagram",
|
|
110
|
+
"markwright.slideshow",
|
|
111
|
+
"markwright.image_compare",
|
|
112
|
+
])
|
|
113
|
+
|
|
114
|
+
html = md.convert("This has a <^>highlighted word<^> in it.")
|
|
115
|
+
print(html)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Load only what you need:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import markdown
|
|
122
|
+
|
|
123
|
+
# Just YouTube embeds
|
|
124
|
+
md = markdown.Markdown(extensions=["markwright.youtube"])
|
|
125
|
+
html = md.convert("[youtube dQw4w9WgXcQ]")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The fence extension expects `pymdownx.superfences` and `pymdownx.highlight` to be loaded too.
|
|
129
|
+
Without them the preprocessor still extracts directives, but the code-block HTML may not match what the postprocessor rewrites.
|
|
130
|
+
|
|
131
|
+
## Command-Line Interface (`mw`)
|
|
132
|
+
|
|
133
|
+
For a toolchain that is not built on Python-Markdown, the `mw` command runs the same extensions as a pair of Unix filters around any renderer: a pre stage on the Markdown source, and a post stage on the rendered HTML.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
mw pre < in.md | your-renderer | mw post > out.html
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- `mw pre` expands the embeds and extracts fence directives into an `mw-fence` comment.
|
|
140
|
+
- `mw post` applies the fence styling, resolves the highlights, and injects each embed script once.
|
|
141
|
+
- `mw render` runs the full pipeline in one shot for callers without their own renderer.
|
|
142
|
+
- `mw list` prints every extension and the stages it provides.
|
|
143
|
+
|
|
144
|
+
Your renderer must pass raw HTML and HTML comments through.
|
|
145
|
+
Hugo is a worked, tested example: see the [Hugo guide](https://masonegger.github.io/markwright/integrations/hugo/).
|
|
146
|
+
The full command and flag reference is in the [CLI docs](https://masonegger.github.io/markwright/cli/).
|
|
147
|
+
|
|
148
|
+
## Syntax at a Glance
|
|
149
|
+
|
|
150
|
+
````text
|
|
151
|
+
Highlight: <^>important<^>
|
|
152
|
+
|
|
153
|
+
Fenced code with a label and command prompts:
|
|
154
|
+
```command
|
|
155
|
+
[label deploy.sh]
|
|
156
|
+
ssh root@server
|
|
157
|
+
apt update
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
YouTube: [youtube dQw4w9WgXcQ]
|
|
161
|
+
[youtube dQw4w9WgXcQ 360 640]
|
|
162
|
+
CodePen: [codepen MattCowley vwPzeX]
|
|
163
|
+
[codepen MattCowley vwPzeX dark css]
|
|
164
|
+
Twitter: [twitter https://twitter.com/github/status/1234567890]
|
|
165
|
+
Instagram: [instagram https://www.instagram.com/p/CkQuv3_LRgS]
|
|
166
|
+
Slideshow: [slideshow https://picsum.photos/id/10/480/270 https://picsum.photos/id/20/480/270]
|
|
167
|
+
Image Compare: [compare before.jpg after.jpg]
|
|
168
|
+
````
|
|
169
|
+
|
|
170
|
+
See the [extension docs](https://masonegger.github.io/markwright/) for every flag and the exact HTML each one produces.
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
This project uses [`uv`](https://docs.astral.sh/uv/) and [`just`](https://github.com/casey/just).
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
just install # uv sync
|
|
178
|
+
just test # unit tests, 100% line + branch coverage
|
|
179
|
+
just test-integration # end-to-end Hugo pipeline test (needs hugo)
|
|
180
|
+
just lint # ruff check + ruff format --check
|
|
181
|
+
just typecheck # mypy --strict
|
|
182
|
+
just check # test + lint + typecheck
|
|
183
|
+
just docs-serve # serve the docs site at localhost:8000
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`just check` must pass before a change is complete.
|
|
187
|
+
The tooling bar is strict: `mypy --strict`, a clean `ruff`, and full test coverage.
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
markwright is released under the [MIT License](LICENSE).
|
|
192
|
+
|
|
193
|
+
It is a port of [`do-markdownit`](https://github.com/digitalocean/do-markdownit) by DigitalOcean, which is licensed under the Apache License 2.0.
|
|
194
|
+
See the [NOTICE](NOTICE) file for attribution details.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# markwright
|
|
2
|
+
|
|
3
|
+
A Python port of DigitalOcean's [`do-markdownit`](https://github.com/digitalocean/do-markdownit) JavaScript library.
|
|
4
|
+
|
|
5
|
+
These are [Python-Markdown](https://python-markdown.github.io/) extensions that bring DigitalOcean's markdown syntax (highlighted text, labeled code fences, and a set of media embeds) to any tool built on Python-Markdown, including [MkDocs](https://www.mkdocs.org/), Flask, or a plain script.
|
|
6
|
+
The port maintains compatibility with the original `do-markdownit` HTML output, so rendered pages match what DigitalOcean produces.
|
|
7
|
+
A bundled command-line tool, `mw`, runs the same extensions as pre and post filters around any renderer, so the syntax also works in toolchains that are not built on Python-Markdown, like Hugo.
|
|
8
|
+
|
|
9
|
+
Full documentation and a live demo: https://masonegger.github.io/markwright/
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
Each extension is standalone and can be loaded on its own or alongside the others.
|
|
14
|
+
|
|
15
|
+
- **Highlight** wraps `<^>text<^>` in `<mark>`, and works inside inline code and fenced code blocks where `==text==` cannot reach.
|
|
16
|
+
- **Fence** adds labels, secondary labels, environment classes, and command-line prefixes (line numbers, `$`/`#` prompts, custom prefixes) to code blocks.
|
|
17
|
+
- **YouTube** turns `[youtube ID]` into a responsive iframe embed.
|
|
18
|
+
- **CodePen** embeds a pen with theme, default-tab, and layout options.
|
|
19
|
+
- **Twitter** embeds a tweet with theme and alignment options.
|
|
20
|
+
- **Instagram** embeds a post with caption and alignment options.
|
|
21
|
+
- **Slideshow** builds an image slideshow with navigation arrows.
|
|
22
|
+
- **Image Compare** renders two images with a draggable before/after slider.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv add markwright
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
or
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install markwright
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To work against a local checkout, install it editable:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv add --editable ../markwright
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### With MkDocs
|
|
45
|
+
|
|
46
|
+
Add the extensions to `mkdocs.yml`.
|
|
47
|
+
Load `markwright.fence` after `pymdownx.superfences` and `pymdownx.highlight` so the code-block HTML is in the shape the fence postprocessor expects.
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
markdown_extensions:
|
|
51
|
+
- pymdownx.superfences
|
|
52
|
+
- pymdownx.highlight:
|
|
53
|
+
pygments_lang_class: true
|
|
54
|
+
- markwright.highlight
|
|
55
|
+
- markwright.fence:
|
|
56
|
+
allowed_environments:
|
|
57
|
+
- local
|
|
58
|
+
- second
|
|
59
|
+
- third
|
|
60
|
+
- markwright.youtube
|
|
61
|
+
- markwright.codepen
|
|
62
|
+
- markwright.twitter
|
|
63
|
+
- markwright.instagram
|
|
64
|
+
- markwright.slideshow
|
|
65
|
+
- markwright.image_compare
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Standalone
|
|
69
|
+
|
|
70
|
+
The extensions work with Python-Markdown directly, so you can use them in any Python program.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import markdown
|
|
74
|
+
|
|
75
|
+
md = markdown.Markdown(extensions=[
|
|
76
|
+
"pymdownx.superfences",
|
|
77
|
+
"pymdownx.highlight",
|
|
78
|
+
"markwright.highlight",
|
|
79
|
+
"markwright.fence",
|
|
80
|
+
"markwright.youtube",
|
|
81
|
+
"markwright.codepen",
|
|
82
|
+
"markwright.twitter",
|
|
83
|
+
"markwright.instagram",
|
|
84
|
+
"markwright.slideshow",
|
|
85
|
+
"markwright.image_compare",
|
|
86
|
+
])
|
|
87
|
+
|
|
88
|
+
html = md.convert("This has a <^>highlighted word<^> in it.")
|
|
89
|
+
print(html)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Load only what you need:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import markdown
|
|
96
|
+
|
|
97
|
+
# Just YouTube embeds
|
|
98
|
+
md = markdown.Markdown(extensions=["markwright.youtube"])
|
|
99
|
+
html = md.convert("[youtube dQw4w9WgXcQ]")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The fence extension expects `pymdownx.superfences` and `pymdownx.highlight` to be loaded too.
|
|
103
|
+
Without them the preprocessor still extracts directives, but the code-block HTML may not match what the postprocessor rewrites.
|
|
104
|
+
|
|
105
|
+
## Command-Line Interface (`mw`)
|
|
106
|
+
|
|
107
|
+
For a toolchain that is not built on Python-Markdown, the `mw` command runs the same extensions as a pair of Unix filters around any renderer: a pre stage on the Markdown source, and a post stage on the rendered HTML.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mw pre < in.md | your-renderer | mw post > out.html
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `mw pre` expands the embeds and extracts fence directives into an `mw-fence` comment.
|
|
114
|
+
- `mw post` applies the fence styling, resolves the highlights, and injects each embed script once.
|
|
115
|
+
- `mw render` runs the full pipeline in one shot for callers without their own renderer.
|
|
116
|
+
- `mw list` prints every extension and the stages it provides.
|
|
117
|
+
|
|
118
|
+
Your renderer must pass raw HTML and HTML comments through.
|
|
119
|
+
Hugo is a worked, tested example: see the [Hugo guide](https://masonegger.github.io/markwright/integrations/hugo/).
|
|
120
|
+
The full command and flag reference is in the [CLI docs](https://masonegger.github.io/markwright/cli/).
|
|
121
|
+
|
|
122
|
+
## Syntax at a Glance
|
|
123
|
+
|
|
124
|
+
````text
|
|
125
|
+
Highlight: <^>important<^>
|
|
126
|
+
|
|
127
|
+
Fenced code with a label and command prompts:
|
|
128
|
+
```command
|
|
129
|
+
[label deploy.sh]
|
|
130
|
+
ssh root@server
|
|
131
|
+
apt update
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
YouTube: [youtube dQw4w9WgXcQ]
|
|
135
|
+
[youtube dQw4w9WgXcQ 360 640]
|
|
136
|
+
CodePen: [codepen MattCowley vwPzeX]
|
|
137
|
+
[codepen MattCowley vwPzeX dark css]
|
|
138
|
+
Twitter: [twitter https://twitter.com/github/status/1234567890]
|
|
139
|
+
Instagram: [instagram https://www.instagram.com/p/CkQuv3_LRgS]
|
|
140
|
+
Slideshow: [slideshow https://picsum.photos/id/10/480/270 https://picsum.photos/id/20/480/270]
|
|
141
|
+
Image Compare: [compare before.jpg after.jpg]
|
|
142
|
+
````
|
|
143
|
+
|
|
144
|
+
See the [extension docs](https://masonegger.github.io/markwright/) for every flag and the exact HTML each one produces.
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
This project uses [`uv`](https://docs.astral.sh/uv/) and [`just`](https://github.com/casey/just).
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
just install # uv sync
|
|
152
|
+
just test # unit tests, 100% line + branch coverage
|
|
153
|
+
just test-integration # end-to-end Hugo pipeline test (needs hugo)
|
|
154
|
+
just lint # ruff check + ruff format --check
|
|
155
|
+
just typecheck # mypy --strict
|
|
156
|
+
just check # test + lint + typecheck
|
|
157
|
+
just docs-serve # serve the docs site at localhost:8000
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`just check` must pass before a change is complete.
|
|
161
|
+
The tooling bar is strict: `mypy --strict`, a clean `ruff`, and full test coverage.
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
markwright is released under the [MIT License](LICENSE).
|
|
166
|
+
|
|
167
|
+
It is a port of [`do-markdownit`](https://github.com/digitalocean/do-markdownit) by DigitalOcean, which is licensed under the Apache License 2.0.
|
|
168
|
+
See the [NOTICE](NOTICE) file for attribution details.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "markwright"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python-Markdown extensions ported from DigitalOcean's do-markdownit"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = [
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"LICENSE-Apache-2.0",
|
|
11
|
+
"NOTICE",
|
|
12
|
+
]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"markdown>=3.4",
|
|
15
|
+
"pymdown-extensions>=10.5",
|
|
16
|
+
]
|
|
17
|
+
keywords = [
|
|
18
|
+
"markdown",
|
|
19
|
+
"python-markdown",
|
|
20
|
+
"do-markdownit",
|
|
21
|
+
"mkdocs",
|
|
22
|
+
"hugo",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Programming Language :: Python :: 3.14",
|
|
31
|
+
"Topic :: Text Processing :: Markup :: Markdown",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[[project.authors]]
|
|
35
|
+
name = "Mason Egger"
|
|
36
|
+
email = "mason@masonegger.com"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/MasonEgger/markwright"
|
|
40
|
+
Repository = "https://github.com/MasonEgger/markwright"
|
|
41
|
+
Documentation = "https://masonegger.github.io/markwright/"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
mw = "markwright.cli:main"
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"pytest>=8.0",
|
|
49
|
+
"ruff>=0.5",
|
|
50
|
+
"mypy>=1.10",
|
|
51
|
+
"pytest-cov>=7.0",
|
|
52
|
+
"types-markdown>=3.10.2.20260211",
|
|
53
|
+
"mkdocs>=1.6,<2",
|
|
54
|
+
"mkdocs-material>=9.7.5",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[build-system]
|
|
58
|
+
requires = ["uv_build>=0.9.17,<0.13.0"]
|
|
59
|
+
build-backend = "uv_build"
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
testpaths = ["tests"]
|
|
63
|
+
markers = ["integration: end-to-end tests that require external tools such as Hugo"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff]
|
|
66
|
+
target-version = "py311"
|
|
67
|
+
line-length = 120
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint]
|
|
70
|
+
select = [
|
|
71
|
+
"E",
|
|
72
|
+
"F",
|
|
73
|
+
"I",
|
|
74
|
+
"UP",
|
|
75
|
+
"B",
|
|
76
|
+
"SIM",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.mypy]
|
|
80
|
+
strict = true
|
|
81
|
+
python_version = "3.11"
|