forked from openlp/openlp
Fix theme text weight and html tag cleanups
This commit is contained in:
parent
1e0d68016f
commit
1e86aa98ba
@ -116,6 +116,7 @@ body {
|
||||
else
|
||||
img.style.display = 'block';
|
||||
}
|
||||
|
||||
function show_blank(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
|
@ -169,7 +169,16 @@ class Renderer(object):
|
||||
doc.setDefaultFont(df)
|
||||
layout = doc.documentLayout()
|
||||
formatted = []
|
||||
shell = u'<p>%s</p>'
|
||||
if self._theme.font_main_weight == u'Bold' and \
|
||||
self._theme.font_main_italics:
|
||||
shell = u'{p}{st}{it}%s{/it}{/st}{/p}'
|
||||
elif self._theme.font_main_weight == u'Bold' and \
|
||||
not self._theme.font_main_italics:
|
||||
shell = u'{p}{st}%s{/st}{/p}'
|
||||
elif self._theme.font_main_italics:
|
||||
shell = u'{p}{it}%s{/it}{/p}'
|
||||
else:
|
||||
shell = u'{p}%s{/p}'
|
||||
temp_text = u''
|
||||
old_html_text = u''
|
||||
for line in text:
|
||||
|
@ -68,15 +68,49 @@ class RenderManager(object):
|
||||
self.themedata = None
|
||||
self.alertTab = None
|
||||
|
||||
# TODO make external and configurable
|
||||
self.html_expands = {
|
||||
u'{r}': u'<font color=red>',
|
||||
u'{b}': u'<font color=black>',
|
||||
u'{u}': u'<font color=blue>',
|
||||
u'{y}': u'<font color=yellow>',
|
||||
u'{g}': u'<font color=green>',
|
||||
u'{/}': u'</font>'
|
||||
}
|
||||
# TODO make external and configurable in alpha 4
|
||||
self.html_expands = []
|
||||
|
||||
self.html_expands.append({u'desc':u'Red',u'start tag':u'{r}', \
|
||||
u'start html':u'<font color=red>', \
|
||||
u'end tag':u'{/r}', u'end html':u'</font>', \
|
||||
u'protected':False})
|
||||
self.html_expands.append({u'desc':u'Black',u'start tag':u'{b}', \
|
||||
u'start html':u'<font color=black>', \
|
||||
u'end tag':u'{/b}', u'end html':u'</font>', \
|
||||
u'protected':False})
|
||||
self.html_expands.append({u'desc':u'Blue',u'start tag':u'{bl}', \
|
||||
u'start html':u'<font color=blue>', \
|
||||
u'end tag':u'{/bl}', u'end html':u'</font>', \
|
||||
u'protected':False})
|
||||
self.html_expands.append({u'desc':u'Yellow',u'start tag':u'{y}', \
|
||||
u'start html':u'<font color=yellow>', \
|
||||
u'end tag':u'{/y}', u'end html':u'</font>', \
|
||||
u'protected':False})
|
||||
self.html_expands.append({u'desc':u'Green',u'start tag':u'{g}', \
|
||||
u'start html':u'<font color=green>', \
|
||||
u'end tag':u'{/g}', u'end html':u'</font>', \
|
||||
u'protected':False})
|
||||
self.html_expands.append({u'desc':u'Superscript',u'start tag':u'{su}', \
|
||||
u'start html':u'<sup>', \
|
||||
u'end tag':u'{/su}', u'end html':u'</sup>', \
|
||||
u'protected':True})
|
||||
self.html_expands.append({u'desc':u'Subscript',u'start tag':u'{sb}', \
|
||||
u'start html':u'<sub>', \
|
||||
u'end tag':u'{/sb}', u'end html':u'</sub>', \
|
||||
u'protected':True})
|
||||
self.html_expands.append({u'desc':u'Paragraph',u'start tag':u'{p}', \
|
||||
u'start html':u'<p>', \
|
||||
u'end tag':u'{/p}', u'end html':u'</p>', \
|
||||
u'protected':True})
|
||||
self.html_expands.append({u'desc':u'Bold',u'start tag':u'{st}', \
|
||||
u'start html':u'<strong>', \
|
||||
u'end tag':u'{/st}', u'end html':u'</strong>', \
|
||||
u'protected':True})
|
||||
self.html_expands.append({u'desc':u'Italics',u'start tag':u'{it}', \
|
||||
u'start html':u'<em>', \
|
||||
u'end tag':u'{/it}', u'end html':u'</em>', \
|
||||
u'protected':True})
|
||||
|
||||
def update_display(self):
|
||||
"""
|
||||
@ -262,18 +296,18 @@ class RenderManager(object):
|
||||
"""
|
||||
Remove Tags from text for display
|
||||
"""
|
||||
text = text.replace(u'<br>', u'\n').replace(u'<p>', u'')\
|
||||
.replace(u'</p>', u'').replace(u'<sup>', u'')\
|
||||
.replace(u'</sup>', u'')
|
||||
for key, value in self.html_expands.iteritems():
|
||||
text = text.replace(key, u'')
|
||||
text = text.replace(u'<br>', u'\n')
|
||||
for tag in self.html_expands:
|
||||
text = text.replace(tag[u'start tag'], u'')
|
||||
text = text.replace(tag[u'end tag'], u'')
|
||||
return text
|
||||
|
||||
def expand(self, text):
|
||||
"""
|
||||
Expand tags fto HTML for display
|
||||
"""
|
||||
for key, value in self.html_expands.iteritems():
|
||||
text = text.replace(key, value)
|
||||
for tag in self.html_expands:
|
||||
text = text.replace(tag[u'start tag'], tag[u'start html'])
|
||||
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
||||
return text
|
||||
|
||||
|
@ -503,16 +503,16 @@ class BibleMediaItem(MediaManagerItem):
|
||||
dual_text = self._decodeQtObject(reference, 'dual_text')
|
||||
if self.parent.settings_tab.display_style == 1:
|
||||
verse_text = self.formatVerse(old_chapter, chapter, verse,
|
||||
u'<sup>(', u')</sup>')
|
||||
u'{su}(', u'){/su}')
|
||||
elif self.parent.settings_tab.display_style == 2:
|
||||
verse_text = self.formatVerse(old_chapter, chapter, verse,
|
||||
u'<sup>{', u'}</sup>')
|
||||
u'{su}{', u'}{/su}')
|
||||
elif self.parent.settings_tab.display_style == 3:
|
||||
verse_text = self.formatVerse(old_chapter, chapter, verse,
|
||||
u'<sup>[', u']</sup>')
|
||||
u'{su}[', u']{/su}')
|
||||
else:
|
||||
verse_text = self.formatVerse(old_chapter, chapter, verse,
|
||||
u'<sup>', u'</sup>')
|
||||
u'{su}', u'{/su}')
|
||||
old_chapter = chapter
|
||||
footer = u'%s (%s %s)' % (book, version, copyright)
|
||||
# If not found add to footer
|
||||
@ -572,7 +572,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
service_item.title = u'%s, %s' % (service_item.title,
|
||||
translate('BiblesPlugin.MediaItem', 'etc'))
|
||||
# item theme
|
||||
>>>>>>> MERGE-SOURCE
|
||||
if len(self.parent.settings_tab.bible_theme) == 0:
|
||||
service_item.theme = None
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user