summaryrefslogtreecommitdiff
path: root/pygments/formatters
Commit message (Collapse)AuthorAgeFilesLines
* Run pyupgrade across codebase to modernize syntax and patterns (#1622)Jon Dufresne2021-01-1712-16/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Bump copyright year.Matthäus G. Chajdas2021-01-0312-14/+14
|
* Revert a private API in the HTML formatter (#1655)Kurt McKee2020-12-301-6/+9
| | | | | | This should revert the behavior of the function without losing the overall caching behavior that was intended. Closes #1644
* ImgFormatter: Use the start position based on the length of text (#1611)strawberry beach sandals2020-11-281-8/+20
|
* Remove margin: 0 from <pre> styling.Matthäus G. Chajdas2020-10-281-1/+1
| | | | | | 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.
* Speed up JSON and reduce HTML formatter consumption (#1569)Kurt McKee2020-10-261-17/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Speculative fix for #1579. (#1583)Matthäus G. Chajdas2020-10-241-2/+2
| | | | 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 (#1517)Eric Wieser2020-09-301-9/+42
| | | | | | | * Fix LatexEmbeddedLexer to not call the nested tokenizer piecewise * Reuse the existing do_insertions function * Add a test for the `LatexEmbeddedLexer`
* image formatter: find ttc fonts on MacGeorg Brandl2020-09-201-1/+2
| | | | fixes #1223
* all: remove "u" string prefix (#1536)Georg Brandl2020-09-084-45/+45
| | | | | | | | | | | * 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
* all: use yield from (#1537)Georg Brandl2020-09-062-12/+6
|
* Update copyright year (fixes #1514.)Matthäus G. Chajdas2020-08-2212-14/+14
|
* Improve HTML formatter output.improve-linenos-handlingMatthäus G. Chajdas2020-07-311-4/+8
| | | | | | | | | | | | | | | 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.
* Fix Solarized line number colors (#1477)Paweł Fertyk2020-07-041-91/+142
| | | | | | | | | | | | | | | | | * 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
* Improve font handling code.Matthäus G. Chajdas2020-03-031-6/+9
| | | | | * 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
* Fix #1247 by looking up in both HKLM and HKCU.Matthäus G. Chajdas2020-03-021-23/+32
| | | | | | 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 (#1348)Georg Brandl2020-02-297-32/+17
| | | | | | | | | | | * Remove Python 2 compatibility * remove 2/3 shims in pygments.util * update setup.py metadata * Remove unneeded object inheritance. * Remove unneeded future imports.
* Update many links to use HTTPS and skip redirectsKurt McKee2019-12-181-2/+2
|
* Merge branch '582/joshuagryphon/svglinenos'Matthäus G. Chajdas2019-12-011-3/+37
|\
| * Right-align line numbers in the SVG formatter.Matthäus G. Chajdas2019-12-011-3/+3
| |
| * Merge branch 'master' into 582/joshuagryphon/svglinenosMatthäus G. Chajdas2019-12-011-2/+2
| |\
| * | svg formatter can now add configurable linenumbersJoshua Griffin Dunn2019-11-281-3/+37
| | |
* | | allow terminal256 formatter to show italics...Kurt Neufeld2019-12-011-2/+12
| |/ |/| | | | | | | | | | | | | | | | | | | 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
* | use IOError reason in error messageGeorg Brandl2019-11-291-2/+2
|/
* html formatter: lineseparator needs to be unicodeGeorg Brandl2019-11-261-1/+1
| | | | Fixes #1053
* Update project to use modern Python features and idiomsJon Dufresne2019-11-251-2/+2
| | | | | | | | | | 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
* formatters.other: style/import fixupsGeorg Brandl2019-11-251-1/+5
|
* image formatter: actually respect "line_number_separator"Georg Brandl2019-11-241-1/+2
|
* Update TestcaseFormatter.Matthäus G. Chajdas2019-11-161-2/+2
| | | | | We're using pytest now, and that needs slightly different test-case syntax.
* Fix #928.Matthäus G. Chajdas2019-11-161-2/+3
| | | | | We're using Menlo on Mac OS now, and DejaVu Sans Mono on Unix. Also updated the documentation to match the actually used fonts.
* Update img.pyanshks2019-10-221-1/+1
| | | changed font style to DejaVu Sans Mono in DEFAULT_FONT_NAME_NIX
* Fix some typos in comments.Matth?us G. Chajdas2019-07-201-2/+2
|
* Fixup all headers and some more minor problems.2.4.2Georg Brandl2019-05-2811-11/+11
|
* Backed out changeset: df3df829861dMatth?us G. Chajdas2019-05-211-7/+1
|
* Don't emit a trailing newline in nowrap mode (fixes #1514.)Matth?us G. Chajdas2019-05-181-1/+7
|
* Merged in SylvainCorlay/pygments-main/css-variables (pull request #814)Anteru2019-05-091-4/+29
|\ | | | | | | | | | | Allow for CSS variable in pygments stylesheets Approved-by: Anteru <bitbucket@ca.sh13.net>
| * Add license information to generated files (fixes #1496).Matth?us G. Chajdas2019-05-071-2/+11
| | | | | | | | Also update the license year to 2019.
| * Add option to wrap the code in both <code> and <pre> (fixes #438.)Matth?us G. Chajdas2019-05-061-2/+18
| | | | | | | | Adds a new option "wrapcode" which wraps the code using <code>.
* | Allow for CSS variable in pygments stylesheetsSylvain Corlay2019-05-021-3/+8
|/
* Fix ResourceWarning: unclosed fileMicka?l Schoentgen2019-01-072-5/+5
| | | | Also uniformize usage of the 'with' contact manager to prevent resource leaks.
* Merge fix for recently introduced failures.Matth?us G. Chajdas2018-12-192-5/+5
|\
| * Fix a few markup problems in the docs.Georg Brandl2018-12-181-2/+2
| |
| * Update ansi color name change version.Matth?us G. Chajdas2018-12-161-2/+2
| |
| * Merged in mortenlund/pygments-main (pull request #777)Anteru2018-12-161-3/+9
| |\ | | | | | | | | | | | | | | | | | | | | | Change ansi color names to more saying names Approved-by: Morten E. Lund <melund@gmail.com> Approved-by: jonathanslenders <jonathan@slenders.be> Approved-by: Anteru <bitbucket@ca.sh13.net>
| * | Fix more instances of invalid string escapesGeorg Brandl2018-11-281-1/+1
| | | | | | | | | | | | Also, raise on warnings from Pygments only.
* | | Update remaining color namesMorten Enemark Lund2018-12-182-62/+62
| |/ |/|
* | Use replace instead of stripMorten Enemark Lund2018-08-211-2/+2
| |
* | Ensure terminal formatter works with new ansi colors namesMorten Enemark Lund2018-08-211-2/+2
| |
* | Change ansi color names to more saying namesMorten Enemark Lund2018-08-041-1/+7
|/ | | | | | The ansi color names are changed to names which are easier to understand and align with color names of other projects and terminals. (e.g. ``#ansifuchsia`` to ``ansibrightmagenta``) This also drops the # prefix to the color names. Hashtag # is usually used for hex colors and the names are already prefixed with `ansi`. Furthermore, it allows the new and old set of names to be exclusive.
* -x functionality updates, Python 3 compatibility fixGeorg Brandl2017-01-221-4/+6
|