Commit 88f00992 authored by Chris McDonough's avatar Chris McDonough

When operating on raw strings which had DOS-style linefeeds (e.g. "\r\n"),...

When operating on raw strings which had DOS-style linefeeds (e.g. "\r\n"), StructuredText would neglect to strip the trailing garbage off the end of a paragraph.  Thus, the test for "examples" and other features that depended on the last characters in a paragraph to not be whitespace for proper operation were failing, causing problems mainly for people who use Windows to author STX content.  This is now fixed.
parent 66ea9597
......@@ -90,10 +90,12 @@ def findlevel(levels,indent):
highest = key
return highest-1
para_delim = r'(\n\s*\n|\r\n\s*\r\n)' # UNIX or DOS line endings, respectively
#####################################################################
# Golly, the capitalization of this function always makes me think it's a class
def StructuredText(paragraphs, paragraph_delimiter=re.compile('\n\s*\n')):
def StructuredText(paragraphs, delimiter=re.compile(para_delim)):
"""
StructuredText accepts paragraphs, which is a list of
lines to be parsed. StructuredText creates a structure
......@@ -107,12 +109,12 @@ def StructuredText(paragraphs, paragraph_delimiter=re.compile('\n\s*\n')):
level = 0 # which header are we under
struct = [] # the structure to be returned
run = struct
paragraphs = filter(
strip,
paragraph_delimiter.split(expandtabs('\n\n'+paragraphs+'\n\n'))
)
paragraphs = expandtabs(paragraphs)
paragraphs = '%s%s%s' % ('\n\n', paragraphs, '\n\n')
paragraphs = delimiter.split(paragraphs)
paragraphs = filter(strip, paragraphs)
if not paragraphs: return StructuredTextDocument()
ind = [] # structure based on indention levels
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment