handle ascii_formatting option in htmltextview
This commit is contained in:
parent
aa3c02efcd
commit
c6660b875f
1 changed files with 10 additions and 3 deletions
|
@ -220,6 +220,7 @@ def build_patterns(view, config, interface):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
view.emot_pattern_re = re.compile(emoticons_pattern, re.IGNORECASE)
|
||||||
# because emoticons match later (in the string) they need to be after
|
# because emoticons match later (in the string) they need to be after
|
||||||
# basic matches that may occur earlier
|
# basic matches that may occur earlier
|
||||||
emot_and_basic_pattern = basic_pattern + emoticons_pattern
|
emot_and_basic_pattern = basic_pattern + emoticons_pattern
|
||||||
|
@ -732,10 +733,16 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
def handle_specials(self, text):
|
def handle_specials(self, text):
|
||||||
index = 0
|
index = 0
|
||||||
se = self.textview.config.get('show_ascii_formatting_chars')
|
se = self.textview.config.get('show_ascii_formatting_chars')
|
||||||
|
af = gajim.config.get('ascii_formatting')
|
||||||
if self.textview.config.get('emoticons_theme'):
|
if self.textview.config.get('emoticons_theme'):
|
||||||
|
if af:
|
||||||
iterator = self.textview.emot_and_basic_re.finditer(text)
|
iterator = self.textview.emot_and_basic_re.finditer(text)
|
||||||
else:
|
else:
|
||||||
|
iterator = self.textview.emot_pattern_re.finditer(text)
|
||||||
|
elif af:
|
||||||
iterator = self.textview.basic_pattern_re.finditer(text)
|
iterator = self.textview.basic_pattern_re.finditer(text)
|
||||||
|
else:
|
||||||
|
iterator = []
|
||||||
for match in iterator:
|
for match in iterator:
|
||||||
start, end = match.span()
|
start, end = match.span()
|
||||||
special_text = text[start:end]
|
special_text = text[start:end]
|
||||||
|
@ -754,7 +761,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
img.show()
|
img.show()
|
||||||
# TODO: add alt/tooltip with the special_text (a11y)
|
# TODO: add alt/tooltip with the special_text (a11y)
|
||||||
self.textview.add_child_at_anchor(img, anchor)
|
self.textview.add_child_at_anchor(img, anchor)
|
||||||
else:
|
elif af:
|
||||||
# now print it
|
# now print it
|
||||||
if special_text.startswith('/'): # it's explicit italics
|
if special_text.startswith('/'): # it's explicit italics
|
||||||
self.startElement('i', {})
|
self.startElement('i', {})
|
||||||
|
|
Loading…
Add table
Reference in a new issue