Verified Commit 8e79f9f7 authored by André's avatar André

Use styling directives as recommended in XEP-0393

Remove style *underline* and add style *strikethrough*.

Fixes #7613.
parent 7056fecf
Pipeline #6655 passed with stages
in 4 minutes and 10 seconds
......@@ -194,8 +194,8 @@ def __init__(self, account, used_in_history_window=False):
tag = buffer_.create_tag('italic')
tag.set_property('style', Pango.Style.ITALIC)
tag = buffer_.create_tag('underline')
tag.set_property('underline', Pango.Underline.SINGLE)
tag = buffer_.create_tag('strikethrough')
tag.set_property('strikethrough', True)
buffer_.create_tag('focus-out-line', justification=Gtk.Justification.CENTER)
self.displaymarking_tags = {}
......@@ -692,46 +692,46 @@ def print_special_text(self, special_text, other_tags, graphics=True,
tags.append('sth_at_sth')
elif special_text.startswith('*'): # it's a bold text
tags.append('bold')
if special_text[1] == '/' and special_text[-2] == '/' and\
len(special_text) > 4: # it's also italic
tags.append('italic')
if special_text[1] == '~' and special_text[-2] == '~' and\
len(special_text) > 4: # it's also strikethrough
tags.append('strikethrough')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove */ /*
special_text = special_text[2:-2] # remove *~ ~*
elif special_text[1] == '_' and special_text[-2] == '_' and \
len(special_text) > 4: # it's also underlined
tags.append('underline')
len(special_text) > 4: # it's also italic
tags.append('italic')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove *_ _*
else:
if not show_ascii_formatting_chars:
special_text = special_text[1:-1] # remove * *
elif special_text.startswith('/'): # it's an italic text
tags.append('italic')
elif special_text.startswith('~'): # it's a strikethrough text
tags.append('strikethrough')
if special_text[1] == '*' and special_text[-2] == '*' and \
len(special_text) > 4: # it's also bold
tags.append('bold')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove /* */
special_text = special_text[2:-2] # remove ~* *~
elif special_text[1] == '_' and special_text[-2] == '_' and \
len(special_text) > 4: # it's also underlined
tags.append('underline')
len(special_text) > 4: # it's also italic
tags.append('italic')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove /_ _/
special_text = special_text[2:-2] # remove ~_ _~
else:
if not show_ascii_formatting_chars:
special_text = special_text[1:-1] # remove / /
elif special_text.startswith('_'): # it's an underlined text
tags.append('underline')
special_text = special_text[1:-1] # remove ~ ~
elif special_text.startswith('_'): # it's an italic text
tags.append('italic')
if special_text[1] == '*' and special_text[-2] == '*' and \
len(special_text) > 4: # it's also bold
tags.append('bold')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove _* *_
elif special_text[1] == '/' and special_text[-2] == '/' and \
len(special_text) > 4: # it's also italic
tags.append('italic')
elif special_text[1] == '~' and special_text[-2] == '~' and \
len(special_text) > 4: # it's also strikethrough
tags.append('strikethrough')
if not show_ascii_formatting_chars:
special_text = special_text[2:-2] # remove _/ /_
special_text = special_text[2:-2] # remove _~ ~_
else:
if not show_ascii_formatting_chars:
special_text = special_text[1:-1] # remove _ _
......
......@@ -1310,7 +1310,7 @@ def make_regexps(self):
# detects eg. *b* *bold* *bold bold* test *bold* *bold*! (*bold*)
# doesn't detect (it's a feature :P) * bold* *bold * * bold * test*bold*
formatting = r'|(?<!\w)' r'\*[^\s*]' r'([^*]*[^\s*])?' r'\*(?!\w)|'\
r'(?<!\S)' r'/[^\s/]' r'([^/]*[^\s/])?' r'/(?!\S)|'\
r'(?<!\S)' r'~[^\s~]' r'([^~]*[^\s~])?' r'~(?!\S)|'\
r'(?<!\w)' r'_[^\s_]' r'([^_]*[^\s_])?' r'_(?!\w)'
basic_pattern = links + '|' + mail + '|' + legacy_prefixes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment