generic text markup tools
Revisión | dc1eabe62fc8d19696dd74bc9a6ad0d576b550b0 (tree) |
---|---|
Tiempo | 2013-04-08 23:42:04 |
Autor | hylom <hylom@hylo...> |
Commiter | hylom |
jarkup.json: add note mode
@@ -70,7 +70,8 @@ | ||
70 | 70 | "figure", |
71 | 71 | "code", |
72 | 72 | "table", |
73 | - "unOrderdList" | |
73 | + "unOrderdList", | |
74 | + "note" | |
74 | 75 | ] |
75 | 76 | }, |
76 | 77 | "unOrderdList": { |
@@ -161,7 +162,7 @@ | ||
161 | 162 | }, |
162 | 163 | "caption": { |
163 | 164 | "priority": 100, |
164 | - "regexp": "^^☆図([0-9]+)\\s+(.*)$", | |
165 | + "regexp": "^☆図([0-9]+)\\s+(.*)$", | |
165 | 166 | "continue": false, |
166 | 167 | "store": [ |
167 | 168 | "ref", |
@@ -178,17 +179,29 @@ | ||
178 | 179 | }, |
179 | 180 | "note": { |
180 | 181 | "extends": "global", |
181 | - "begin": "^☆note$", | |
182 | - "end": "^☆note-end$", | |
182 | + "transitions": [ | |
183 | + "figure", | |
184 | + "code", | |
185 | + "table", | |
186 | + "unOrderdList" | |
187 | + ], | |
188 | + "begin": "^☆note\\s+(.*)$", | |
189 | + "end": "^☆note-end\\s*$", | |
183 | 190 | "onStart": { |
184 | - "insert": "<div class=\"column note\">", | |
185 | - "replace": "" | |
191 | + "insert": "<div class=\"note\">\n" | |
186 | 192 | }, |
187 | 193 | "onFinished": { |
188 | - "insert": "</div>\n", | |
194 | + "insert": "</div>", | |
189 | 195 | "replace": "" |
196 | + }, | |
197 | + "rules": { | |
198 | + "title": { | |
199 | + "priority": 100, | |
200 | + "regexp": "^☆note\\s+(.*)$", | |
201 | + "replace": "<h5>\\1</h5>" | |
202 | + } | |
190 | 203 | } |
191 | - }, | |
204 | + }, | |
192 | 205 | "inline": { |
193 | 206 | "includeRule": ["fontDecoration", "toEntity"], |
194 | 207 | "rules": { |
@@ -40,6 +40,10 @@ | ||
40 | 40 | もしくは*b{こういう感じ}や*g{こんな風}にもできます |
41 | 41 | ☆+--- |
42 | 42 | |
43 | +☆note 注釈/コラム | |
44 | + 注釈/コラム内ではほかのマークアップがそのまま使えます。 | |
45 | +☆note-end | |
46 | + | |
43 | 47 | 下記、テストその2。 |
44 | 48 | |
45 | 49 | ☆+--- |
@@ -25,6 +25,7 @@ class Mode(object): | ||
25 | 25 | def test(self, attr_name, text): |
26 | 26 | '''test attr_name matches text''' |
27 | 27 | rex = self.attr(attr_name, False) |
28 | + #_debug_print(rex) | |
28 | 29 | if rex and re.search(rex, text): |
29 | 30 | return True |
30 | 31 | else: |
@@ -228,6 +229,7 @@ class Parser(object): | ||
228 | 229 | return '' |
229 | 230 | |
230 | 231 | mode = self.current_mode() |
232 | + #_debug_print(mode.name) | |
231 | 233 | if mode.test("end", text): |
232 | 234 | text = mode.on_exit(self, text) |
233 | 235 | self.mode_stack.pop() |