diff --git a/src/gen/plug/docbackend/docbackend.py b/src/gen/plug/docbackend/docbackend.py index 88bf07f65..deacdf04d 100644 --- a/src/gen/plug/docbackend/docbackend.py +++ b/src/gen/plug/docbackend/docbackend.py @@ -341,15 +341,35 @@ class DocBackend(object): for opentag in opentags: otext += opentag[0] start = pos - #add remainder of text, no markup present there - otext += self.ESCAPE_FUNC()(text[start:end]) - - #opentags should be empty. If not, user gave tags on positions that - # are over the end of the text. Just close the tags still open + #add remainder of text, no markup present there if all is correct if opentags: + # a problem, we don't have a closing tag left but there are open + # tags. Just keep them up to end of text + pos = len(text) print 'WARNING: DocBackend : More style tags in text than length '\ 'of text allows.\n', opentags + if pos > start: + if split: + #make sure text can split + splitpos = text[start:pos].find(split) + while splitpos != -1: + otext += self.ESCAPE_FUNC()(text[start:start+splitpos]) + #close open tags + for opentag in reversed(opentags): + otext += opentag[1] + #add split text + otext += self.ESCAPE_FUNC()(split) + #open the tags again + for opentag in opentags: + otext += opentag[0] + #obtain new values + start = start + splitpos + lensplit + splitpos = text[start:pos].find(split) + + otext += self.ESCAPE_FUNC()(text[start:pos]) for opentag in reversed(opentags): otext += opentag[1] - + else: + otext += self.ESCAPE_FUNC()(text[start:end]) + return otext diff --git a/src/plugins/docgen/ODFDoc.py b/src/plugins/docgen/ODFDoc.py index 11d41df3d..a491744da 100644 --- a/src/plugins/docgen/ODFDoc.py +++ b/src/plugins/docgen/ODFDoc.py @@ -1222,9 +1222,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): """ text = str(styledtext) s_tags = styledtext.get_tags() - text = text.replace('&', '\1') # must be the first - text = text.replace('<', '\2') - text = text.replace('>', '\3') markuptext = self._backend.add_markup_from_styled(text, s_tags, '\n') # we need to know if we have new styles to add. # if markuptext contains : FontColor, FontFace, FontSize ... @@ -1243,9 +1240,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): start = m.end() linenb = 1 self.start_paragraph(style_name) - markuptext = markuptext.replace('\1', '&') # must be the first - markuptext = markuptext.replace('\2', '<') - markuptext = markuptext.replace('\3', '>') for line in markuptext.split('\n'): [line, sigcount] = process_spaces(line, format) if sigcount == 0: diff --git a/src/plugins/lib/libodfbackend.py b/src/plugins/lib/libodfbackend.py index 8470e4958..e4c4b9b8c 100644 --- a/src/plugins/lib/libodfbackend.py +++ b/src/plugins/lib/libodfbackend.py @@ -61,7 +61,13 @@ LOG = logging.getLogger(".odfbackend.py") def _escape(string): """ a write to the file + """""" + change text in text that latex shows correctly + special characters: & < and > """ + string = string.replace('&', '&') # must be the first + string = string.replace('<', '<') + string = string.replace('>', '>') return string class OdfBackend(DocBackend):