mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
ff2cbe76a0
@ -712,6 +712,8 @@ class BuiltinSubitems(BuiltinFormatterFunction):
|
|||||||
'value of "A.B.C, D.E.F", {#genre:subitems(0,1)} returns "A, D". '
|
'value of "A.B.C, D.E.F", {#genre:subitems(0,1)} returns "A, D". '
|
||||||
'{#genre:subitems(0,2)} returns "A.B, D.E"')
|
'{#genre:subitems(0,2)} returns "A.B, D.E"')
|
||||||
|
|
||||||
|
period_pattern = re.compile(r'(?<=[^\.\s])\.(?=[^\.\s])', re.U)
|
||||||
|
|
||||||
def evaluate(self, formatter, kwargs, mi, locals, val, start_index, end_index):
|
def evaluate(self, formatter, kwargs, mi, locals, val, start_index, end_index):
|
||||||
if not val:
|
if not val:
|
||||||
return ''
|
return ''
|
||||||
@ -720,13 +722,9 @@ class BuiltinSubitems(BuiltinFormatterFunction):
|
|||||||
has_periods = '.' in val
|
has_periods = '.' in val
|
||||||
items = [v.strip() for v in val.split(',')]
|
items = [v.strip() for v in val.split(',')]
|
||||||
rv = set()
|
rv = set()
|
||||||
if has_periods:
|
|
||||||
pp = re.compile(r'(?<=[^\.\s])\.(?=[^\.\s])', re.U)
|
|
||||||
else:
|
|
||||||
pp = None
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if has_periods and '.' in item:
|
if has_periods and '.' in item:
|
||||||
components = pp.split(item)
|
components = self.period_pattern.split(item)
|
||||||
else:
|
else:
|
||||||
components = [item]
|
components = [item]
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user