From d1837841fc4705f311a106c2efe553f811c46a9d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 8 Jun 2020 21:35:29 +0200 Subject: [PATCH] m.code: remove the ZWNJ hack. Was used only to fix one browser rendering issue on magnum.graphics which happened only when Unicode blocks were involved. Does not make sense to pollute all output with it. --- .../test_doxygen/contents_code_language/ansi.html | 6 +++--- plugins/ansilexer.py | 13 ++++--------- plugins/m/test/code/page.html | 6 +++--- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/documentation/test_doxygen/contents_code_language/ansi.html b/documentation/test_doxygen/contents_code_language/ansi.html index d5aa5488..a071d1e3 100644 --- a/documentation/test_doxygen/contents_code_language/ansi.html +++ b/documentation/test_doxygen/contents_code_language/ansi.html @@ -22,11 +22,11 @@

ANSI color escape code highlighting

-
![mosra@don-perverzo m.css]$ 
‌██ ‌██ ‌██ ‌██ ‌██ ‌▓▓ ‌▒▒
+
![mosra@don-perverzo m.css]$ 
██ ██ ██ ██ ██ ▓▓ ▒▒
 
-Leading zeros: ‌▒▒ ‌▒▒
+Leading zeros: ▒▒ ▒▒
 
-  ‌░░ ‌▒▒ ‌▓▓ ‌██
+ ░░ ▒▒ ▓▓ ██
diff --git a/plugins/ansilexer.py b/plugins/ansilexer.py index 39538d8b..01dd9ce1 100644 --- a/plugins/ansilexer.py +++ b/plugins/ansilexer.py @@ -89,8 +89,8 @@ class AnsiLexer(RegexLexer): ] } -_ansi_fg_color_re = re.compile('class="g g-AnsiForegroundColor([0-9a-f]{6})">') -_ansi_fg_bg_color_re = re.compile('class="g g-AnsiForegroundBackgroundColor([0-9a-f]{6})">') +_ansi_fg_color_re = re.compile('class="g g-AnsiForegroundColor([0-9a-f]{6})"') +_ansi_fg_bg_color_re = re.compile('class="g g-AnsiForegroundBackgroundColor([0-9a-f]{6})"') class HtmlAnsiFormatter(HtmlFormatter): def wrap(self, source, outfile): @@ -99,12 +99,7 @@ class HtmlAnsiFormatter(HtmlFormatter): def _wrap_code(self, source): for i, t in source: if i == 1: # it's a line of formatted code - # Add ZWNJ for before each character because otherwise it's - # somehow impossible to wrap even with word-break: break-all. - # Not sure why (and not sure if this is the best solution), but - # had to ship a thing so there it is. Adding did not - # help. - t = _ansi_fg_bg_color_re.sub('style="color: #\\1; background-color: #\\1">‌', t) - t = _ansi_fg_color_re.sub('style="color: #\\1">‌', t) + t = _ansi_fg_bg_color_re.sub('style="color: #\\1; background-color: #\\1"', t) + t = _ansi_fg_color_re.sub('style="color: #\\1"', t) #t += 'H' yield i, t diff --git a/plugins/m/test/code/page.html b/plugins/m/test/code/page.html index 0af11332..a9f95582 100644 --- a/plugins/m/test/code/page.html +++ b/plugins/m/test/code/page.html @@ -39,11 +39,11 @@ ASan reports: =>0x0c287fff8030: 00[fc]fc fc fc fc fc fc fc fc fc fa fa fa fa fa

Console colors:

-
‌██ ‌██ ‌██ ‌██ ‌██ ‌▓▓ ‌▒▒
+
██ ██ ██ ██ ██ ▓▓ ▒▒
 
-Leading zeros: ‌▒▒ ‌▒▒
+Leading zeros: ▒▒ ▒▒
 
-  ‌░░ ‌▒▒ ‌▓▓ ‌██
+ ░░ ▒▒ ▓▓ ██
// this language is not highlighted

Properly preserve backslashes: \frac{a}{b} ... and backticks: :ref:`a function <os.path.join()>`

-- 2.30.2