File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 33def align_yaml (str , pad = 0 , aligned_colons = False ):
44 props = re .findall (r'^\s*[\S]+:' , str , re .MULTILINE )
55 longest = max ([len (i ) for i in props ]) + pad
6- return '' .join ([i + '\n ' for i in map (lambda str :
7- re .sub (r'^(\s*.+?[^:#]): \s*(.*)' if aligned_colons else r'^(\s*.+?[^:#]: )\s*(.*)' , lambda m :
8- m .group (1 ) + '' .ljust (longest - len (m .group (1 ))+ (- 1 - pad if aligned_colons else 1 )) + (':' .ljust (pad + 1 ) if aligned_colons else '' ) + m .group (2 ),
9- str , re .MULTILINE )
10- , str .split ('\n ' ))])
6+ if aligned_colons :
7+ return '' .join ([i + '\n ' for i in map (lambda str :
8+ re .sub (r'^(\s*.+?[^:#]): \s*(.*)' , lambda m :
9+ m .group (1 ) + '' .ljust (longest - len (m .group (1 ))- 1 - pad ) + ':' .ljust (pad + 1 ) + m .group (2 ),
10+ str , re .MULTILINE )
11+ , str .split ('\n ' ))])
12+ else :
13+ return '' .join ([i + '\n ' for i in map (lambda str :
14+ re .sub (r'^(\s*.+?[^:#]: )\s*(.*)' , lambda m :
15+ m .group (1 ) + '' .ljust (longest - len (m .group (1 ))+ 1 ) + m .group (2 ),
16+ str , re .MULTILINE )
17+ , str .split ('\n ' ))])
You can’t perform that action at this time.
0 commit comments