From 55e3688097a28d88e43acf63c71f3d809f0fe652 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 May 2020 14:13:54 +0530 Subject: [PATCH] Comments editor: Add an action to the context menu to smarten punctuation. Fixes #1876381 [Feature request: Smarten punctuation in metadata](https://bugs.launchpad.net/calibre/+bug/1876381) --- src/calibre/gui2/comments_editor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index 4670a2b038..9ef8b468ce 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -805,6 +805,8 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{ if hasattr(parent, 'toolbars_visible'): vis = parent.toolbars_visible menu.addAction(_('%s toolbars') % (_('Hide') if vis else _('Show')), parent.toggle_toolbars) + menu.addSeparator() + menu.addAction(_('Smarten punctuation'), parent.smarten_punctuation) menu.exec_(ev.globalPos()) # }}} @@ -1192,6 +1194,13 @@ class Editor(QWidget): # {{{ def hide_tabs(self): self.tabs.tabBar().setVisible(False) + def smarten_punctuation(self): + from calibre.ebooks.conversion.preprocess import smarten_punctuation + html = self.html + newhtml = smarten_punctuation(html) + if html != newhtml: + self.html = newhtml + # }}}