summaryrefslogtreecommitdiff
path: root/statemachine.py
diff options
context:
space:
mode:
authorgoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2002-10-02 03:20:00 +0000
committergoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2002-10-02 03:20:00 +0000
commit0948cf353e07d37a465325f6eb0ebd4d8e9204c2 (patch)
tree8725e98e5c3c398732aef4ee3d11b1264d78b97b /statemachine.py
parent6ebf013119e5e3db7882393fb34df0c2bc23a8d0 (diff)
downloaddocutils-0948cf353e07d37a465325f6eb0ebd4d8e9204c2.tar.gz
Added ``strip_top`` parameter to ``StateMachineWS.get_first_known_indented``.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils/docutils@746 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'statemachine.py')
-rw-r--r--statemachine.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/statemachine.py b/statemachine.py
index cc5514808..63f35c741 100644
--- a/statemachine.py
+++ b/statemachine.py
@@ -814,7 +814,8 @@ class StateMachineWS(StateMachine):
offset += 1
return indented, offset, blank_finish
- def get_first_known_indented(self, indent, until_blank=0, strip_indent=1):
+ def get_first_known_indented(self, indent, until_blank=0, strip_indent=1,
+ strip_top=1):
"""
Return an indented block and info.
@@ -827,6 +828,7 @@ class StateMachineWS(StateMachine):
(1).
- `strip_indent`: Strip `indent` characters of indentation if true
(1, default).
+ - `strip_top`: Strip blank lines from the beginning of the block.
:Return:
- the indented block,
@@ -840,9 +842,10 @@ class StateMachineWS(StateMachine):
self.input_lines[self.line_offset + 1:], until_blank,
strip_indent)
self.next_line(len(indented) - 1) # advance to last indented line
- while indented and not indented[0].strip():
- indented.pop(0)
- offset += 1
+ if strip_top:
+ while indented and not indented[0].strip():
+ indented.pop(0)
+ offset += 1
return indented, indent, offset, blank_finish