From 4c61274d09008cffd92b1b4472b447c312171a68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 21 Oct 2023 17:47:37 +0530 Subject: [PATCH] Qt comments editor add a margin for floating images Qt itself doesnt render it but it is rendered in the server --- src/calibre/gui2/comments_editor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index ea92518adf..734e785ca9 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -213,6 +213,13 @@ def cleanup_qt_markup(root): if ts: remove_margins(li, ts) remove_zero_indents(ts) + for img in root.xpath('//img[@style]'): + s = style_map.get(img) + if s: + if s == {'float': 'left'}: + s['margin-right'] = '0.5em' + elif s == {'float': 'right'}: + s['margin-left'] = '0.5em' for style in itervalues(style_map): filter_qt_styles(style) fw = style.get('font-weight')