-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_txt2wp.py
113 lines (75 loc) · 3 KB
/
config_txt2wp.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
# -*- 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"""\<div.*?\>""",
r""""""),
(r"""\<\/div.*?\>""",
r""""""),
(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"JUMP TO CODE DOWNLOAD",
r"[jump_to_code_download]"),
(r"To learn (.*), just keep reading!",
r"<strong>To learn \g<1>, <em>just keep reading!</em></strong>"),
(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"""(.*), (.*) in the form below!""",
r"""<strong>\g<1>, <em>\g<2> in the form below!</em></strong>\n\n[code_download_form action="" formid=""]"""),
(r"—",
r"--"),
(r"Figure X",
r"<strong>Figure X</strong>"),
(r""""(.*?) section""",
r"""<em>"\g<1>"</em> section"""),
(r"""DOWNLOAD FORM""",
r"""[code_download_form action="" formid=""]"""),
(r"`(.*?).py`",
r"""<span class="lang:sh decode:true crayon-inline">\g<1>.py</span>"""),
(r"""`(.*?)`""",
r"""<span class="lang:python decode:true crayon-inline ">\g<1></span>"""),
(r"Summary",
r"<h2>Summary</h2>"),
(r"Project structure",
r"<h3>Project structure</h3>"),
(r"<li>([1-9]*)\. (.*)</li>",
r"<li><\g<2></li>"),
(r"([1-9]+)x([1-9]+)",
r"<em>\g<1>x\g<2></em>"),
(r"""\<i\>(.*)\<\/i\>""",
r"""<em>\g<1></em>"""),
(r"""\<p .*?\>(.*)\<\/p\>""",
r"""\g<1>"""),
(r"""\<b\>(.*)\<\/b\>""",
r"""<strong>\g<1></strong>"""),
(r"""\<b\>\<em\>(.*)\<\/em\><\/b\>""",
r"""<strong><em>\g<1></em></strong>"""),
(r"""\<a href="(.*?)"\>(.*\>)\<\/a\>""",
r"""\<a href="\g<1>" target="_blank" rel="noopener">\g<2>\<\/a\>"""),
# (r"""\<span class.*?\>(.*)\<\/span\>""",
# r"""\g<1>"""),
# (r"""\<span class.*?\>(.*)\<\/span\>""",
# r"""\g<1>"""),
(r"""\<span style="font-weight: bold;"\>(.*?)\<\/span\>""",
r"""\<strong\>\g<1>\<\/strong\>"""),
(r"""\<span style="font-style: italic;"\>(.*?)\<\/span\>""",
r"""\<em>\g<1></em>"""),
(r"""\<span style="font-weight: bold; font-style: italic;"\>(.*?)\<\/span\>""",
r"""<strong><em>\g<1></em></strong>"""),
(r"""\<span style="font-weight: bold; font-size: 24px;"\>(.*?)\<\/span\>""",
r"""\n<h2>\g<1></h2>\n"""),
(r"""\<span style="font-weight: bold; font-size: 18px;"\>(.*?)\<\/span\>""",
r"""\n\<h3\>\g<1>\<\/h3\>\n"""),
(r"""COMMAND""",
r"""\n<pre class="start-line:1 lang:sh decode:true " title="@TITLE@">COMMAND OUTPUT</pre>\n\n\g<2>"""),
(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>""")
]