projects/aports·blob master · refs

81 lines · 2.4 KiB

1--- a/m2r2.py
2+++ b/m2r2.py
3@@ -11,7 +11,7 @@
4 import sys
5 from argparse import ArgumentParser, Namespace
6
7-import mistune
8+import mistune1
9 from docutils import io, statemachine, utils
10 from docutils.parsers import rst
11 from docutils.utils import column_width
12@@ -86,7 +86,7 @@
13 parser.parse_known_args(namespace=options)
14
15
16-class RestBlockGrammar(mistune.BlockGrammar): # pylint: disable=too-few-public-methods
17+class RestBlockGrammar(mistune1.BlockGrammar): # pylint: disable=too-few-public-methods
18 directive = re.compile(
19 r"^( *\.\..*?)\n(?=\S)",
20 re.DOTALL | re.MULTILINE,
21@@ -101,13 +101,13 @@
22 )
23
24
25-class RestBlockLexer(mistune.BlockLexer):
26+class RestBlockLexer(mistune1.BlockLexer):
27 grammar_class = RestBlockGrammar
28 default_rules = [
29 "directive",
30 "oneline_directive",
31 "rest_code_block",
32- ] + mistune.BlockLexer.default_rules
33+ ] + mistune1.BlockLexer.default_rules
34
35 def parse_directive(self, m):
36 self.tokens.append({"type": "directive", "text": m.group(1)})
37@@ -120,7 +120,7 @@
38 self.tokens.append({"type": "rest_code_block"})
39
40
41-class RestInlineGrammar(mistune.InlineGrammar):
42+class RestInlineGrammar(mistune1.InlineGrammar):
43 image_link = re.compile(
44 r"\[!\[(?P<alt>.*?)\]\((?P<url>.*?)\).*?\]\((?P<target>.*?)\)"
45 )
46@@ -146,14 +146,14 @@
47 self.emphasis = re.compile(r"^\*(?P<text>(?:\*\*|[^\*])+?)\*(?!\*)") # *word*
48
49
50-class RestInlineLexer(mistune.InlineLexer):
51+class RestInlineLexer(mistune1.InlineLexer):
52 grammar_class = RestInlineGrammar
53 default_rules = [
54 "image_link",
55 "rest_role",
56 "rest_link",
57 "eol_literal_marker",
58- ] + mistune.InlineLexer.default_rules
59+ ] + mistune1.InlineLexer.default_rules
60
61 def __init__(self, *args, **kwargs):
62 no_underscore_emphasis = kwargs.pop("no_underscore_emphasis", False)
63@@ -204,7 +204,7 @@
64 return self.renderer.eol_literal_marker(marker)
65
66
67-class RestRenderer(mistune.Renderer): # pylint: disable=too-many-public-methods
68+class RestRenderer(mistune1.Renderer): # pylint: disable=too-many-public-methods
69 _include_raw_html = False
70 list_indent_re = re.compile(r"^(\s*(#\.|\*)\s)")
71 indent = " " * 3
72@@ -520,7 +520,7 @@
73 return "\n\n"
74
75
76-class M2R(mistune.Markdown):
77+class M2R(mistune1.Markdown):
78 def __init__(
79 self, renderer=None, inline=RestInlineLexer, block=RestBlockLexer, **kwargs
80 ):
81