Do not rely on translators getting the trailing spaces right when rendering the series name

This commit is contained in:
Kovid Goyal 2017-05-25 08:13:20 +05:30
parent ad1c1e7575
commit 8c07e979dd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 7 additions and 6 deletions

View File

@ -249,9 +249,10 @@ def render_metadata(mi, table, book_id): # {{{
ival = 1.0 ival = 1.0
ival = fmt_sidx(ival, use_roman=interface_data.use_roman_numerals_for_series_number) ival = fmt_sidx(ival, use_roman=interface_data.use_roman_numerals_for_series_number)
table.appendChild(E.tr(E.td(name + ':'), E.td())) table.appendChild(E.tr(E.td(name + ':'), E.td()))
table.lastChild.lastChild.appendChild(E.span(ival, _(' of '), E.a( s = safe_set_inner_html(E.span(), _('{0} of <a>{1}</a>').format(ival, val))
href=href_for_search(field, val), s.lastChild.setAttribute('href', href_for_search(field, val))
title=_('Click to see books with {0}: {1}').format(name, val), val))) s.lastChild.setAttribute('title', _('Click to see books with {0}: {1}').format(name, val))
table.lastChild.lastChild.appendChild(s)
def process_field(field, fm): def process_field(field, fm):
name = fm.name or field name = fm.name or field

View File

@ -7,7 +7,7 @@ from gettext import gettext as _
from dom import build_rule, clear, set_css, svgicon from dom import build_rule, clear, set_css, svgicon
from session import get_interface_data from session import get_interface_data
from utils import fmt_sidx, sandboxed_html from utils import fmt_sidx, sandboxed_html, safe_set_inner_html
DETAILS_LIST_CLASS = 'book-list-details-list' DETAILS_LIST_CLASS = 'book-list-details-list'
ITEM_CLASS = DETAILS_LIST_CLASS + '-item' ITEM_CLASS = DETAILS_LIST_CLASS + '-item'
@ -85,7 +85,7 @@ def create_item(book_id, metadata, create_image, show_book_details):
except Exception: except Exception:
ival = 1.0 ival = 1.0
ival = fmt_sidx(ival, use_roman=interface_data.use_roman_numerals_for_series_number) ival = fmt_sidx(ival, use_roman=interface_data.use_roman_numerals_for_series_number)
extra_data.appendChild(E.span(ival, ' ' + _('of') + ' ', E.i(metadata.series))) extra_data.appendChild(safe_set_inner_html(E.span(), _('{0} of <i>{1}</i>').format(ival, metadata.series)))
right = E.div( right = E.div(
class_='details-list-right', class_='details-list-right',
E.div(style='display:flex; justify-content: space-between; overflow: hidden', E.div(style='display:flex; justify-content: space-between; overflow: hidden',

View File

@ -215,7 +215,7 @@ def simple_markup(html):
div.textContent = html div.textContent = html
html = div.innerHTML html = div.innerHTML
return html.replace(/\uffff(\/?[a-z1-6]+)\uffff/g, '<$1>') return html.replace(/\uffff(\/?[a-z1-6]+)\uffff/g, '<$1>')
simple_markup.allowed_tags = v"'b|i|br|h1|h2|h3|h4|h5|h6|div|em|strong|span'.split('|')" simple_markup.allowed_tags = v"'a|b|i|br|h1|h2|h3|h4|h5|h6|div|em|strong|span'.split('|')"
def safe_set_inner_html(elem, html): def safe_set_inner_html(elem, html):