Hello community,
here is the log from the commit of package python-pygments-ansi-color for
openSUSE:Factory checked in at 2019-09-23 12:02:51
Comparing /work/SRC/openSUSE:Factory/python-pygments-ansi-color (Old)
and /work/SRC/openSUSE:Factory/.python-pygments-ansi-color.new.7948 (New)
Package is "python-pygments-ansi-color"
Mon Sep 23 12:02:51 2019 rev:2 rq:729487 version:0.0.3
Changes:
---
/work/SRC/openSUSE:Factory/python-pygments-ansi-color/python-pygments-ansi-color.changes
2019-02-17 12:21:03.476205232 +0100
+++
/work/SRC/openSUSE:Factory/.python-pygments-ansi-color.new.7948/python-pygments-ansi-color.changes
2019-09-23 12:02:53.889950072 +0200
@@ -1,0 +2,6 @@
+Mon Sep 9 14:14:19 UTC 2019 - Tomáš Chvátal
+
+- Update to 0.0.3:
+ * minor color tweaks
+
+---
Old:
v0.0.2.tar.gz
New:
v0.0.3.tar.gz
Other differences:
--
++ python-pygments-ansi-color.spec ++
--- /var/tmp/diff_new_pack.aKpwXQ/_old 2019-09-23 12:02:55.645949782 +0200
+++ /var/tmp/diff_new_pack.aKpwXQ/_new 2019-09-23 12:02:55.649949781 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pygments-ansi-color
-Version:0.0.2
+Version:0.0.3
Release:0
Summary:ANSI color-code highlighting for Pygments
License:Apache-2.0
++ v0.0.2.tar.gz -> v0.0.3.tar.gz ++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.2/README.md
new/pygments-ansi-color-0.0.3/README.md
--- old/pygments-ansi-color-0.0.2/README.md 2018-02-01 20:04:03.0
+0100
+++ new/pygments-ansi-color-0.0.3/README.md 2019-07-24 23:23:57.0
+0200
@@ -48,11 +48,11 @@
```python
import pygments
- import pygments.formatter
+ import pygments.formatters
import pygments.lexers
lexer = pygments.lexers.get_lexer_by_name('ansi-color')
- formatter = pygments.formatter.HtmlFormatter(style=MyStyle)
+ formatter = pygments.formatters.HtmlFormatter(style=MyStyle)
print(pygments.highlight('your text', lexer, formatter))
```
@@ -65,4 +65,60 @@
The colors are defined as part of your Pygments style and can be changed.
+### Optional: Enable "256 color" support
+
+This library supports rendering terminal output using [256 color
+(8-bit)][256-color] ANSI color codes. However, because of limitations in
+Pygments tokens, this is an opt-in feature which requires patching the
+formatter you're using.
+
+The reason this requires patching the Pygments formatter is that Pygments does
+not support multiple tokens on a single piece of text, requiring us to
+"compose" a single state (which is a tuple of `(bold enabled, fg color, bg
+color)`) into a single token like `Color.Bold.FGColor.BGColor`. We then need to
+output the styles for this token in the CSS.
+
+In the default mode where we only support the standard 8 colors (plus 1 for no
+color), we need 2 × 9 × 9 - 1 = 161 tokens, which is reasonable to contain in
+one CSS file. With 256 colors (plus the standard 8, plus 1 for no color),
+though, we'd need 2 × 265 × 265 - 1 = 140,449 tokens defined in CSS. This makes
+the CSS too large to be practical.
+
+To make 256-color support realistic, we patch Pygments' HTML formatter so that
+it places a class for each part of the state tuple independently. This means
+you need only 1 + 265 + 265 = 531 CSS classes to support all possibilities.
+
+If you'd like to enable 256-color support, you'll need to do two things:
+
+1. When calling `color_tokens`, pass `enable_256color=True`:
+
+ ```python
+ styles.update(color_tokens(fg_colors, bg_colors, enable_256color=True))
+ ```
+
+ This change is what causes your CSS to have the appropriate classes in it.
+
+2. When constructing your formatter, use the `ExtendedColorHtmlFormatterMixin`
+ mixin, like this:
+
+ ```python
+ from pygments.formatters import HtmlFormatter
+ from pygments_ansi_color import ExtendedColorHtmlFormatterMixin
+
+ ...
+
+ class MyFormatter(ExtendedColorHtmlFormatterMixin, HtmlFormatter):
+ pass
+
+ ...
+
+ formatter = pygments.formatter.HtmlFormatter(style=MyStyle)
+ ```
+
+ This change is what causes the rendered HTML to have the right class names.
+
+Once these two changes have been made, you can use pygments-ansi-color as
normal.
+
+
[fluffy-example]: https://i.fluffy.cc/zr9RVt0gcrVtKH06hkqRCJPP1S91z3Mz.html
+[256-color]: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.2/pygments_ansi_color.py