Show More
@@ -292,6 +292,17 b' def addmargins(blocks):' | |||
|
292 | 292 | i += 2 |
|
293 | 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 | 306 | _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" |
|
296 | 307 | r"error|hint|important|note|tip|warning)::", |
|
297 | 308 | flags=re.IGNORECASE) |
@@ -405,6 +416,7 b' def format(text, width, indent=0, keep=N' | |||
|
405 | 416 | blocks = hgrole(blocks) |
|
406 | 417 | blocks = splitparagraphs(blocks) |
|
407 | 418 | blocks = updatefieldlists(blocks) |
|
419 | blocks = prunecomments(blocks) | |
|
408 | 420 | blocks = addmargins(blocks) |
|
409 | 421 | blocks = findadmonitions(blocks) |
|
410 | 422 | text = '\n'.join(formatblock(b, width) for b in blocks) |
@@ -432,6 +444,7 b' if __name__ == "__main__":' | |||
|
432 | 444 | blocks = debug(splitparagraphs, blocks) |
|
433 | 445 | blocks = debug(updatefieldlists, blocks) |
|
434 | 446 | blocks = debug(findsections, blocks) |
|
447 | blocks = debug(prunecomments, blocks) | |
|
435 | 448 | blocks = debug(addmargins, blocks) |
|
436 | 449 | blocks = debug(findadmonitions, blocks) |
|
437 | 450 | print '\n'.join(formatblock(b, 30) for b in blocks) |
@@ -214,3 +214,15 b' admonitions = """' | |||
|
214 | 214 | """ |
|
215 | 215 | |
|
216 | 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 | 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