Show More
@@ -292,6 +292,17 b' def addmargins(blocks):' | |||||
292 | i += 2 |
|
292 | i += 2 | |
293 | return blocks |
|
293 | return blocks | |
294 |
|
294 | |||
|
295 | def prunecomments(blocks): | |||
|
296 | """Remove comments.""" | |||
|
297 | i = 0 | |||
|
298 | while i < len(blocks): | |||
|
299 | b = blocks[i] | |||
|
300 | if b['type'] == 'paragraph' and b['lines'][0].startswith('.. '): | |||
|
301 | del blocks[i] | |||
|
302 | else: | |||
|
303 | i += 1 | |||
|
304 | return blocks | |||
|
305 | ||||
295 | _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" |
|
306 | _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" | |
296 | r"error|hint|important|note|tip|warning)::", |
|
307 | r"error|hint|important|note|tip|warning)::", | |
297 | flags=re.IGNORECASE) |
|
308 | flags=re.IGNORECASE) | |
@@ -405,6 +416,7 b' def format(text, width, indent=0, keep=N' | |||||
405 | blocks = hgrole(blocks) |
|
416 | blocks = hgrole(blocks) | |
406 | blocks = splitparagraphs(blocks) |
|
417 | blocks = splitparagraphs(blocks) | |
407 | blocks = updatefieldlists(blocks) |
|
418 | blocks = updatefieldlists(blocks) | |
|
419 | blocks = prunecomments(blocks) | |||
408 | blocks = addmargins(blocks) |
|
420 | blocks = addmargins(blocks) | |
409 | blocks = findadmonitions(blocks) |
|
421 | blocks = findadmonitions(blocks) | |
410 | text = '\n'.join(formatblock(b, width) for b in blocks) |
|
422 | text = '\n'.join(formatblock(b, width) for b in blocks) | |
@@ -432,6 +444,7 b' if __name__ == "__main__":' | |||||
432 | blocks = debug(splitparagraphs, blocks) |
|
444 | blocks = debug(splitparagraphs, blocks) | |
433 | blocks = debug(updatefieldlists, blocks) |
|
445 | blocks = debug(updatefieldlists, blocks) | |
434 | blocks = debug(findsections, blocks) |
|
446 | blocks = debug(findsections, blocks) | |
|
447 | blocks = debug(prunecomments, blocks) | |||
435 | blocks = debug(addmargins, blocks) |
|
448 | blocks = debug(addmargins, blocks) | |
436 | blocks = debug(findadmonitions, blocks) |
|
449 | blocks = debug(findadmonitions, blocks) | |
437 | print '\n'.join(formatblock(b, 30) for b in blocks) |
|
450 | print '\n'.join(formatblock(b, 30) for b in blocks) |
@@ -214,3 +214,15 b' admonitions = """' | |||||
214 | """ |
|
214 | """ | |
215 |
|
215 | |||
216 | debugformat('admonitions', admonitions, 30) |
|
216 | debugformat('admonitions', admonitions, 30) | |
|
217 | ||||
|
218 | comments = """ | |||
|
219 | Some text. | |||
|
220 | ||||
|
221 | .. A comment | |||
|
222 | ||||
|
223 | .. An indented comment | |||
|
224 | ||||
|
225 | Some indented text. | |||
|
226 | """ | |||
|
227 | ||||
|
228 | debugformat('comments', comments, 30) |
@@ -334,3 +334,10 b' Note:' | |||||
334 | This is danger |
|
334 | This is danger | |
335 | ---------------------------------------------------------------------- |
|
335 | ---------------------------------------------------------------------- | |
336 |
|
336 | |||
|
337 | comments formatted to fit within 30 characters: | |||
|
338 | ---------------------------------------------------------------------- | |||
|
339 | Some text. | |||
|
340 | ||||
|
341 | Some indented text. | |||
|
342 | ---------------------------------------------------------------------- | |||
|
343 |
General Comments 0
You need to be logged in to leave comments.
Login now