mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Micro optimization
This commit is contained in:
parent
f3f244c41b
commit
b900419810
@ -95,6 +95,7 @@ def comments_to_html(comments):
|
|||||||
open_pTag = False
|
open_pTag = False
|
||||||
|
|
||||||
all_tokens = list(soup.contents)
|
all_tokens = list(soup.contents)
|
||||||
|
inline_tags = ('br', 'b', 'i', 'em', 'strong', 'span', 'font', 'a', 'hr')
|
||||||
for token in all_tokens:
|
for token in all_tokens:
|
||||||
if isinstance(token, (CData, Comment, Declaration, ProcessingInstruction)):
|
if isinstance(token, (CData, Comment, Declaration, ProcessingInstruction)):
|
||||||
continue
|
continue
|
||||||
@ -105,8 +106,7 @@ def comments_to_html(comments):
|
|||||||
ptc = 0
|
ptc = 0
|
||||||
pTag.insert(ptc, token)
|
pTag.insert(ptc, token)
|
||||||
ptc += 1
|
ptc += 1
|
||||||
elif token.name in ['br', 'b', 'i', 'em', 'strong', 'span', 'font', 'a',
|
elif token.name in inline_tags:
|
||||||
'hr']:
|
|
||||||
if not open_pTag:
|
if not open_pTag:
|
||||||
pTag = result.new_tag('p')
|
pTag = result.new_tag('p')
|
||||||
open_pTag = True
|
open_pTag = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user