diff --git a/gramps/plugins/docgen/odfdoc.py b/gramps/plugins/docgen/odfdoc.py index 692850e12..0c6f1e1ac 100644 --- a/gramps/plugins/docgen/odfdoc.py +++ b/gramps/plugins/docgen/odfdoc.py @@ -1520,14 +1520,15 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): linenb += 1 self.end_paragraph() - def write_text(self, text, mark=None, links=False): + def write_text(self, text, mark=None, links=False, markup=False): """ Uses the xml.sax.saxutils.escape function to convert XML entities. The ESC_MAP dictionary allows us to add our own mappings. @param mark: IndexMark to use for indexing """ - text = escape(text, ESC_MAP) + if not markup: + text = escape(text, ESC_MAP) if links is True: text = re.sub(URL_PATTERN, _CLICKABLE, text) @@ -1536,6 +1537,19 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): self.cntnt.write(text) + def write_markup(self, text, s_tags, mark=None): + """ + Writes the text in the current paragraph. Should only be used after a + start_paragraph and before an end_paragraph. + + @param text: text to write. The text is assumed to be _not_ escaped + @param s_tags: assumed to be list of styledtexttags to apply to the + text + @param mark: IndexMark to use for indexing + """ + markuptext = self._backend.add_markup_from_styled(text, s_tags) + self.write_text(markuptext, mark=mark, markup=True) + def _write_mark(self, mark, text): """ Insert a mark at this point in the document.