From 5fd1963855c5c66afb5f5edb8c6e1843455378a7 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 7 Jan 2014 10:35:30 -0500 Subject: [PATCH] 7357: Adding link to a "Html code" note using the "Link" button has no effect --- gramps/gen/plug/docbackend/docbackend.py | 10 +++++++--- gramps/plugins/webreport/narrativeweb.py | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gramps/gen/plug/docbackend/docbackend.py b/gramps/gen/plug/docbackend/docbackend.py index c601fe427..481c1ee78 100644 --- a/gramps/gen/plug/docbackend/docbackend.py +++ b/gramps/gen/plug/docbackend/docbackend.py @@ -107,7 +107,7 @@ class DocBackend(object): SUPPORTED_MARKUP = [] - ESCAPE_FUNC = lambda x: noescape + ESCAPE_FUNC = lambda: noescape #Map between styletypes and internally used values. This map is needed # to make TextDoc officially independant of gen.lib.styledtexttag STYLETYPE_MAP = { @@ -263,7 +263,7 @@ class DocBackend(object): return None return ('', '') - def add_markup_from_styled(self, text, s_tags, split=''): + def add_markup_from_styled(self, text, s_tags, split='', escape=True): """ Input is plain text, output is text with markup added according to the s_tags which are assumed to be styledtexttags. @@ -287,6 +287,9 @@ class DocBackend(object): is text here not overwrite this method if this complexity is not needed. """ + if not escape: + escape_func = self.ESCAPE_FUNC + self.ESCAPE_FUNC = lambda: (lambda text: text) #unicode text must be sliced correctly text = cuni(text) FIRST = 0 @@ -378,7 +381,8 @@ class DocBackend(object): otext += opentag[1] else: otext += self.ESCAPE_FUNC()(text[start:end]) - + if not escape: + self.ESCAPE_FUNC = escape_func return otext def format_link(self, value): diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 1b6b094e5..6273f10ee 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -918,12 +918,17 @@ class BasePage(object): return '' s_tags = styledtext.get_tags() - markuptext = self._backend.add_markup_from_styled(text, s_tags, - split='\n') htmllist = Html("div", class_="grampsstylednote") if contains_html: - htmllist += text + markuptext = self._backend.add_markup_from_styled(text, + s_tags, + split='\n', + escape=False) + htmllist += markuptext else: + markuptext = self._backend.add_markup_from_styled(text, + s_tags, + split='\n') linelist = [] linenb = 1 for line in markuptext.split('\n'):