mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix the subitems formatter function to split only when the period is surrounded by non-white space and not another period
This commit is contained in:
commit
a9b701d685
@ -717,15 +717,23 @@ class BuiltinSubitems(BuiltinFormatterFunction):
|
||||
return ''
|
||||
si = int(start_index)
|
||||
ei = int(end_index)
|
||||
has_periods = '.' in val
|
||||
items = [v.strip() for v in val.split(',')]
|
||||
rv = set()
|
||||
if has_periods:
|
||||
pp = re.compile(r'(?<=[^\.\s])\.(?=[^\.\s])', re.U)
|
||||
else:
|
||||
pp = None
|
||||
for item in items:
|
||||
component = item.split('.')
|
||||
if has_periods and '.' in item:
|
||||
components = pp.split(item)
|
||||
else:
|
||||
components = [item]
|
||||
try:
|
||||
if ei == 0:
|
||||
rv.add('.'.join(component[si:]))
|
||||
rv.add('.'.join(components[si:]))
|
||||
else:
|
||||
rv.add('.'.join(component[si:ei]))
|
||||
rv.add('.'.join(components[si:ei]))
|
||||
except:
|
||||
pass
|
||||
return ', '.join(sorted(rv, key=sort_key))
|
||||
|
Loading…
x
Reference in New Issue
Block a user