Move series onto same line as authors in FTS cards

This commit is contained in:
Kovid Goyal 2026-03-16 09:35:18 +05:30
parent e927ee32fd
commit 840654cd38
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 6 deletions

View File

@ -169,8 +169,8 @@ class CardData:
series = ''
if s := self.results.series:
sidx = fmt_sidx(self.results.series_index or 0, use_roman=config['use_roman_numerals_for_series_number'])
series = _('{series_index} of {series}').format(series_index=sidx, series=s)
series = f'{prepare_string_for_xml(series)}<br>'
series = _('{series_index} of <i>{series}</i>').format(series_index=sidx, series=prepare_string_for_xml(s))
series = f' ({series})'
results = []
ftt = _('Open the book, in the {fmt} format.\nWhen using the calibre E-book viewer, it will attempt to scroll\n'
'to this search result automatically.')
@ -187,11 +187,12 @@ class CardData:
ftxt = '\xa0'.join(fmts)
results.append(f'<br>{ftxt} {text}')
pal = QApplication.instance().palette()
accent = pal.color(QPalette.ColorRole.Accent).name()
html = f'''
<img src="card://thumb" width="{sz.width()}" height="{sz.height()}" align="left" /><div style="margin: 0">
<big><b>{prepare_string_for_xml(self.results.title)}</b></big><br>
{prepare_string_for_xml(authors_to_string(self.results.authors))}<br>
{series}
<span style="color: {accent}">{prepare_string_for_xml(authors_to_string(self.results.authors))}</span>{series}<br>
{button_line(self.results.book_id, self.results.book_in_db)}
<br>
{'<br>'.join(results)}

View File

@ -18,13 +18,13 @@ def get_db():
return get_gui().current_db.new_api
def markup_text(text: str) -> str:
def markup_text(text: str, open_tag: str = '<b><i>', close_tag: str = '</i></b>') -> str:
closing = False
def sub(m):
nonlocal closing
closing = not closing
return '<b><i>' if closing else '</i></b>'
return open_tag if closing else close_tag
return re.sub(r'\x1d', sub, prepare_string_for_xml(text))