generic text markup tools
Revisión | 18f5a22b3e7afc176d2ee7728b80e351060a9822 (tree) |
---|---|
Tiempo | 2013-09-01 22:26:08 |
Autor | hylom <hylom@hylo...> |
Commiter | hylom |
update jarkup.json: enable textlink in table
@@ -42,6 +42,23 @@ | ||
42 | 42 | "regexp": "\\*b\\[(.*?)]", |
43 | 43 | "replace": "<strong>\\1</strong>" |
44 | 44 | } |
45 | + }, | |
46 | + "inline": { | |
47 | + "textLink": { | |
48 | + "priority": 100, | |
49 | + "regexp": "\\*\\[(https?:/[^ ]*?)\\s+(.*?)]", | |
50 | + "replace": "<a href=\"\\1\">\\2</a>" | |
51 | + }, | |
52 | + "rawLink": { | |
53 | + "priority": 101, | |
54 | + "regexp": "\\*\\[(https?:/[^ ]*?)]", | |
55 | + "replace": "<a href=\"\\1\">\\1</a>" | |
56 | + }, | |
57 | + "refference": { | |
58 | + "priority": 102, | |
59 | + "regexp": "\\*(図|表|リスト|実行例)([0-9A-Za-z、]+)", | |
60 | + "replace": "<strong>\\1\\2</strong>" | |
61 | + } | |
45 | 62 | } |
46 | 63 | }, |
47 | 64 | "modes": { |
@@ -72,6 +89,7 @@ | ||
72 | 89 | "transitions": [ |
73 | 90 | "figure", |
74 | 91 | "code", |
92 | + "langCode", | |
75 | 93 | "table", |
76 | 94 | "unOrderdList", |
77 | 95 | "note", |
@@ -98,7 +116,7 @@ | ||
98 | 116 | } |
99 | 117 | }, |
100 | 118 | "table": { |
101 | - "includeRule": ["fontDecoration", "toEntity"], | |
119 | + "includeRule": ["inline", "fontDecoration", "toEntity" ], | |
102 | 120 | "rules": { |
103 | 121 | "tableRow": { |
104 | 122 | "priority": 102, |
@@ -157,6 +175,19 @@ | ||
157 | 175 | "replace": "" |
158 | 176 | } |
159 | 177 | }, |
178 | + "langCode": { | |
179 | + "includeRule": ["fontDecoration", "toEntity"], | |
180 | + "begin": "^☆\\+---\\((.*)\\)\\s*$", | |
181 | + "end": "^☆\\+---\\s*$", | |
182 | + "onStart": { | |
183 | + "insert": "<pre>", | |
184 | + "replace": "" | |
185 | + }, | |
186 | + "onFinished": { | |
187 | + "insert": "</pre>", | |
188 | + "replace": "" | |
189 | + } | |
190 | + }, | |
160 | 191 | "codeList": { |
161 | 192 | "includeRule": ["fontDecoration", "toEntity"], |
162 | 193 | "begin": "^☆リスト.*$", |
@@ -219,6 +250,7 @@ | ||
219 | 250 | "transitions": [ |
220 | 251 | "figure", |
221 | 252 | "code", |
253 | + "langCode", | |
222 | 254 | "table", |
223 | 255 | "unOrderdList", |
224 | 256 | "comment", |
@@ -237,13 +237,17 @@ class Parser(object): | ||
237 | 237 | rex = re.compile('\$([0-9]+)') |
238 | 238 | m = rex.search(text) |
239 | 239 | if m and match: |
240 | - sub_func = lambda x:match.group(int(x.group(1))) | |
241 | - text = rex.sub(sub_func, text) | |
240 | + def match_func(x): | |
241 | + ret = match.group(int(x.group(1))) | |
242 | + if ret == None: | |
243 | + ret = x | |
244 | + return ret | |
245 | + text = rex.sub(match_func, text) | |
242 | 246 | |
243 | 247 | # expand vars |
244 | 248 | rex = re.compile('\${?([A-Za-z0-9_]+)}?') |
245 | 249 | m = rex.search(text) |
246 | - sub_func = lambda x:self.store.load(x.group(1), '') | |
250 | + sub_func = lambda x:self.store.load(x.group(1), x.string) | |
247 | 251 | text = rex.sub(sub_func, text) |
248 | 252 | return text |
249 | 253 |