Better output of pre- and unformatted notes and of end notes references.
svn: r14097
This commit is contained in:
parent
517a5e3c90
commit
e18dd1d560
@ -234,16 +234,25 @@ class AsciiDoc(BaseDoc,TextDoc):
|
|||||||
# If we have a leader then we need to reformat the text
|
# If we have a leader then we need to reformat the text
|
||||||
# as if there's no special treatment for the first line.
|
# as if there's no special treatment for the first line.
|
||||||
# Then add leader and eat up the beginning of the first line pad.
|
# Then add leader and eat up the beginning of the first line pad.
|
||||||
start_at = regular_indent + min(len(self.leader)+first_indent,0)
|
# Do not reformat if preformatted notes
|
||||||
this_text = reformat_para(self.text,regular_indent,right,fmt,
|
if not self.__note_format:
|
||||||
right_pad)
|
start_at = regular_indent + min(len(self.leader)+first_indent,0)
|
||||||
this_text = ' '*(regular_indent+first_indent) + \
|
this_text = reformat_para(self.text,regular_indent,right,fmt,
|
||||||
self.leader + this_text[start_at:]
|
right_pad)
|
||||||
|
this_text = ' '*(regular_indent+first_indent) + \
|
||||||
|
self.leader + this_text[start_at:]
|
||||||
|
else:
|
||||||
|
this_text = self.text
|
||||||
else:
|
else:
|
||||||
# If no leader then reformat the text according to the first
|
# If no leader then reformat the text according to the first
|
||||||
# line indent, as specified by style.
|
# line indent, as specified by style.
|
||||||
this_text = reformat_para(self.text,regular_indent,right,fmt,
|
# Do not reformat if preformatted notes
|
||||||
|
if not self.__note_format:
|
||||||
|
this_text = reformat_para(self.text,regular_indent,right,fmt,
|
||||||
right_pad,first_indent)
|
right_pad,first_indent)
|
||||||
|
else:
|
||||||
|
this_text = self.text
|
||||||
|
|
||||||
if self.__note_format:
|
if self.__note_format:
|
||||||
# don't add an extra LF before the_pad if preformatted notes.
|
# don't add an extra LF before the_pad if preformatted notes.
|
||||||
if this_text != '\n':
|
if this_text != '\n':
|
||||||
@ -355,19 +364,18 @@ class AsciiDoc(BaseDoc,TextDoc):
|
|||||||
|
|
||||||
def write_styled_note(self,styledtext,format,style_name):
|
def write_styled_note(self,styledtext,format,style_name):
|
||||||
text = str(styledtext)
|
text = str(styledtext)
|
||||||
if format == 1:
|
if format:
|
||||||
# Preformatted note
|
#Preformatted note, keep all white spaces, tabs, LF's
|
||||||
self.__note_format = True
|
self.__note_format = True
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
# Add an extra LF after all lines in each preformatted note
|
# Add an extra empty para all lines in each preformatted note
|
||||||
self.__note_format = False
|
|
||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
self.write_text('\n')
|
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
elif format == 0:
|
self.__note_format = False
|
||||||
|
else:
|
||||||
for line in text.split('\n\n'):
|
for line in text.split('\n\n'):
|
||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
line = line.replace('\n',' ')
|
line = line.replace('\n',' ')
|
||||||
@ -379,16 +387,10 @@ class AsciiDoc(BaseDoc,TextDoc):
|
|||||||
"""
|
"""
|
||||||
Overwrite base method for lines of endnotes references
|
Overwrite base method for lines of endnotes references
|
||||||
"""
|
"""
|
||||||
self.__note_format = True
|
|
||||||
for line in text.split('\n'):
|
for line in text.split('\n'):
|
||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
# Add an extra LF after all lines in each preformatted note
|
|
||||||
self.__note_format = False
|
|
||||||
self.start_paragraph(style_name)
|
|
||||||
self.write_text('\n')
|
|
||||||
self.end_paragraph()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user