mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix newlines not being matched by the "Search ignoring markup" tool. Fixes #1649383 [Search ignoring HTML markup in book editor ignores "Dot all"](https://bugs.launchpad.net/calibre/+bug/1649383)
This commit is contained in:
parent
e1a0e184c7
commit
6d2d835265
@ -250,6 +250,7 @@ def ensure_not_within_tag_definition(cursor, forward=True):
|
||||
|
||||
return False
|
||||
|
||||
|
||||
BLOCK_TAG_NAMES = frozenset((
|
||||
'address', 'article', 'aside', 'blockquote', 'center', 'dir', 'fieldset',
|
||||
'isindex', 'menu', 'noframes', 'hgroup', 'noscript', 'pre', 'section',
|
||||
@ -294,6 +295,7 @@ def set_style_property(tag, property_name, value, editor):
|
||||
d.setProperty(property_name, value)
|
||||
c.insertText('"%s"' % css(d))
|
||||
|
||||
|
||||
entity_pat = re.compile(r'&(#{0,1}[a-zA-Z0-9]{1,8});$')
|
||||
|
||||
|
||||
@ -700,6 +702,7 @@ class Smarts(NullSmarts):
|
||||
in_text = find_tag_definition(block, 0)[0] is None
|
||||
|
||||
def append(text, start):
|
||||
text = text.replace(PARAGRAPH_SEPARATOR, '\n')
|
||||
after = start + len(text)
|
||||
if start <= cend and cstart < after:
|
||||
extra = after - (cend + 1)
|
||||
@ -715,9 +718,8 @@ class Smarts(NullSmarts):
|
||||
if not boundaries:
|
||||
# Add the whole line
|
||||
if in_text:
|
||||
text = block.text()
|
||||
if text:
|
||||
append(text, block.position())
|
||||
text = block.text() + '\n'
|
||||
append(text, block.position())
|
||||
else:
|
||||
start = block.position()
|
||||
c.setPosition(start)
|
||||
@ -733,11 +735,12 @@ class Smarts(NullSmarts):
|
||||
c.setPosition(block.position() + boundaries[-1].offset + 1)
|
||||
c.movePosition(c.EndOfBlock, c.KeepAnchor)
|
||||
if c.hasSelection():
|
||||
append(c.selectedText(), c.anchor())
|
||||
append(c.selectedText() + '\n', c.anchor())
|
||||
block = block.next()
|
||||
s, e = find_text_in_chunks(pat, chunks)
|
||||
return s != -1 and e != -1, s, e
|
||||
|
||||
|
||||
if __name__ == '__main__': # {{{
|
||||
from calibre.gui2.tweak_book.editor.widget import launch_editor
|
||||
if sys.argv[-1].endswith('.html'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user