From 3bbbdf95e14c1638b216fbcb61cdbc22679a6f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Wed, 1 May 2019 16:37:57 +0100 Subject: [PATCH 1/3] Add .idea to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 564b95d..4ed3eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ flatpak/* data/ui/shortcut_handlers *.ui~ .vscode/ +.idea/ *.glade~ dist/uberwriter-2.0b0-py3.7.egg builddir/* From 9238a82d4df8124eb956f31b5e36b2c24085af4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Wed, 1 May 2019 16:40:14 +0100 Subject: [PATCH 2/3] Fix #154 --- uberwriter/text_view_markup_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uberwriter/text_view_markup_handler.py b/uberwriter/text_view_markup_handler.py index 029871a..fd3a9a2 100644 --- a/uberwriter/text_view_markup_handler.py +++ b/uberwriter/text_view_markup_handler.py @@ -37,13 +37,13 @@ class MarkupHandler: "BOLDITALIC": re.compile(r"(\*\*\*|___)(.+?)\1"), "STRIKETHROUGH": re.compile(r"~~.+?~~"), "LINK": re.compile(r"(\[).*(\]\(.+?\))"), - "HORIZONTALRULE": re.compile(r"\n\n([ ]{0,3}[*\-_]{3,}[ ]*)\n", re.MULTILINE), + "HORIZONTALRULE": re.compile(r"\n\n([ ]{0,3}[*\-_]{3,}[ ]*)\n\n", re.MULTILINE), "LIST": re.compile(r"^((?:\t|[ ]{4})*)[\-*+] .+", re.MULTILINE), "NUMERICLIST": re.compile(r"^((\d|[a-z]|#)+[.)]) ", re.MULTILINE), "NUMBEREDLIST": re.compile(r"^((?:\t|[ ]{4})*)((?:\d|[a-z])+[.)]) .+", re.MULTILINE), "BLOCKQUOTE": re.compile(r"^[ ]{0,3}(?:>|(?:> )+).+", re.MULTILINE), "HEADER": re.compile(r"^[ ]{0,3}(#{1,6}) [^\n]+", re.MULTILINE), - "HEADER_UNDER": re.compile(r"^[ ]{0,3}\w.+\n[ ]{0,3}[=\-]{3,}", re.MULTILINE), + "HEADER_UNDER": re.compile(r"^\n[ ]{0,3}\w.+\n[ ]{0,3}[=\-]{3,}", re.MULTILINE), "CODE": re.compile(r"(?:^|\n)[ ]{0,3}(([`~]{3}).+?[ ]{0,3}\2)(?:\n|$)", re.DOTALL), "TABLE": re.compile(r"^[\-+]{5,}\n(.+?)\n[\-+]{5,}\n", re.DOTALL), "MATH": re.compile(r"[$]{1,2}([^` ].+?[^`\\ ])[$]{1,2}"), From 241ba567e47093496a9d3ae662a7e8ce96a093e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= Date: Wed, 1 May 2019 18:55:24 +0100 Subject: [PATCH 3/3] Fix character count with horizontal rules Pandoc's conversion to plain text converts horizontal rules to a sequence of 72 dashes. This update ensures that subsequent dashes are ignored when counting characters. --- uberwriter/stats_counter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/uberwriter/stats_counter.py b/uberwriter/stats_counter.py index fa4b103..adeac08 100644 --- a/uberwriter/stats_counter.py +++ b/uberwriter/stats_counter.py @@ -11,8 +11,11 @@ from uberwriter import helpers class StatsCounter: """Counts characters, words, sentences and read time using a background thread.""" - # Regexp that matches any character, except for newlines and subsequent spaces. - CHARACTERS = re.compile(r"[^\s]|(?:[^\S\n](?!\s))") + # Regexp that matches characters, with the following exceptions: + # * Newlines + # * Sequential spaces + # * Sequential dashes + CHARACTERS = re.compile(r"[^\s-]|(?:[^\S\n](?!\s)|-(?![-\n]))") # Regexp that matches Asian letters, general symbols and hieroglyphs, # as well as sequences of word characters optionally containing non-word characters in-between.