Show More
@@ -296,28 +296,25 b' def addmargins(blocks):' | |||
|
296 | 296 | i += 2 |
|
297 | 297 | return blocks |
|
298 | 298 | |
|
299 | _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" | |
|
300 | r"error|hint|important|note|tip|warning)::", | |
|
301 | flags=re.IGNORECASE) | |
|
302 | ||
|
299 | 303 | def findadmonitions(blocks): |
|
300 | 304 | """ |
|
301 | 305 | Makes the type of the block an admonition block if |
|
302 | 306 | the first line is an admonition directive |
|
303 | 307 | """ |
|
304 | ||
|
305 | 308 | i = 0 |
|
306 | ||
|
307 | pattern = (r"\.\. (admonition|attention|caution|danger|error|hint|" | |
|
308 | r"important|note|tip|warning)::") | |
|
309 | ||
|
310 | prog = re.compile(pattern, flags=re.IGNORECASE) | |
|
311 | 309 | while i < len(blocks): |
|
312 |
m = |
|
|
310 | m = _admonitionre.match(blocks[i]['lines'][0]) | |
|
313 | 311 | if m: |
|
314 | 312 | blocks[i]['type'] = 'admonition' |
|
315 | 313 | admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower() |
|
316 | 314 | |
|
317 | 315 | firstline = blocks[i]['lines'][0][m.end() + 1:] |
|
318 |
if firstline |
|
|
319 |
blocks[i]['lines'].insert(1, ' ' + firstline |
|
|
320 | ||
|
316 | if firstline: | |
|
317 | blocks[i]['lines'].insert(1, ' ' + firstline) | |
|
321 | 318 | |
|
322 | 319 | blocks[i]['admonitiontitle'] = admonitiontitle |
|
323 | 320 | del blocks[i]['lines'][0] |
General Comments 0
You need to be logged in to leave comments.
Login now