Show More
@@ -241,13 +241,15 b' def findsections(blocks):' | |||||
241 | if (block['type'] == 'paragraph' and |
|
241 | if (block['type'] == 'paragraph' and | |
242 | len(block['lines']) == 2 and |
|
242 | len(block['lines']) == 2 and | |
243 | block['lines'][1] == '-' * len(block['lines'][0])): |
|
243 | block['lines'][1] == '-' * len(block['lines'][0])): | |
|
244 | block['underline'] = block['lines'][1][0] | |||
244 | block['type'] = 'section' |
|
245 | block['type'] = 'section' | |
|
246 | del block['lines'][1] | |||
245 | return blocks |
|
247 | return blocks | |
246 |
|
248 | |||
247 |
|
249 | |||
248 | def inlineliterals(blocks): |
|
250 | def inlineliterals(blocks): | |
249 | for b in blocks: |
|
251 | for b in blocks: | |
250 |
if b['type'] |
|
252 | if b['type'] in ('paragraph', 'section'): | |
251 | b['lines'] = [l.replace('``', '"') for l in b['lines']] |
|
253 | b['lines'] = [l.replace('``', '"') for l in b['lines']] | |
252 | return blocks |
|
254 | return blocks | |
253 |
|
255 | |||
@@ -256,7 +258,7 b' def inlineliterals(blocks):' | |||||
256 |
|
258 | |||
257 | def hgrole(blocks): |
|
259 | def hgrole(blocks): | |
258 | for b in blocks: |
|
260 | for b in blocks: | |
259 |
if b['type'] |
|
261 | if b['type'] in ('paragraph', 'section'): | |
260 | b['lines'] = [_hgrolere.sub(r'"hg \1"', l) for l in b['lines']] |
|
262 | b['lines'] = [_hgrolere.sub(r'"hg \1"', l) for l in b['lines']] | |
261 | return blocks |
|
263 | return blocks | |
262 |
|
264 | |||
@@ -289,7 +291,8 b' def formatblock(block, width):' | |||||
289 | indent += ' ' |
|
291 | indent += ' ' | |
290 | return indent + ('\n' + indent).join(block['lines']) |
|
292 | return indent + ('\n' + indent).join(block['lines']) | |
291 | if block['type'] == 'section': |
|
293 | if block['type'] == 'section': | |
292 | return indent + ('\n' + indent).join(block['lines']) |
|
294 | underline = len(block['lines'][0]) * block['underline'] | |
|
295 | return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) | |||
293 | if block['type'] == 'definition': |
|
296 | if block['type'] == 'definition': | |
294 | term = indent + block['lines'][0] |
|
297 | term = indent + block['lines'][0] | |
295 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) |
|
298 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) | |
@@ -341,11 +344,11 b' def format(text, width, indent=0, keep=N' | |||||
341 | b['indent'] += indent |
|
344 | b['indent'] += indent | |
342 | blocks = findliteralblocks(blocks) |
|
345 | blocks = findliteralblocks(blocks) | |
343 | blocks, pruned = prunecontainers(blocks, keep or []) |
|
346 | blocks, pruned = prunecontainers(blocks, keep or []) | |
|
347 | blocks = findsections(blocks) | |||
344 | blocks = inlineliterals(blocks) |
|
348 | blocks = inlineliterals(blocks) | |
345 | blocks = hgrole(blocks) |
|
349 | blocks = hgrole(blocks) | |
346 | blocks = splitparagraphs(blocks) |
|
350 | blocks = splitparagraphs(blocks) | |
347 | blocks = updatefieldlists(blocks) |
|
351 | blocks = updatefieldlists(blocks) | |
348 | blocks = findsections(blocks) |
|
|||
349 | blocks = addmargins(blocks) |
|
352 | blocks = addmargins(blocks) | |
350 | text = '\n'.join(formatblock(b, width) for b in blocks) |
|
353 | text = '\n'.join(formatblock(b, width) for b in blocks) | |
351 | if keep is None: |
|
354 | if keep is None: |
@@ -186,5 +186,8 b" debugformat('roles', roles, 60)" | |||||
186 | sections = """ |
|
186 | sections = """ | |
187 | A Somewhat Wide Section Header |
|
187 | A Somewhat Wide Section Header | |
188 | ------------------------------ |
|
188 | ------------------------------ | |
|
189 | ||||
|
190 | Markup: ``foo`` and :hg:`help` | |||
|
191 | ------------------------------ | |||
189 | """ |
|
192 | """ | |
190 | debugformat('sections', sections, 20) |
|
193 | debugformat('sections', sections, 20) |
@@ -307,5 +307,8 b' sections formatted to fit within 20 char' | |||||
307 | ---------------------------------------------------------------------- |
|
307 | ---------------------------------------------------------------------- | |
308 | A Somewhat Wide Section Header |
|
308 | A Somewhat Wide Section Header | |
309 | ------------------------------ |
|
309 | ------------------------------ | |
|
310 | ||||
|
311 | Markup: "foo" and "hg help" | |||
|
312 | --------------------------- | |||
310 | ---------------------------------------------------------------------- |
|
313 | ---------------------------------------------------------------------- | |
311 |
|
314 |
General Comments 0
You need to be logged in to leave comments.
Login now