3815: Notes with html show verbatim in narrative web

svn: r15168
This commit is contained in:
Benny Malengier
2010-04-16 20:58:51 +00:00
parent 387e9537a5
commit 99e8b2bb31
15 changed files with 107 additions and 29 deletions

View File

@@ -69,7 +69,7 @@ log = logging.getLogger(".WebPage")
from gen.ggettext import sgettext as _
import gen.lib
from gen.lib import UrlType, EventType, Person, date, Date, ChildRefType, \
FamilyRelType, NameType, Name
FamilyRelType, NameType, Name, NoteType
import const
import Sort
from gen.plug.menu import PersonOption, NumberOption, StringOption, \
@@ -364,7 +364,8 @@ class BasePage(object):
# styled notes
htmlnotetext = self.styled_note(note.get_styledtext(),
note.get_format())
note.get_format(), contains_html =
note.get_type() == NoteType.HTML_CODE)
text = htmlnotetext or Html("p", note_text)
# return text of the note to its callers
@@ -377,9 +378,9 @@ class BasePage(object):
#
#################################################
def styled_note(self, styledtext, format):
def styled_note(self, styledtext, format, contains_html=False):
"""
styledtext : assumed a StyledText object to write
styledtext : assumed a StyledText object to write
format : = 0 : Flowed, = 1 : Preformatted
style_name : name of the style to use for default presentation
"""
@@ -393,7 +394,9 @@ class BasePage(object):
markuptext = self._backend.add_markup_from_styled(text, s_tags,
split='\n\n')
htmllist = Html("div", id = "grampsstylednote")
if format == 1:
if contains_html:
htmllist.extend((Html('p') + text))
elif format == 1:
#preformatted, retain whitespace.
#so use \n\n for paragraph detection
htmllist += Html("pre", indent=None) + markuptext.split('\n\n')
@@ -1466,7 +1469,8 @@ class BasePage(object):
# Web Site address
elif _type == UrlType.WEB_HOME:
if not uri.startswith("http://"):
if not (uri.startswith("http://") or
uri.startswith("https://")):
uri = "http://%(website)s" % { "website" : uri }
# FTP server address