-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_md2wp_crayon.py
116 lines (80 loc) · 2.89 KB
/
config_md2wp_crayon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- coding: utf-8 -*-
# NOTE: in Sublime Text, "(groups) in regex" are "$1 in regex".
# in Python, "(groups) in regex" are "\g<1> in regex".
# regular expression strings in format [(find, replace), (find2, replace2)...]
regexStrings = [
(r" *\- ",
r"""\n"""),
(r"""(.*)Codeblock \#(\d*): Lines (\d*)-(\d*)(.*)""",
r"""\g<1>\n\n<pre class="start-line:\g<3> lang:python decode:true " title="@TITLE@">Codeblock \g<2> Lines \g<3>-\g<4></pre>\n\n\g<5>"""),
(r"""(.*)COMMAND OUTPUT(.*)""",
r"""\g<1>\n\n<pre class="start-line:1 lang:sh decode:true " title="@TITLE@">COMMAND OUTPUT</pre>\n\n\g<2>"""),
(r"Review project structure",
r"""Review project structure\n\n<pre class="start-line:1 lang:sh decode:true " title="@TITLE@">$ tree --dirsfirst --filelimit 10
output</pre>\n\n...\n"""),
(r"Figure X",
r"<strong>Figure X</strong>"),
# bold italics
(r"""\*\*\*(.*?)\*\*\*""",
r"""<strong><em>\g<1></em></strong>"""),
# bold generic
(r"""\*\*(.*?)\*\*""",
r"""<strong>\g<1></strong>"""),
# ##### must be under **double** stars #####
# italics
(r"""\*{1}(.*?)\*{1}""",
r"""<em>\g<1></em>"""),
(r"""—""",
r"""--"""),
# italics
#(r"""\_(.*?)\_""",
# r"""<em>\g<1></em>"""),
# italics (x, y)-coordinates
(r""" \(x, y\)-(.*) """,
r""" <em>\(x, y\)</em>-\g<1> """),
(r"JUMP TO CODE DOWNLOAD",
r"[jump_to_code_download]"),
(r"""DOWNLOAD FORM""",
r"""[code_download_form action="" formid=""]"""),
# preformatted filename
(r"`(.*?).py`",
r"""<span class="lang:sh decode:true crayon-inline">\g<1>.py</span>"""),
# preformatted
(r"""`(.*?)`""",
r"""<span class="lang:python decode:true crayon-inline ">\g<1></span>"""),
# fix preformatted inline zero
(r""">0<""",
r"""> 0<"""),
(r""".Downloads.""",
r"""<strong><em>"Downloads"</em></strong>"""),
# (r"""\(x, y\)-(.*) """,
# r"""<em>(x, y)</em>-\g<1> """),
# (r"""Line (\d*)""",
# r"""<strong>Line \g<1></strong>"""),
# (r"""Lines (\d*)-(\d*)""",
# r"""<strong>Lines \g<1>-\g<2></strong>"""),
# (r"""Lines (\d*) and (\d*)""",
# r"""<strong>Lines \g<1> and \g<2></strong>"""),
# # MARKDOWN
# # be careful with this one -- if there is a comment in a code block, it fails
(r"""^# (.*)""",
r"""<h2>\g<1></h2>"""),
(r"""^## (.*)""",
r"""<h3>\g<1></h3>"""),
(r"""^### (.*)""",
r"""<h4>\g<1></h2>"""),
# (r"""_(.*)_""",
# r"""<em>\g<1></em>"""),
# (r""" \*([a-zA-Z].*?)\* """,
# r"""<em>\g<1></em>"""),
# (r"""\*\*(.*)\*\*""",
# r"""<strong>\g<1></strong>"""),
(r"""\[(.*?)\]\((.*?)\)""",
r"""<a href="\g<2>" target="_blank" rel="noopener">\g<1></a>"""),
(r"""^(```)\n((.*\n)*?)^(```)""",
r"""\n<pre class="start-line:1 lang:sh decode:true " title="@TITLE@">\g<2></pre>\n\n""")
# (r"\`(.*?).py\`",
# r"""<span class="lang:sh decode:true crayon-inline">\g<1>.py</span>"""),
# (r"""\`(.*?)\`(.?)""",
# r"""<span class="lang:sh decode:true crayon-inline ">\g<1></span>\g<2>""")
]