diff --git a/ankiqt/config.py b/ankiqt/config.py index 418b6e449..f58e4995d 100644 --- a/ankiqt/config.py +++ b/ankiqt/config.py @@ -98,6 +98,7 @@ class Config(dict): 'sortIndex': 0, 'splitQA': True, 'standaloneWindows': True, + 'stripHTML': True, 'studyOptionsScreen': 0, 'suppressEstimates': False, 'suppressUpdate': False, diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index b15ba5601..c943f1edc 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -1021,7 +1021,7 @@ class FactEdit(QTextEdit): if source.hasHtml() and "qrichtext" in unicode(source.html()): self.insertHtml(source.html()) return - if source.hasText(): + if source.hasText() and ankiqt.mw.config['stripHTML']: txt = unicode(source.text()) l = txt.lower() if l.startswith("http://") or l.startswith("file://"): @@ -1095,6 +1095,8 @@ class FactEdit(QTextEdit): def simplifyHTML(self, html): "Remove all style information and P tags." + if not ankiqt.mw.config['stripHTML']: + return html html = re.sub("\n", " ", html) html = re.sub("
", "\n", html) html = re.sub("

", "\n\n", html) diff --git a/ankiqt/ui/preferences.py b/ankiqt/ui/preferences.py index af2902b4c..30f78d10a 100644 --- a/ankiqt/ui/preferences.py +++ b/ankiqt/ui/preferences.py @@ -218,6 +218,7 @@ class Preferences(QDialog): self.dialog.openLastDeck.setChecked(self.config['loadLastDeck']) self.dialog.deckBrowserOrder.setChecked(self.config['deckBrowserOrder']) self.dialog.deleteMedia.setChecked(self.config['deleteMedia']) + self.dialog.stripHTML.setChecked(self.config['stripHTML']) self.dialog.deckBrowserLen.setValue(self.config['deckBrowserNameLength']) def updateAdvanced(self): @@ -232,6 +233,7 @@ class Preferences(QDialog): self.config['alternativeTheme'] = self.dialog.alternativeTheme.isChecked() self.config['showProgress'] = self.dialog.showProgress.isChecked() self.config['preventEditUntilAnswer'] = self.dialog.preventEdits.isChecked() + self.config['stripHTML'] = self.dialog.stripHTML.isChecked() self.config['loadLastDeck'] = self.dialog.openLastDeck.isChecked() if self.dialog.deckBrowserOrder.isChecked(): self.config['deckBrowserOrder'] = 1 diff --git a/designer/preferences.ui b/designer/preferences.ui index ab4f43fa6..a30268e37 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -548,7 +548,7 @@ - + Show study options on deck load @@ -562,28 +562,28 @@ - + Add hidden char to text (fixes Thai on OSX) - + Always open last deck on startup - + Show decks with cards due first in browser - + Delete original media on add @@ -597,6 +597,13 @@ + + + + Strip HTML when pasting text + + + @@ -711,6 +718,7 @@ colourTimes showTimer showTray + stripHTML showStudyOptions openLastDeck deckBrowserOrder