Skip to content
Snippets Groups Projects
Verified Commit 8e79f9f7 authored by André's avatar André
Browse files

Use styling directives as recommended in XEP-0393

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

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