| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
In Python 3, RawTokenFormatter would output non-ASCII for non-ASCII
input, and RawTokenLexer would throw Unicode-related exceptions for
ASCII or non-ASCII input; fix them. Also, handle all exceptions, so
that callers who find RawTokenLexer via get_lexer_by_name on user
input don’t unexpectedly get a lexer that throws exceptions.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
|
|
|
|
|
|
|
|
|
| |
Extend Image formatters in img.py to support background colors.
* New function to get the background color for a given token type, optionally None
* The self.drawables list used the fill keyword, stuffed into a **kwrgs, for the color of the token; since tokens can have foreground and background colors, that list now uses two explicit names, passing one to the PIL/Pillow text draw call, the other to the rectangle draw call.
* When iterating over the `drawables` list, the presence of a background color triggers the drawing of a rectangle beneath the text.
* Dimensions of background rectangle calculated by PIL based on the rendered text and font.
* If input string is multiline, PIL will use multiline for draw and size internally.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix #1698.
* Change default line number styling.
Instead of hardcoding black/light gray, use transparent/inherit which
makes it "neutral" out of the box. linenospecial is still hard-coded and
may look wrong, but that needs fixing in the style.
* Prettify the test files.
* Fix incorrect wrapping of TD linenos.
The padding would get applied twice to "special" lines, once via
<pre>, once via the <span>, which was not consistent with inline
line numbers where the .special style would override the default
style.
To fix this, we now emit "normal" and "special" lines for td.linenos
line numbers, and the normal style is applied to "normal". This brings
td.linenos closer to inline line numbers, and also makes the styling
between noclasses=True and noclasses=False consistent.
* Document the line number styling changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without this, the \strut causes the background color to apply to a full
baseline height, then the framing done by \fcolorbox augments beyond
that the box height and as a result the line where this happens will
have extra distance from previous and next lines.
Correct that by reducing the apparent box size by exactly the width of
the frame (\fboxrule).
Also, make the change to \fboxsep local. Reason: if texcomments is True,
some arbitrary LaTeX mark-up can be executed in a later part and the
setting of \fboxsep could modify output; macro \<cmdprefix>@bc is
executed at top level, cf. \<cmdprefix>@do.
|
|
|
|
|
|
|
| |
In case of texcomments=True or usage of escapeinside, arbitrary LaTeX
can be executed. The \PY@bc is executed at top level hence should not
set \fboxsep at this level but keep the change to a local scope.
There is another instance but it is part of PR #1708
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ latexdef @namedef
\@namedef:
macro:#1->\expandafter \def \csname #1\endcsname
And the @ character is usable here in macro names (the variable with
name definition is authorized to contain for example \PY@it)
This makes the output shorter. It makes for a neater
sphinxhighlight.sty...
|
|
|
|
|
|
|
|
| |
This is almost irrelevant. But \catcode`\_=8 without termination might
let LaTeX expand prematurely its token stream. Of course here in the
context of fancyvrb.sty chances are 99.99% that what comes next does not
expand or expands safely. I did not look in code.
Only a matter of style, to be on the safe side.
|
|
|
|
|
| |
* Add support for anchored line numbers in inline rendering mode
* Fix tests rendering anchored line number in inline mode
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pyupgrade is a tool to automatically upgrade syntax for newer versions
of the Python language.
The project has been Python 3 only since
35544e2fc6eed0ce4a27ec7285aac71ff0ddc473, allowing for several cleanups:
- Remove unnecessary "-*- coding: utf-8 -*-" cookie. Python 3 reads all
source files as utf-8 by default.
- Replace IOError/EnvironmentError with OSError. Python 3 unified these
exceptions. The old names are aliases only.
- Use the Python 3 shorter super() syntax.
- Remove "utf8" argument form encode/decode. In Python 3, this value is
the default.
- Remove "r" from open() calls. In Python 3, this value is the default.
- Remove u prefix from Unicode strings. In Python 3, all strings are
Unicode.
- Replace io.open() with builtin open(). In Python 3, these functions
are functionally equivalent.
Co-authored-by: Matthäus G. Chajdas <Anteru@users.noreply.github.com>
|
| |
|
|
|
|
|
|
| |
This should revert the behavior of the function without losing
the overall caching behavior that was intended.
Closes #1644
|
| |
|
|
|
|
|
|
| |
This seems to break some themes which were not expecting Pygments to
change margins, and it doesn't look like it makes a difference for
standalone Pygments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update the JSON-LD keyword list to match JSON-LD 1.1
Changes in this patch:
* Update the JSON-LD URL to HTTPS
* Update the list of JSON-LD keywords
* Make the JSON-LD parser less dependent on the JSON lexer implementation
* Add unit tests for the JSON-LD lexer
* Add unit tests for the JSON parser
This includes:
* Testing valid literals
* Testing valid string escapes
* Testing that object keys are tokenized differently from string values
* Rewrite the JSON lexer
Related to #1425
Included in this change:
* The JSON parser is rewritten
* The JSON bare object parser no longer requires additional code
* `get_tokens_unprocessed()` returns as much as it can to reduce yields
(for example, side-by-side punctuation is not returned separately)
* The unit tests were updated
* Add unit tests based on Hypothesis test results
* Reduce HTML formatter memory consumption by ~33% and speed it up
Related to #1425
Tested on a 118MB JSON file. Memory consumption tops out at ~3GB before
this patch and drops to only ~2GB with this patch. These were the command
lines used:
python -m pygments -l json -f html -o .\new-code-classes.html .\jc-output.txt
python -m pygments -l json -f html -O "noclasses" -o .\new-code-styles.html .\jc-output.txt
* Add an LRU cache to the HTML formatter's HTML-escaping and line-splitting
For a 118MB JSON input file, this reduces memory consumption by ~500MB
and reduces formatting time by ~15 seconds.
* JSON: Add a catastrophic backtracking test back to the test suite
* JSON: Update the comment that documents the internal queue
* JSON: Document in comments that ints/floats/constants are not validated
|
|
|
|
| |
This removes the top/bottom padding changes, and only keeps left/right
padding, in the hope that this does not break all Sphinx themes.
|
|
|
|
|
|
|
| |
* Fix LatexEmbeddedLexer to not call the nested tokenizer piecewise
* Reuse the existing do_insertions function
* Add a test for the `LatexEmbeddedLexer`
|
|
|
|
| |
fixes #1223
|
|
|
|
|
|
|
|
|
|
|
| |
* all: remove "u" string prefix
* util: remove unirange
Since Python 3.3, all builds are wide unicode compatible.
* unistring: remove support for narrow-unicode builds
which stopped being relevant with Python 3.3
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With the previous changes, we started to emit one <pre> per line for
line numbers. This breaks for instance the Sphinx-RTD-Theme, which
expects the line numbers to be formatted the same way as the normal
content. This commit makes the following changes:
* Emit a single <pre> inside the linenos div
* Wrap individual lines into <span> as needed
* Update all tests
* Don't yield empty <span> elements when no style is specified
This also makes the .html test files look correct when looked at with a
browser, as there is no extra whitespace in them which needs stripping.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add font and background colors to Style
* Move all styles to get_style_defs, add tests
* Remove hardcoded styles, add special lineno style
* Add styles for special line numbers in tables
* Update noclasses documentation
* Refactor linenos elements and styles, add tests
* Update AUTHORS
* Fix multiple CSS prefixes, add tests
|
|
|
|
|
| |
* Fix an issue raised in the review -- don't raise None no matter what.
* Remove a few variables to make the control flow easier to understand
|
|
|
|
|
|
| |
This is slightly different from the code posted inside the issue:
* Use finally to close the registry key no matter what
* Don't use break, but return directly on the first hit
|
|
|
|
|
|
|
|
|
|
|
| |
* Remove Python 2 compatibility
* remove 2/3 shims in pygments.util
* update setup.py metadata
* Remove unneeded object inheritance.
* Remove unneeded future imports.
|
| |
|
|\ |
|
| | |
|
| |\ |
|
| | | |
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
OSX users will have to follow instructions at: http://www.eddieantonio.ca/blog/2015/04/16/iterm-italics/
tldr;
infocmp xterm-256color > /tmp/xterm-256color.terminfo
echo 'sitm=\E[3m, ritm=\E[23m,' >> /tmp/xterm-256color.terminfo
tic /tmp/xterm-256color.terminfo
make sure iTerm2.settings.profiles.terminal.terminal type=xterm-256color
|
|/ |
|
|
|
|
| |
Fixes #1053
|
|
|
|
|
|
|
|
|
|
| |
Run the pyupgrade tool across the project to use modern language
features.
- Use set literals
- Use dict comprehension
- Remove unnecessary numeric indexes in format string
- Remove unnecessary extra parentheses
|
| |
|
| |
|
|
|
|
|
| |
We're using pytest now, and that needs slightly different test-case
syntax.
|
|
|
|
|
| |
We're using Menlo on Mac OS now, and DejaVu Sans Mono on Unix. Also
updated the documentation to match the actually used fonts.
|
|
|
| |
changed font style to DejaVu Sans Mono in DEFAULT_FONT_NAME_NIX
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| |
| |
| |
| | |
Allow for CSS variable in pygments stylesheets
Approved-by: Anteru <bitbucket@ca.sh13.net>
|
| |
| |
| |
| | |
Also update the license year to 2019.
|
| |
| |
| |
| | |
Adds a new option "wrapcode" which wraps the code using <code>.
|
|/ |
|
|
|
|
| |
Also uniformize usage of the 'with' contact manager to prevent resource leaks.
|