Mercurial > public > mercurial-scm > hg
comparison mercurial/minirst.py @ 12867:eda77c3e246a stable
minirst: use colwidth to match title lengths (issue2455)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 27 Oct 2010 15:35:23 -0500 |
parents | 5082e2f3f8e0 |
children | 8957c39867f6 |
comparison
equal
deleted
inserted
replaced
12866:eddc20306ab6 | 12867:eda77c3e246a |
---|---|
246 # | Section title | | 246 # | Section title | |
247 # | ------------- | | 247 # | ------------- | |
248 # +------------------------------+ | 248 # +------------------------------+ |
249 if (block['type'] == 'paragraph' and | 249 if (block['type'] == 'paragraph' and |
250 len(block['lines']) == 2 and | 250 len(block['lines']) == 2 and |
251 len(block['lines'][0]) == len(block['lines'][1]) and | 251 encoding.colwidth(block['lines'][0]) == len(block['lines'][1]) and |
252 _sectionre.match(block['lines'][1])): | 252 _sectionre.match(block['lines'][1])): |
253 block['underline'] = block['lines'][1][0] | 253 block['underline'] = block['lines'][1][0] |
254 block['type'] = 'section' | 254 block['type'] = 'section' |
255 del block['lines'][1] | 255 del block['lines'][1] |
256 return blocks | 256 return blocks |
356 return '' | 356 return '' |
357 if block['type'] == 'literal': | 357 if block['type'] == 'literal': |
358 indent += ' ' | 358 indent += ' ' |
359 return indent + ('\n' + indent).join(block['lines']) | 359 return indent + ('\n' + indent).join(block['lines']) |
360 if block['type'] == 'section': | 360 if block['type'] == 'section': |
361 underline = len(block['lines'][0]) * block['underline'] | 361 underline = encoding.colwidth(block['lines'][0]) * block['underline'] |
362 return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) | 362 return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) |
363 if block['type'] == 'definition': | 363 if block['type'] == 'definition': |
364 term = indent + block['lines'][0] | 364 term = indent + block['lines'][0] |
365 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) | 365 hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) |
366 defindent = indent + hang * ' ' | 366 defindent = indent + hang * ' ' |