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)

This commit is contained in:
Kovid Goyal 2020-05-10 14:13:54 +05:30
parent a8649d2e96
commit 55e3688097
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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
# }}}