Philipp Hörist pushed to branch master at gajim / gajim


Commits:
8e79f9f7 by André Apitzsch at 2020-10-25T17:39:24+01:00
Use styling directives as recommended in XEP-0393

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

Fixes #7613.

- - - - -


2 changed files:

- gajim/conversation_textview.py
- gajim/gui_interface.py


Changes:

=====================================
gajim/conversation_textview.py
=====================================
@@ -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 _ _


=====================================
gajim/gui_interface.py
=====================================
@@ -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



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/8e79f9f79a3d6e571af408a2b83fb1e70755e9e5

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/8e79f9f79a3d6e571af408a2b83fb1e70755e9e5
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to