chiark / gitweb /
m.code: improve ANSI coloring to work on ASan output as well.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 5 Dec 2019 18:49:06 +0000 (19:49 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 5 Dec 2019 18:49:06 +0000 (19:49 +0100)
doc/plugins/math-and-code-console.ansi
plugins/ansilexer.py
plugins/m/test/code/page.html

index db53fd3f37a290055b5172f1b7d8f1380b1d3abb..742c3f5ef3555603f96f0a45fa0eacd10f38a429 100644 (file)
@@ -1,3 +1,7 @@
 !\e[0;34m[\e[1;37mmosra@don-perverzo \e[0;37mm.css\e[0;34m]\e[1;36m$ \e[0mls
 CONTRIBUTING.rst  CREDITS.rst  \e[0m\e[01;34mdoc\e[0m            \e[01;34mplugins\e[0m        README.rst
 COPYING           \e[01;34mcss\e[0m          \e[01;34mdocumentation\e[0m  \e[01;34mpelican-theme\e[0m  \e[01;34msite\e[0m
+
+ASan reports:
+
+=>0x0c287fff8030: \e[1m\e[0m00\e[1m\e[0m[\e[1m\e[34mfc\e[1m\e[0m]\e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[34mfc\e[1m\e[0m \e[1m\e[31mfa\e[1m\e[0m \e[1m\e[31mfa\e[1m\e[0m \e[1m\e[31mfa\e[1m\e[0m \e[1m\e[31mfa\e[1m\e[0m \e[1m\e[31mfa\e[1m\e[0m
index e22686b7c22379881f9919baab662b85a0e3b648..945c51943a229de61204a78d1fdbd26820ac19a6 100644 (file)
@@ -44,23 +44,23 @@ class AnsiLexer(RegexLexer):
             yield (match.start(), Text, text)
             return
 
-        if color == ';30':
+        if color == '30':
             token += 'Black'
-        elif color == ';31':
+        elif color == '31':
             token += 'Red'
-        elif color == ';32':
+        elif color == '32':
             token += 'Green'
-        elif color == ';33':
+        elif color == '33':
             token += 'Yellow'
-        elif color == ';34':
+        elif color == '34':
             token += 'Blue'
-        elif color == ';35':
+        elif color == '35':
             token += 'Magenta'
-        elif color == ';36':
+        elif color == '36':
             token += 'Cyan'
-        elif color == ';37':
+        elif color == '37':
             token += 'White'
-        elif color == ';39':
+        elif color == '39':
             token += 'Default'
         else:
             yield (match.start(), Text, text)
@@ -83,7 +83,10 @@ class AnsiLexer(RegexLexer):
             ('[^\x1b]+', Text),
             ('\x1b\\[38;2;(\\d+);(\\d+);(\\d+)m\x1b\\[48;2;\\d+;\\d+;\\d+m([^\x1b]+)\x1b\\[0m', callback_fg_bg_color),
             ('\x1b\\[38;2;(\\d+);(\\d+);(\\d+)m([^\x1b]+)\x1b\\[0m', callback_fg_color),
-            ('\x1b\\[(\\d+)(;\\d+)?m([^\x1b]*)', callback)]
+            # Brightness and color separately (used by ASan reports)
+            ('\x1b\\[([01])m\x1b\\[(\\d+)m([^\x1b]*)', callback),
+            ('\x1b\\[(\\d+)(?:;(\\d+))?m([^\x1b]*)', callback)
+        ]
     }
 
 _ansi_fg_color_re = re.compile('class="g g-AnsiForegroundColor([0-9a-f]{6})">')
index ba58943b1027d2576151631980be0c492175b464..54c84c42049987a9552b6ddb5b6e4c303f081357 100644 (file)
 rendered as plain monospace text: <code>code</code>.</p>
 <pre class="m-console">!<span class="g g-AnsiBlue">[</span><span class="g g-AnsiBrightWhite">mosra@don-perverzo </span><span class="g g-AnsiWhite">m.css</span><span class="g g-AnsiBlue">]</span><span class="g g-AnsiBrightCyan">$ </span>ls
 CONTRIBUTING.rst  CREDITS.rst  <span class="g g-AnsiBrightBlue">doc</span>            <span class="g g-AnsiBrightBlue">plugins</span>        README.rst
-COPYING           <span class="g g-AnsiBrightBlue">css</span>          <span class="g g-AnsiBrightBlue">documentation</span>  <span class="g g-AnsiBrightBlue">pelican-theme</span>  <span class="g g-AnsiBrightBlue">site</span></pre>
+COPYING           <span class="g g-AnsiBrightBlue">css</span>          <span class="g g-AnsiBrightBlue">documentation</span>  <span class="g g-AnsiBrightBlue">pelican-theme</span>  <span class="g g-AnsiBrightBlue">site</span>
+
+ASan reports:
+
+=&gt;0x0c287fff8030: 00[<span class="g g-AnsiBrightBlue">fc</span>]<span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightBlue">fc</span> <span class="g g-AnsiBrightRed">fa</span> <span class="g g-AnsiBrightRed">fa</span> <span class="g g-AnsiBrightRed">fa</span> <span class="g g-AnsiBrightRed">fa</span> <span class="g g-AnsiBrightRed">fa</span></pre>
 <p>Console colors:</p>
 <pre class="m-console"><span style="color: #dcdcdc; background-color: #dcdcdc">&zwnj;██</span> <span style="color: #a5c9ea; background-color: #a5c9ea">&zwnj;██</span> <span style="color: #3bd267; background-color: #3bd267">&zwnj;██</span> <span style="color: #c7cf2f; background-color: #c7cf2f">&zwnj;██</span> <span style="color: #cd3431; background-color: #cd3431">&zwnj;██</span> <span style="color: #2f83cc; background-color: #2f83cc">&zwnj;▓▓</span> <span style="color: #747474; background-color: #747474">&zwnj;▒▒</span>