File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010from __future__ import annotations
1111
1212from collections .abc import Sequence
13- import re
1413
1514from markdown_it import MarkdownIt
1615from markdown_it .renderer import RendererHTML
1716from markdown_it .rules_inline import StateInline
1817from markdown_it .token import Token
1918from markdown_it .utils import EnvType , OptionsDict
19+ from mdit_py_plugins .utils import UNESCAPE_RE , WHITESPACE_RE
2020
2121__all__ = ["sub_plugin" ]
2222
2323TILDE_CHAR = "~"
2424
25- WHITESPACE_RE = re .compile (r"(^|[^\\])(\\\\)*\s" )
26- UNESCAPE_RE = re .compile (r'\\([ \\!"#$%&\'()*+,.\/:;<=>?@[\]^_`{|}~-])' )
27-
2825
2926def tokenize (state : StateInline , silent : bool ) -> bool :
3027 """Parse a ~subscript~ token."""
Original file line number Diff line number Diff line change 2828OTHER DEALINGS IN THE SOFTWARE.
2929"""
3030
31- import re
32-
3331from markdown_it import MarkdownIt
3432from markdown_it .rules_inline import StateInline
35-
36- UNESCAPE_RE = re .compile (r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])" )
37- WHITESPACE_RE = re .compile (r"(^|[^\\])(\\\\)*\s" )
33+ from mdit_py_plugins .utils import UNESCAPE_RE , WHITESPACE_RE
3834
3935
4036def superscript_plugin (md : MarkdownIt ) -> None :
Original file line number Diff line number Diff line change 1+ import re
2+
13from markdown_it .rules_block import StateBlock
24
35
@@ -10,3 +12,8 @@ def is_code_block(state: StateBlock, line: int) -> bool:
1012 pass
1113
1214 return (state .sCount [line ] - state .blkIndent ) >= 4
15+
16+
17+ # Regex for subscript and superscript plugins
18+ UNESCAPE_RE = re .compile (r"\\([ \\!\"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])" )
19+ WHITESPACE_RE = re .compile (r"(^|[^\\])(\\\\)*\s" )
You can’t perform that action at this time.
0 commit comments