def set_margin(lines, margin=0):
"""Utility routine that sets the left margin to 'margin' space in a
block of non-blank lines."""
# Calculate width of block margin.
lines = list(lines)
width = len(lines[0])
for s in lines:
i = re.search(r'\S',s).start()
if i < width: width = i
# Strip margin width from all lines.
for i in range(len(lines)):
lines[i] = ' '*margin + lines[i][width:]
return lines
#---------------------------------------------------------------------------
# Document element classes parse AsciiDoc reader input and write DocBook writer
# output.
#---------------------------------------------------------------------------
评论列表
文章目录