mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
add config option to turn off html stripping
This commit is contained in:
parent
1b2f44d29b
commit
c92a00d90b
4 changed files with 19 additions and 6 deletions
|
@ -98,6 +98,7 @@ class Config(dict):
|
||||||
'sortIndex': 0,
|
'sortIndex': 0,
|
||||||
'splitQA': True,
|
'splitQA': True,
|
||||||
'standaloneWindows': True,
|
'standaloneWindows': True,
|
||||||
|
'stripHTML': True,
|
||||||
'studyOptionsScreen': 0,
|
'studyOptionsScreen': 0,
|
||||||
'suppressEstimates': False,
|
'suppressEstimates': False,
|
||||||
'suppressUpdate': False,
|
'suppressUpdate': False,
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ class FactEdit(QTextEdit):
|
||||||
if source.hasHtml() and "qrichtext" in unicode(source.html()):
|
if source.hasHtml() and "qrichtext" in unicode(source.html()):
|
||||||
self.insertHtml(source.html())
|
self.insertHtml(source.html())
|
||||||
return
|
return
|
||||||
if source.hasText():
|
if source.hasText() and ankiqt.mw.config['stripHTML']:
|
||||||
txt = unicode(source.text())
|
txt = unicode(source.text())
|
||||||
l = txt.lower()
|
l = txt.lower()
|
||||||
if l.startswith("http://") or l.startswith("file://"):
|
if l.startswith("http://") or l.startswith("file://"):
|
||||||
|
@ -1095,6 +1095,8 @@ class FactEdit(QTextEdit):
|
||||||
|
|
||||||
def simplifyHTML(self, html):
|
def simplifyHTML(self, html):
|
||||||
"Remove all style information and P tags."
|
"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("<br ?/?>", "\n", html)
|
html = re.sub("<br ?/?>", "\n", html)
|
||||||
html = re.sub("<p ?/?>", "\n\n", html)
|
html = re.sub("<p ?/?>", "\n\n", html)
|
||||||
|
|
|
@ -218,6 +218,7 @@ class Preferences(QDialog):
|
||||||
self.dialog.openLastDeck.setChecked(self.config['loadLastDeck'])
|
self.dialog.openLastDeck.setChecked(self.config['loadLastDeck'])
|
||||||
self.dialog.deckBrowserOrder.setChecked(self.config['deckBrowserOrder'])
|
self.dialog.deckBrowserOrder.setChecked(self.config['deckBrowserOrder'])
|
||||||
self.dialog.deleteMedia.setChecked(self.config['deleteMedia'])
|
self.dialog.deleteMedia.setChecked(self.config['deleteMedia'])
|
||||||
|
self.dialog.stripHTML.setChecked(self.config['stripHTML'])
|
||||||
self.dialog.deckBrowserLen.setValue(self.config['deckBrowserNameLength'])
|
self.dialog.deckBrowserLen.setValue(self.config['deckBrowserNameLength'])
|
||||||
|
|
||||||
def updateAdvanced(self):
|
def updateAdvanced(self):
|
||||||
|
@ -232,6 +233,7 @@ class Preferences(QDialog):
|
||||||
self.config['alternativeTheme'] = self.dialog.alternativeTheme.isChecked()
|
self.config['alternativeTheme'] = self.dialog.alternativeTheme.isChecked()
|
||||||
self.config['showProgress'] = self.dialog.showProgress.isChecked()
|
self.config['showProgress'] = self.dialog.showProgress.isChecked()
|
||||||
self.config['preventEditUntilAnswer'] = self.dialog.preventEdits.isChecked()
|
self.config['preventEditUntilAnswer'] = self.dialog.preventEdits.isChecked()
|
||||||
|
self.config['stripHTML'] = self.dialog.stripHTML.isChecked()
|
||||||
self.config['loadLastDeck'] = self.dialog.openLastDeck.isChecked()
|
self.config['loadLastDeck'] = self.dialog.openLastDeck.isChecked()
|
||||||
if self.dialog.deckBrowserOrder.isChecked():
|
if self.dialog.deckBrowserOrder.isChecked():
|
||||||
self.config['deckBrowserOrder'] = 1
|
self.config['deckBrowserOrder'] = 1
|
||||||
|
|
|
@ -548,7 +548,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QCheckBox" name="showStudyOptions">
|
<widget class="QCheckBox" name="showStudyOptions">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show study options on deck load</string>
|
<string>Show study options on deck load</string>
|
||||||
|
@ -562,28 +562,28 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="11" column="0">
|
||||||
<widget class="QCheckBox" name="addZeroSpace">
|
<widget class="QCheckBox" name="addZeroSpace">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add hidden char to text (fixes Thai on OSX)</string>
|
<string>Add hidden char to text (fixes Thai on OSX)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QCheckBox" name="openLastDeck">
|
<widget class="QCheckBox" name="openLastDeck">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Always open last deck on startup</string>
|
<string>Always open last deck on startup</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QCheckBox" name="deckBrowserOrder">
|
<widget class="QCheckBox" name="deckBrowserOrder">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show decks with cards due first in browser</string>
|
<string>Show decks with cards due first in browser</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="10" column="0">
|
||||||
<widget class="QCheckBox" name="deleteMedia">
|
<widget class="QCheckBox" name="deleteMedia">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Delete original media on add</string>
|
<string>Delete original media on add</string>
|
||||||
|
@ -597,6 +597,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QCheckBox" name="stripHTML">
|
||||||
|
<property name="text">
|
||||||
|
<string>Strip HTML when pasting text</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -711,6 +718,7 @@
|
||||||
<tabstop>colourTimes</tabstop>
|
<tabstop>colourTimes</tabstop>
|
||||||
<tabstop>showTimer</tabstop>
|
<tabstop>showTimer</tabstop>
|
||||||
<tabstop>showTray</tabstop>
|
<tabstop>showTray</tabstop>
|
||||||
|
<tabstop>stripHTML</tabstop>
|
||||||
<tabstop>showStudyOptions</tabstop>
|
<tabstop>showStudyOptions</tabstop>
|
||||||
<tabstop>openLastDeck</tabstop>
|
<tabstop>openLastDeck</tabstop>
|
||||||
<tabstop>deckBrowserOrder</tabstop>
|
<tabstop>deckBrowserOrder</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue