comrak 0.0.2__tar.gz → 0.0.4__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.
Potentially problematic release.
This version of comrak might be problematic. Click here for more details.
- comrak-0.0.4/.aiignore +9 -0
- {comrak-0.0.2 → comrak-0.0.4}/.gitignore +2 -0
- {comrak-0.0.2 → comrak-0.0.4}/Cargo.lock +34 -0
- {comrak-0.0.2 → comrak-0.0.4}/Cargo.toml +1 -1
- comrak-0.0.4/DEVELOPMENT.md +7 -0
- comrak-0.0.4/LICENSE +203 -0
- {comrak-0.0.2 → comrak-0.0.4}/PKG-INFO +18 -2
- {comrak-0.0.2 → comrak-0.0.4}/README.md +16 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/README.md +7 -7
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/hello_world_x1000/comrak_bench.py +1 -1
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/hello_world_x1000/markdown2_bench.py +1 -1
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/hello_world_x1000/markdown_bench.py +1 -1
- comrak-0.0.4/pyproject.toml +59 -0
- comrak-0.0.4/src/lib.rs +48 -0
- comrak-0.0.4/src/options.rs +246 -0
- comrak-0.0.2/pyproject.toml +0 -62
- comrak-0.0.2/src/lib.rs +0 -17
- {comrak-0.0.2 → comrak-0.0.4}/.github/workflows/CI.yml +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/.pre-commit-config.yaml +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/awesome_python_readme_x1000/comrak_bench.py +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/awesome_python_readme_x1000/markdown2_bench.py +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/awesome_python_readme_x1000/markdown_bench.py +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/run_medium_benchmark.sh +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/benchmark/run_small_benchmark.sh +0 -0
- {comrak-0.0.2 → comrak-0.0.4}/uv.lock +0 -0
comrak-0.0.4/.aiignore
ADDED
|
@@ -234,6 +234,7 @@ dependencies = [
|
|
|
234
234
|
"bon",
|
|
235
235
|
"caseless",
|
|
236
236
|
"clap",
|
|
237
|
+
"emojis",
|
|
237
238
|
"entities",
|
|
238
239
|
"memchr",
|
|
239
240
|
"shell-words",
|
|
@@ -303,6 +304,15 @@ version = "1.6.0"
|
|
|
303
304
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
304
305
|
checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00"
|
|
305
306
|
|
|
307
|
+
[[package]]
|
|
308
|
+
name = "emojis"
|
|
309
|
+
version = "0.6.4"
|
|
310
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
311
|
+
checksum = "99e1f1df1f181f2539bac8bf027d31ca5ffbf9e559e3f2d09413b9107b5c02f4"
|
|
312
|
+
dependencies = [
|
|
313
|
+
"phf",
|
|
314
|
+
]
|
|
315
|
+
|
|
306
316
|
[[package]]
|
|
307
317
|
name = "entities"
|
|
308
318
|
version = "1.0.1"
|
|
@@ -479,6 +489,24 @@ dependencies = [
|
|
|
479
489
|
"pkg-config",
|
|
480
490
|
]
|
|
481
491
|
|
|
492
|
+
[[package]]
|
|
493
|
+
name = "phf"
|
|
494
|
+
version = "0.11.3"
|
|
495
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
496
|
+
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
|
497
|
+
dependencies = [
|
|
498
|
+
"phf_shared",
|
|
499
|
+
]
|
|
500
|
+
|
|
501
|
+
[[package]]
|
|
502
|
+
name = "phf_shared"
|
|
503
|
+
version = "0.11.3"
|
|
504
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
505
|
+
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
|
506
|
+
dependencies = [
|
|
507
|
+
"siphasher",
|
|
508
|
+
]
|
|
509
|
+
|
|
482
510
|
[[package]]
|
|
483
511
|
name = "pkg-config"
|
|
484
512
|
version = "0.3.31"
|
|
@@ -717,6 +745,12 @@ version = "1.3.0"
|
|
|
717
745
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
718
746
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
719
747
|
|
|
748
|
+
[[package]]
|
|
749
|
+
name = "siphasher"
|
|
750
|
+
version = "1.0.1"
|
|
751
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
752
|
+
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
|
753
|
+
|
|
720
754
|
[[package]]
|
|
721
755
|
name = "slug"
|
|
722
756
|
version = "0.1.6"
|
comrak-0.0.4/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright (c) 2017–2024, Asherah Connor and Comrak contributors
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
20
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
21
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
22
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
-----
|
|
29
|
+
|
|
30
|
+
cmark-gfm
|
|
31
|
+
|
|
32
|
+
derived from https://github.com/github/cmark
|
|
33
|
+
|
|
34
|
+
Copyright (c) 2014, John MacFarlane
|
|
35
|
+
|
|
36
|
+
All rights reserved.
|
|
37
|
+
|
|
38
|
+
Redistribution and use in source and binary forms, with or without
|
|
39
|
+
modification, are permitted provided that the following conditions are met:
|
|
40
|
+
|
|
41
|
+
* Redistributions of source code must retain the above copyright
|
|
42
|
+
notice, this list of conditions and the following disclaimer.
|
|
43
|
+
|
|
44
|
+
* Redistributions in binary form must reproduce the above
|
|
45
|
+
copyright notice, this list of conditions and the following
|
|
46
|
+
disclaimer in the documentation and/or other materials provided
|
|
47
|
+
with the distribution.
|
|
48
|
+
|
|
49
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
50
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
51
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
52
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
53
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
54
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
55
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
56
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
57
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
58
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
59
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
60
|
+
|
|
61
|
+
-----
|
|
62
|
+
|
|
63
|
+
houdini.h, houdini_href_e.c, houdini_html_e.c, houdini_html_u.c
|
|
64
|
+
|
|
65
|
+
derive from https://github.com/vmg/houdini (with some modifications)
|
|
66
|
+
|
|
67
|
+
Copyright (C) 2012 Vicent Martí
|
|
68
|
+
|
|
69
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
70
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
71
|
+
the Software without restriction, including without limitation the rights to
|
|
72
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
73
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
74
|
+
so, subject to the following conditions:
|
|
75
|
+
|
|
76
|
+
The above copyright notice and this permission notice shall be included in all
|
|
77
|
+
copies or substantial portions of the Software.
|
|
78
|
+
|
|
79
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
80
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
81
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
82
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
83
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
84
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
85
|
+
SOFTWARE.
|
|
86
|
+
|
|
87
|
+
-----
|
|
88
|
+
|
|
89
|
+
buffer.h, buffer.c, chunk.h
|
|
90
|
+
|
|
91
|
+
are derived from code (C) 2012 Github, Inc.
|
|
92
|
+
|
|
93
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
94
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
95
|
+
the Software without restriction, including without limitation the rights to
|
|
96
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
97
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
98
|
+
so, subject to the following conditions:
|
|
99
|
+
|
|
100
|
+
The above copyright notice and this permission notice shall be included in all
|
|
101
|
+
copies or substantial portions of the Software.
|
|
102
|
+
|
|
103
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
104
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
105
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
106
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
107
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
108
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
109
|
+
SOFTWARE.
|
|
110
|
+
|
|
111
|
+
-----
|
|
112
|
+
|
|
113
|
+
utf8.c and utf8.c
|
|
114
|
+
|
|
115
|
+
are derived from utf8proc
|
|
116
|
+
(<http://www.public-software-group.org/utf8proc>),
|
|
117
|
+
(C) 2009 Public Software Group e. V., Berlin, Germany.
|
|
118
|
+
|
|
119
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
120
|
+
copy of this software and associated documentation files (the "Software"),
|
|
121
|
+
to deal in the Software without restriction, including without limitation
|
|
122
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
123
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
124
|
+
Software is furnished to do so, subject to the following conditions:
|
|
125
|
+
|
|
126
|
+
The above copyright notice and this permission notice shall be included in
|
|
127
|
+
all copies or substantial portions of the Software.
|
|
128
|
+
|
|
129
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
130
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
131
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
132
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
133
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
134
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
135
|
+
DEALINGS IN THE SOFTWARE.
|
|
136
|
+
|
|
137
|
+
-----
|
|
138
|
+
|
|
139
|
+
The normalization code in normalize.py was derived from the
|
|
140
|
+
markdowntest project, Copyright 2013 Karl Dubost:
|
|
141
|
+
|
|
142
|
+
The MIT License (MIT)
|
|
143
|
+
|
|
144
|
+
Copyright (c) 2013 Karl Dubost
|
|
145
|
+
|
|
146
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
147
|
+
a copy of this software and associated documentation files (the
|
|
148
|
+
"Software"), to deal in the Software without restriction, including
|
|
149
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
150
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
151
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
152
|
+
the following conditions:
|
|
153
|
+
|
|
154
|
+
The above copyright notice and this permission notice shall be
|
|
155
|
+
included in all copies or substantial portions of the Software.
|
|
156
|
+
|
|
157
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
158
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
159
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
160
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
161
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
162
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
163
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
164
|
+
|
|
165
|
+
-----
|
|
166
|
+
|
|
167
|
+
The CommonMark spec (test/spec.txt) is
|
|
168
|
+
|
|
169
|
+
Copyright (C) 2014-15 John MacFarlane
|
|
170
|
+
|
|
171
|
+
Released under the Creative Commons CC-BY-SA 4.0 license:
|
|
172
|
+
<http://creativecommons.org/licenses/by-sa/4.0/>.
|
|
173
|
+
|
|
174
|
+
-----
|
|
175
|
+
|
|
176
|
+
The test software in test/ is
|
|
177
|
+
|
|
178
|
+
Copyright (c) 2014, John MacFarlane
|
|
179
|
+
|
|
180
|
+
All rights reserved.
|
|
181
|
+
|
|
182
|
+
Redistribution and use in source and binary forms, with or without
|
|
183
|
+
modification, are permitted provided that the following conditions are met:
|
|
184
|
+
|
|
185
|
+
* Redistributions of source code must retain the above copyright
|
|
186
|
+
notice, this list of conditions and the following disclaimer.
|
|
187
|
+
|
|
188
|
+
* Redistributions in binary form must reproduce the above
|
|
189
|
+
copyright notice, this list of conditions and the following
|
|
190
|
+
disclaimer in the documentation and/or other materials provided
|
|
191
|
+
with the distribution.
|
|
192
|
+
|
|
193
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
194
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
195
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
196
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
197
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
198
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
199
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
200
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
201
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
202
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
203
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: comrak
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Classifier: Intended Audience :: Developers
|
|
5
5
|
Classifier: License :: OSI Approved :: MIT License
|
|
6
6
|
Classifier: Programming Language :: Rust
|
|
@@ -19,10 +19,10 @@ Requires-Dist: markdown>=3.7 ; extra == 'bench'
|
|
|
19
19
|
Requires-Dist: markdown2>=2.5.3 ; extra == 'bench'
|
|
20
20
|
Provides-Extra: dev
|
|
21
21
|
Provides-Extra: bench
|
|
22
|
+
License-File: LICENSE
|
|
22
23
|
Summary: Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser
|
|
23
24
|
Keywords: markdown,html,rust,commonmark,gfm,parser
|
|
24
25
|
Author-email: Louis Maddox <louismmx@gmail.com>
|
|
25
|
-
License: MIT
|
|
26
26
|
Requires-Python: >=3.9
|
|
27
27
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
28
28
|
Project-URL: Homepage, https://github.com/lmmx/comrak
|
|
@@ -54,6 +54,22 @@ pip install comrak
|
|
|
54
54
|
|
|
55
55
|
Fast Markdown to HTML parser in Rust, shipped for Python via PyO3.
|
|
56
56
|
|
|
57
|
+
### Options
|
|
58
|
+
|
|
59
|
+
All options are exposed in a simple manner:
|
|
60
|
+
|
|
61
|
+
```py
|
|
62
|
+
>>> import comrak
|
|
63
|
+
>>> opts = comrak.ExtensionOptions()
|
|
64
|
+
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
|
|
65
|
+
'<p>foo :smile:</p>\n'
|
|
66
|
+
>>> opts.shortcodes = True
|
|
67
|
+
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
|
|
68
|
+
'<p>foo 😄</p>\n'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Refer to the [Comrak docs](https://docs.rs/comrak/latest/comrak/struct.Options.html) for all available options.
|
|
72
|
+
|
|
57
73
|
## Benchmarks
|
|
58
74
|
|
|
59
75
|
Tested with small (8 lines) and medium (1200 lines) markdown strings
|
|
@@ -24,6 +24,22 @@ pip install comrak
|
|
|
24
24
|
|
|
25
25
|
Fast Markdown to HTML parser in Rust, shipped for Python via PyO3.
|
|
26
26
|
|
|
27
|
+
### Options
|
|
28
|
+
|
|
29
|
+
All options are exposed in a simple manner:
|
|
30
|
+
|
|
31
|
+
```py
|
|
32
|
+
>>> import comrak
|
|
33
|
+
>>> opts = comrak.ExtensionOptions()
|
|
34
|
+
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
|
|
35
|
+
'<p>foo :smile:</p>\n'
|
|
36
|
+
>>> opts.shortcodes = True
|
|
37
|
+
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
|
|
38
|
+
'<p>foo 😄</p>\n'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Refer to the [Comrak docs](https://docs.rs/comrak/latest/comrak/struct.Options.html) for all available options.
|
|
42
|
+
|
|
27
43
|
## Benchmarks
|
|
28
44
|
|
|
29
45
|
Tested with small (8 lines) and medium (1200 lines) markdown strings
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
Source: `hello_world_x1000`
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
bash run_small_benchmark.sh
|
|
6
|
+
bash run_small_benchmark.sh
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
Benchmark 1: baseline
|
|
11
11
|
Time (mean ± σ): 42.2 ms ± 0.9 ms [User: 34.0 ms, System: 7.7 ms]
|
|
12
12
|
Range (min … max): 40.6 ms … 46.0 ms 68 runs
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
Benchmark 2: markdown
|
|
15
15
|
Time (mean ± σ): 854.2 ms ± 4.9 ms [User: 833.7 ms, System: 20.0 ms]
|
|
16
16
|
Range (min … max): 844.5 ms … 861.0 ms 10 runs
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
Benchmark 3: markdown2
|
|
19
19
|
Time (mean ± σ): 608.1 ms ± 6.0 ms [User: 586.7 ms, System: 16.0 ms]
|
|
20
20
|
Range (min … max): 601.5 ms … 619.7 ms 10 runs
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
Summary
|
|
23
23
|
'baseline' ran
|
|
24
24
|
14.42 ± 0.34 times faster than 'markdown2'
|
|
@@ -37,15 +37,15 @@ bash run_medium_benchmark.sh
|
|
|
37
37
|
Benchmark 1: baseline
|
|
38
38
|
Time (mean ± σ): 126.1 ms ± 1.7 ms [User: 110.7 ms, System: 14.9 ms]
|
|
39
39
|
Range (min … max): 123.0 ms … 129.8 ms 23 runs
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
Benchmark 2: markdown
|
|
42
42
|
Time (mean ± σ): 2.070 s ± 0.010 s [User: 2.034 s, System: 0.028 s]
|
|
43
43
|
Range (min … max): 2.054 s … 2.084 s 10 runs
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
Benchmark 3: markdown2
|
|
46
46
|
Time (mean ± σ): 7.205 s ± 0.041 s [User: 7.160 s, System: 0.024 s]
|
|
47
47
|
Range (min … max): 7.149 s … 7.299 s 10 runs
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
Summary
|
|
50
50
|
'baseline' ran
|
|
51
51
|
16.42 ± 0.24 times faster than 'markdown'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"maturin>=1.8,<2.0"
|
|
4
|
+
]
|
|
5
|
+
build-backend = "maturin"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "comrak"
|
|
9
|
+
description = "Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Rust",
|
|
14
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
15
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.9"
|
|
23
|
+
]
|
|
24
|
+
authors = [
|
|
25
|
+
{email = "louismmx@gmail.com", name = "Louis Maddox"}
|
|
26
|
+
]
|
|
27
|
+
keywords = [
|
|
28
|
+
"markdown",
|
|
29
|
+
"html",
|
|
30
|
+
"rust",
|
|
31
|
+
"commonmark",
|
|
32
|
+
"gfm",
|
|
33
|
+
"parser"
|
|
34
|
+
]
|
|
35
|
+
readme = "README.md"
|
|
36
|
+
requires-python = ">=3.9"
|
|
37
|
+
version = "0.0.4"
|
|
38
|
+
|
|
39
|
+
[project.license]
|
|
40
|
+
file = "LICENSE"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"maturin[patchelf]>=1.8.2",
|
|
45
|
+
"pre-commit>=4.1.0"
|
|
46
|
+
]
|
|
47
|
+
bench = [
|
|
48
|
+
"markdown>=3.7",
|
|
49
|
+
"markdown2>=2.5.3"
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Homepage = "https://github.com/lmmx/comrak"
|
|
54
|
+
Repository = "https://github.com/lmmx/comrak.git"
|
|
55
|
+
|
|
56
|
+
[tool.maturin]
|
|
57
|
+
features = [
|
|
58
|
+
"pyo3/extension-module"
|
|
59
|
+
]
|
comrak-0.0.4/src/lib.rs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use pyo3::prelude::*;
|
|
2
|
+
|
|
3
|
+
// We renamed the Rust library to `comrak_lib`
|
|
4
|
+
use comrak_lib::{markdown_to_html, Options as ComrakOptions};
|
|
5
|
+
|
|
6
|
+
// Import the Python option classes we defined
|
|
7
|
+
mod options;
|
|
8
|
+
use options::{PyExtensionOptions, PyParseOptions, PyRenderOptions};
|
|
9
|
+
|
|
10
|
+
/// Render a Markdown string to HTML, with optional Extension/Parse/Render overrides.
|
|
11
|
+
#[pyfunction(signature=(text, extension_options=None, parse_options=None, render_options=None))]
|
|
12
|
+
fn render_markdown(
|
|
13
|
+
text: &str,
|
|
14
|
+
extension_options: Option<PyExtensionOptions>,
|
|
15
|
+
parse_options: Option<PyParseOptions>,
|
|
16
|
+
render_options: Option<PyRenderOptions>,
|
|
17
|
+
) -> PyResult<String> {
|
|
18
|
+
let mut opts = ComrakOptions::default();
|
|
19
|
+
|
|
20
|
+
// If user provided custom extension options, apply them.
|
|
21
|
+
if let Some(py_ext) = extension_options {
|
|
22
|
+
py_ext.update_extension_options(&mut opts.extension);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if let Some(py_parse) = parse_options {
|
|
26
|
+
py_parse.update_parse_options(&mut opts.parse);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if let Some(py_render) = render_options {
|
|
30
|
+
py_render.update_render_options(&mut opts.render);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let html = markdown_to_html(text, &opts);
|
|
34
|
+
Ok(html)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[pymodule]
|
|
38
|
+
fn comrak(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
39
|
+
// Expose the function
|
|
40
|
+
m.add_function(wrap_pyfunction!(render_markdown, m)?)?;
|
|
41
|
+
|
|
42
|
+
// Expose the classes
|
|
43
|
+
m.add_class::<PyExtensionOptions>()?;
|
|
44
|
+
m.add_class::<PyParseOptions>()?;
|
|
45
|
+
m.add_class::<PyRenderOptions>()?;
|
|
46
|
+
|
|
47
|
+
Ok(())
|
|
48
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
use pyo3::prelude::*;
|
|
2
|
+
|
|
3
|
+
// Import the Comrak (Rust) types under `comrak_lib::`
|
|
4
|
+
use comrak_lib::{
|
|
5
|
+
ExtensionOptions as ComrakExtensionOptions, ListStyleType, ParseOptions as ComrakParseOptions,
|
|
6
|
+
RenderOptions as ComrakRenderOptions,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/// Python class that mirrors Comrak’s `ExtensionOptions`
|
|
10
|
+
#[pyclass(name = "ExtensionOptions")]
|
|
11
|
+
#[derive(Clone)]
|
|
12
|
+
pub struct PyExtensionOptions {
|
|
13
|
+
#[pyo3(get, set)]
|
|
14
|
+
pub strikethrough: bool,
|
|
15
|
+
#[pyo3(get, set)]
|
|
16
|
+
pub tagfilter: bool,
|
|
17
|
+
#[pyo3(get, set)]
|
|
18
|
+
pub table: bool,
|
|
19
|
+
#[pyo3(get, set)]
|
|
20
|
+
pub autolink: bool,
|
|
21
|
+
#[pyo3(get, set)]
|
|
22
|
+
pub tasklist: bool,
|
|
23
|
+
#[pyo3(get, set)]
|
|
24
|
+
pub superscript: bool,
|
|
25
|
+
#[pyo3(get, set)]
|
|
26
|
+
pub header_ids: Option<String>,
|
|
27
|
+
#[pyo3(get, set)]
|
|
28
|
+
pub footnotes: bool,
|
|
29
|
+
#[pyo3(get, set)]
|
|
30
|
+
pub description_lists: bool,
|
|
31
|
+
#[pyo3(get, set)]
|
|
32
|
+
pub front_matter_delimiter: Option<String>,
|
|
33
|
+
#[pyo3(get, set)]
|
|
34
|
+
pub multiline_block_quotes: bool,
|
|
35
|
+
#[pyo3(get, set)]
|
|
36
|
+
pub alerts: bool,
|
|
37
|
+
#[pyo3(get, set)]
|
|
38
|
+
pub math_dollars: bool,
|
|
39
|
+
#[pyo3(get, set)]
|
|
40
|
+
pub math_code: bool,
|
|
41
|
+
#[pyo3(get, set)]
|
|
42
|
+
pub shortcodes: bool, // if your comrak_lib has the "shortcodes" feature
|
|
43
|
+
#[pyo3(get, set)]
|
|
44
|
+
pub wikilinks_title_after_pipe: bool,
|
|
45
|
+
#[pyo3(get, set)]
|
|
46
|
+
pub wikilinks_title_before_pipe: bool,
|
|
47
|
+
#[pyo3(get, set)]
|
|
48
|
+
pub underline: bool,
|
|
49
|
+
#[pyo3(get, set)]
|
|
50
|
+
pub subscript: bool,
|
|
51
|
+
#[pyo3(get, set)]
|
|
52
|
+
pub spoiler: bool,
|
|
53
|
+
#[pyo3(get, set)]
|
|
54
|
+
pub greentext: bool,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
impl PyExtensionOptions {
|
|
58
|
+
/// **Rust-only** helper to copy from `PyExtensionOptions` into a real `ComrakExtensionOptions`.
|
|
59
|
+
pub fn update_extension_options(&self, opts: &mut ComrakExtensionOptions<'_>) {
|
|
60
|
+
opts.strikethrough = self.strikethrough;
|
|
61
|
+
opts.tagfilter = self.tagfilter;
|
|
62
|
+
opts.table = self.table;
|
|
63
|
+
opts.autolink = self.autolink;
|
|
64
|
+
opts.tasklist = self.tasklist;
|
|
65
|
+
opts.superscript = self.superscript;
|
|
66
|
+
opts.header_ids = self.header_ids.clone();
|
|
67
|
+
opts.footnotes = self.footnotes;
|
|
68
|
+
opts.description_lists = self.description_lists;
|
|
69
|
+
opts.front_matter_delimiter = self.front_matter_delimiter.clone();
|
|
70
|
+
opts.multiline_block_quotes = self.multiline_block_quotes;
|
|
71
|
+
opts.alerts = self.alerts;
|
|
72
|
+
opts.math_dollars = self.math_dollars;
|
|
73
|
+
opts.math_code = self.math_code;
|
|
74
|
+
opts.shortcodes = self.shortcodes;
|
|
75
|
+
opts.wikilinks_title_after_pipe = self.wikilinks_title_after_pipe;
|
|
76
|
+
opts.wikilinks_title_before_pipe = self.wikilinks_title_before_pipe;
|
|
77
|
+
opts.underline = self.underline;
|
|
78
|
+
opts.subscript = self.subscript;
|
|
79
|
+
opts.spoiler = self.spoiler;
|
|
80
|
+
opts.greentext = self.greentext;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#[pymethods]
|
|
85
|
+
impl PyExtensionOptions {
|
|
86
|
+
#[new]
|
|
87
|
+
pub fn new() -> Self {
|
|
88
|
+
let defaults = ComrakExtensionOptions::default();
|
|
89
|
+
Self {
|
|
90
|
+
strikethrough: defaults.strikethrough,
|
|
91
|
+
tagfilter: defaults.tagfilter,
|
|
92
|
+
table: defaults.table,
|
|
93
|
+
autolink: defaults.autolink,
|
|
94
|
+
tasklist: defaults.tasklist,
|
|
95
|
+
superscript: defaults.superscript,
|
|
96
|
+
header_ids: defaults.header_ids.clone(),
|
|
97
|
+
footnotes: defaults.footnotes,
|
|
98
|
+
description_lists: defaults.description_lists,
|
|
99
|
+
front_matter_delimiter: defaults.front_matter_delimiter.clone(),
|
|
100
|
+
multiline_block_quotes: defaults.multiline_block_quotes,
|
|
101
|
+
alerts: defaults.alerts,
|
|
102
|
+
math_dollars: defaults.math_dollars,
|
|
103
|
+
math_code: defaults.math_code,
|
|
104
|
+
shortcodes: false, // or `defaults.shortcodes` if your version has that
|
|
105
|
+
wikilinks_title_after_pipe: defaults.wikilinks_title_after_pipe,
|
|
106
|
+
wikilinks_title_before_pipe: defaults.wikilinks_title_before_pipe,
|
|
107
|
+
underline: defaults.underline,
|
|
108
|
+
subscript: defaults.subscript,
|
|
109
|
+
spoiler: defaults.spoiler,
|
|
110
|
+
greentext: defaults.greentext,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// Python class that mirrors Comrak’s `ParseOptions`
|
|
116
|
+
#[pyclass(name = "ParseOptions")]
|
|
117
|
+
#[derive(Clone)]
|
|
118
|
+
pub struct PyParseOptions {
|
|
119
|
+
#[pyo3(get, set)]
|
|
120
|
+
pub smart: bool,
|
|
121
|
+
#[pyo3(get, set)]
|
|
122
|
+
pub default_info_string: Option<String>,
|
|
123
|
+
#[pyo3(get, set)]
|
|
124
|
+
pub relaxed_tasklist_matching: bool,
|
|
125
|
+
#[pyo3(get, set)]
|
|
126
|
+
pub relaxed_autolinks: bool,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
impl PyParseOptions {
|
|
130
|
+
/// Rust-only helper
|
|
131
|
+
pub fn update_parse_options(&self, opts: &mut ComrakParseOptions<'_>) {
|
|
132
|
+
opts.smart = self.smart;
|
|
133
|
+
opts.default_info_string = self.default_info_string.clone();
|
|
134
|
+
opts.relaxed_tasklist_matching = self.relaxed_tasklist_matching;
|
|
135
|
+
opts.relaxed_autolinks = self.relaxed_autolinks;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#[pymethods]
|
|
140
|
+
impl PyParseOptions {
|
|
141
|
+
#[new]
|
|
142
|
+
pub fn new() -> Self {
|
|
143
|
+
let defaults = ComrakParseOptions::default();
|
|
144
|
+
Self {
|
|
145
|
+
smart: defaults.smart,
|
|
146
|
+
default_info_string: defaults.default_info_string.clone(),
|
|
147
|
+
relaxed_tasklist_matching: defaults.relaxed_tasklist_matching,
|
|
148
|
+
relaxed_autolinks: defaults.relaxed_autolinks,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// Python class that mirrors Comrak’s `RenderOptions`
|
|
154
|
+
#[pyclass(name = "RenderOptions")]
|
|
155
|
+
#[derive(Clone)]
|
|
156
|
+
pub struct PyRenderOptions {
|
|
157
|
+
#[pyo3(get, set)]
|
|
158
|
+
pub hardbreaks: bool,
|
|
159
|
+
#[pyo3(get, set)]
|
|
160
|
+
pub github_pre_lang: bool,
|
|
161
|
+
#[pyo3(get, set)]
|
|
162
|
+
pub full_info_string: bool,
|
|
163
|
+
#[pyo3(get, set)]
|
|
164
|
+
pub width: usize,
|
|
165
|
+
#[pyo3(get, set)]
|
|
166
|
+
pub unsafe_: bool, // named 'unsafe_' because 'unsafe' is reserved
|
|
167
|
+
#[pyo3(get, set)]
|
|
168
|
+
pub escape: bool,
|
|
169
|
+
#[pyo3(get, set)]
|
|
170
|
+
pub list_style: u8, // store 42 = '*', 43 = '+', 45 = '-'
|
|
171
|
+
#[pyo3(get, set)]
|
|
172
|
+
pub sourcepos: bool,
|
|
173
|
+
#[pyo3(get, set)]
|
|
174
|
+
pub experimental_inline_sourcepos: bool,
|
|
175
|
+
#[pyo3(get, set)]
|
|
176
|
+
pub escaped_char_spans: bool,
|
|
177
|
+
#[pyo3(get, set)]
|
|
178
|
+
pub ignore_setext: bool,
|
|
179
|
+
#[pyo3(get, set)]
|
|
180
|
+
pub ignore_empty_links: bool,
|
|
181
|
+
#[pyo3(get, set)]
|
|
182
|
+
pub gfm_quirks: bool,
|
|
183
|
+
#[pyo3(get, set)]
|
|
184
|
+
pub prefer_fenced: bool,
|
|
185
|
+
#[pyo3(get, set)]
|
|
186
|
+
pub figure_with_caption: bool,
|
|
187
|
+
#[pyo3(get, set)]
|
|
188
|
+
pub tasklist_classes: bool,
|
|
189
|
+
#[pyo3(get, set)]
|
|
190
|
+
pub ol_width: usize,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
impl PyRenderOptions {
|
|
194
|
+
/// Rust-only helper
|
|
195
|
+
pub fn update_render_options(&self, opts: &mut ComrakRenderOptions) {
|
|
196
|
+
opts.hardbreaks = self.hardbreaks;
|
|
197
|
+
opts.github_pre_lang = self.github_pre_lang;
|
|
198
|
+
opts.full_info_string = self.full_info_string;
|
|
199
|
+
opts.width = self.width;
|
|
200
|
+
opts.unsafe_ = self.unsafe_;
|
|
201
|
+
opts.escape = self.escape;
|
|
202
|
+
// convert integer to ListStyleType
|
|
203
|
+
opts.list_style = match self.list_style {
|
|
204
|
+
43 => ListStyleType::Plus, // '+'
|
|
205
|
+
42 => ListStyleType::Star, // '*'
|
|
206
|
+
_ => ListStyleType::Dash, // '-'
|
|
207
|
+
};
|
|
208
|
+
opts.sourcepos = self.sourcepos;
|
|
209
|
+
opts.experimental_inline_sourcepos = self.experimental_inline_sourcepos;
|
|
210
|
+
opts.escaped_char_spans = self.escaped_char_spans;
|
|
211
|
+
opts.ignore_setext = self.ignore_setext;
|
|
212
|
+
opts.ignore_empty_links = self.ignore_empty_links;
|
|
213
|
+
opts.gfm_quirks = self.gfm_quirks;
|
|
214
|
+
opts.prefer_fenced = self.prefer_fenced;
|
|
215
|
+
opts.figure_with_caption = self.figure_with_caption;
|
|
216
|
+
opts.tasklist_classes = self.tasklist_classes;
|
|
217
|
+
opts.ol_width = self.ol_width;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#[pymethods]
|
|
222
|
+
impl PyRenderOptions {
|
|
223
|
+
#[new]
|
|
224
|
+
pub fn new() -> Self {
|
|
225
|
+
let defaults = ComrakRenderOptions::default();
|
|
226
|
+
Self {
|
|
227
|
+
hardbreaks: defaults.hardbreaks,
|
|
228
|
+
github_pre_lang: defaults.github_pre_lang,
|
|
229
|
+
full_info_string: defaults.full_info_string,
|
|
230
|
+
width: defaults.width,
|
|
231
|
+
unsafe_: defaults.unsafe_,
|
|
232
|
+
escape: defaults.escape,
|
|
233
|
+
list_style: defaults.list_style as u8, // 45 if dash
|
|
234
|
+
sourcepos: defaults.sourcepos,
|
|
235
|
+
experimental_inline_sourcepos: defaults.experimental_inline_sourcepos,
|
|
236
|
+
escaped_char_spans: defaults.escaped_char_spans,
|
|
237
|
+
ignore_setext: defaults.ignore_setext,
|
|
238
|
+
ignore_empty_links: defaults.ignore_empty_links,
|
|
239
|
+
gfm_quirks: defaults.gfm_quirks,
|
|
240
|
+
prefer_fenced: defaults.prefer_fenced,
|
|
241
|
+
figure_with_caption: defaults.figure_with_caption,
|
|
242
|
+
tasklist_classes: defaults.tasklist_classes,
|
|
243
|
+
ol_width: defaults.ol_width,
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
comrak-0.0.2/pyproject.toml
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = [
|
|
3
|
-
"maturin>=1.8,<2.0",
|
|
4
|
-
]
|
|
5
|
-
build-backend = "maturin"
|
|
6
|
-
|
|
7
|
-
[project]
|
|
8
|
-
name = "comrak"
|
|
9
|
-
description = "Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser"
|
|
10
|
-
classifiers = [
|
|
11
|
-
"Intended Audience :: Developers",
|
|
12
|
-
"License :: OSI Approved :: MIT License",
|
|
13
|
-
"Programming Language :: Rust",
|
|
14
|
-
"Programming Language :: Python :: Implementation :: CPython",
|
|
15
|
-
"Programming Language :: Python :: Implementation :: PyPy",
|
|
16
|
-
"Operating System :: OS Independent",
|
|
17
|
-
"Programming Language :: Python :: 3",
|
|
18
|
-
"Programming Language :: Python :: 3.10",
|
|
19
|
-
"Programming Language :: Python :: 3.11",
|
|
20
|
-
"Programming Language :: Python :: 3.12",
|
|
21
|
-
"Programming Language :: Python :: 3.13",
|
|
22
|
-
"Programming Language :: Python :: 3.9",
|
|
23
|
-
]
|
|
24
|
-
dynamic = [
|
|
25
|
-
"version",
|
|
26
|
-
]
|
|
27
|
-
authors = [
|
|
28
|
-
{ email = "louismmx@gmail.com", name = "Louis Maddox" },
|
|
29
|
-
]
|
|
30
|
-
keywords = [
|
|
31
|
-
"markdown",
|
|
32
|
-
"html",
|
|
33
|
-
"rust",
|
|
34
|
-
"commonmark",
|
|
35
|
-
"gfm",
|
|
36
|
-
"parser",
|
|
37
|
-
]
|
|
38
|
-
readme = "README.md"
|
|
39
|
-
requires-python = ">=3.9"
|
|
40
|
-
version = "0.0.2"
|
|
41
|
-
|
|
42
|
-
[project.license]
|
|
43
|
-
text = "MIT"
|
|
44
|
-
|
|
45
|
-
[project.optional-dependencies]
|
|
46
|
-
dev = [
|
|
47
|
-
"maturin[patchelf]>=1.8.2",
|
|
48
|
-
"pre-commit>=4.1.0",
|
|
49
|
-
]
|
|
50
|
-
bench = [
|
|
51
|
-
"markdown>=3.7",
|
|
52
|
-
"markdown2>=2.5.3",
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
[project.urls]
|
|
56
|
-
Homepage = "https://github.com/lmmx/comrak"
|
|
57
|
-
Repository = "https://github.com/lmmx/comrak.git"
|
|
58
|
-
|
|
59
|
-
[tool.maturin]
|
|
60
|
-
features = [
|
|
61
|
-
"pyo3/extension-module",
|
|
62
|
-
]
|
comrak-0.0.2/src/lib.rs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
use comrak_lib::{markdown_to_html, ComrakOptions};
|
|
2
|
-
use pyo3::prelude::*;
|
|
3
|
-
|
|
4
|
-
#[pyfunction]
|
|
5
|
-
fn render_markdown(text: &str) -> PyResult<String> {
|
|
6
|
-
let options = ComrakOptions::default();
|
|
7
|
-
let html = markdown_to_html(text, &options);
|
|
8
|
-
Ok(html)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
#[pymodule]
|
|
12
|
-
fn comrak(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
13
|
-
// In this style, `m` is an ephemeral reference to the module
|
|
14
|
-
// instead of a plain &PyModule.
|
|
15
|
-
m.add_function(wrap_pyfunction!(render_markdown, m)?)?;
|
|
16
|
-
Ok(())
|
|
17
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|