Skip to content

Commit

Permalink
Edit book: When changing a paragraph to a heading if the cursor is ad…
Browse files Browse the repository at this point in the history
…jacent to a paragraph tag but not inside any tags other than body, use the adjacent tag
  • Loading branch information
kovidgoyal committed Sep 24, 2021
1 parent 932c37d commit 95fc272
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/calibre/gui2/tweak_book/editor/smarts/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ def rename_block_tag(self, editor, new_name):
tag = find_closest_containing_block_tag(block, offset)

if tag is not None:
if tag.name == 'body':
ntag = find_closest_containing_block_tag(block, offset + 1)
if ntag is not None and ntag.name != 'body':
tag = ntag
elif offset > 0:
ntag = find_closest_containing_block_tag(block, offset - 1)
if ntag is not None and ntag.name != 'body':
tag = ntag
closing_tag = find_closing_tag(tag)
if closing_tag is None:
return error_dialog(editor, _('Invalid HTML'), _(
Expand Down

0 comments on commit 95fc272

Please sign in to comment.