Mercurial > hg
comparison mercurial/minirst.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 687b865b95ad |
children | aaff3bc75306 |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
50 def subsubsubsubsection(s): | 50 def subsubsubsubsection(s): |
51 return b"%s\n%s\n\n" % (s, b"'" * encoding.colwidth(s)) | 51 return b"%s\n%s\n\n" % (s, b"'" * encoding.colwidth(s)) |
52 | 52 |
53 | 53 |
54 def replace(text, substs): | 54 def replace(text, substs): |
55 ''' | 55 """ |
56 Apply a list of (find, replace) pairs to a text. | 56 Apply a list of (find, replace) pairs to a text. |
57 | 57 |
58 >>> replace(b"foo bar", [(b'f', b'F'), (b'b', b'B')]) | 58 >>> replace(b"foo bar", [(b'f', b'F'), (b'b', b'B')]) |
59 'Foo Bar' | 59 'Foo Bar' |
60 >>> encoding.encoding = b'latin1' | 60 >>> encoding.encoding = b'latin1' |
61 >>> replace(b'\\x81\\\\', [(b'\\\\', b'/')]) | 61 >>> replace(b'\\x81\\\\', [(b'\\\\', b'/')]) |
62 '\\x81/' | 62 '\\x81/' |
63 >>> encoding.encoding = b'shiftjis' | 63 >>> encoding.encoding = b'shiftjis' |
64 >>> replace(b'\\x81\\\\', [(b'\\\\', b'/')]) | 64 >>> replace(b'\\x81\\\\', [(b'\\\\', b'/')]) |
65 '\\x81\\\\' | 65 '\\x81\\\\' |
66 ''' | 66 """ |
67 | 67 |
68 # some character encodings (cp932 for Japanese, at least) use | 68 # some character encodings (cp932 for Japanese, at least) use |
69 # ASCII characters other than control/alphabet/digit as a part of | 69 # ASCII characters other than control/alphabet/digit as a part of |
70 # multi-bytes characters, so direct replacing with such characters | 70 # multi-bytes characters, so direct replacing with such characters |
71 # on strings in local encoding causes invalid byte sequences. | 71 # on strings in local encoding causes invalid byte sequences. |
320 | 320 |
321 _sectionre = re.compile(br"""^([-=`:.'"~^_*+#])\1+$""") | 321 _sectionre = re.compile(br"""^([-=`:.'"~^_*+#])\1+$""") |
322 | 322 |
323 | 323 |
324 def findtables(blocks): | 324 def findtables(blocks): |
325 '''Find simple tables | 325 """Find simple tables |
326 | 326 |
327 Only simple one-line table elements are supported | 327 Only simple one-line table elements are supported |
328 ''' | 328 """ |
329 | 329 |
330 for block in blocks: | 330 for block in blocks: |
331 # Searching for a block that looks like this: | 331 # Searching for a block that looks like this: |
332 # | 332 # |
333 # === ==== === | 333 # === ==== === |
430 """ | 430 """ |
431 i = 1 | 431 i = 1 |
432 while i < len(blocks): | 432 while i < len(blocks): |
433 if blocks[i][b'type'] == blocks[i - 1][b'type'] and blocks[i][ | 433 if blocks[i][b'type'] == blocks[i - 1][b'type'] and blocks[i][ |
434 b'type' | 434 b'type' |
435 ] in (b'bullet', b'option', b'field',): | 435 ] in ( |
436 b'bullet', | |
437 b'option', | |
438 b'field', | |
439 ): | |
436 i += 1 | 440 i += 1 |
437 elif not blocks[i - 1][b'lines']: | 441 elif not blocks[i - 1][b'lines']: |
438 # no lines in previous block, do not separate | 442 # no lines in previous block, do not separate |
439 i += 1 | 443 i += 1 |
440 else: | 444 else: |