summaryrefslogtreecommitdiff
path: root/pygments/formatters
Commit message (Collapse)AuthorAgeFilesLines
* Use autodoc for pygments.stylesJean Abou Samra2023-03-301-15/+20
|
* tox -e mapfilesJean Abou Samra2023-03-301-1/+1
| | | | (sorry, I forgot that the docstrings are part of _mapping.py)
* Slightly clarify documentation of HtmlFormatter nowrap optionJean Abou Samra2023-03-301-7/+5
| | | | Fixes #2396
* Update copyright year to 2023.Matthäus G. Chajdas2023-03-2913-15/+15
|
* Replace Makefile with tox (#2331)Jean Abou-Samra2023-02-231-1/+1
| | | | | | | | | | | | | | | Porting notes: - tox handles Python environments automatically. Remove a bit of PYTHONPATH manipulation (that was using Python 2 code which always failed!) - No `clean` target: `git clean -xdf` should fit the bill. - No `reindent` target: the `reindent.py` script it was using does not exist (anymore?). - No equivalent of tox-test-coverage, which was an artifact of the past, using nose. Instead, the test-coverage target only is ported, which uses pytest, and works.
* groff: Sort color definitions for reproducibility (#2343)Jean Abou-Samra2023-02-151-1/+1
|
* Fix lots of missing encoding="utf-8" parametersJean Abou Samra2023-01-311-4/+4
| | | | | Some of these are probably unnecessary (ASCII-only content), but it's easier not to think about it.
* Revert "Remove filename pattern caches (#2153)" (#2328)Dirk Mueller2023-01-311-3/+14
| | | | | | | | This introduced a performance regession. While it is true that fnmatch already uses functools.lru_cache, that cache is limited to 256 on python 3.10 and older and we have over 1000 matching patterns, which means the cache is evicted entirely on every iteration. This reverts commit 951c894ab23537be90fbf3973d0345591e682371.
* Simplify the condition.Matthäus G. Chajdas2022-12-111-8/+6
|
* Stop the HTML formatter from emitting empty whitespace spans.Matthäus G. Chajdas2022-12-111-2/+6
|
* Remove unneeded _format_unencoded_with_lineno function from IRCFormatter and ↵Ayowel2022-11-061-30/+5
| | | | fix line endings insertion
* all: style fixesGeorg Brandl2022-10-271-1/+0
|
* formatters/img: use new API for bounding box for Pillow 9.2Georg Brandl2022-07-301-4/+8
|
* Remove filename pattern caches (#2153)Jean Abou-Samra2022-06-041-13/+3
| | | | These are irrelevant because the fnmatch module implementation already uses functools.lru_cache.
* Merge mapping file generation scripts (#2152)Jean Abou-Samra2022-05-291-64/+3
| | | | | | | | | Use a unified script, to reduce code duplication and in preparation for doing a similar thing with styles and filters. The new script also uses a bit more modern Python APIs (e.g., pathlib). Unlike the previous scripts, it does not replace replace CRLF with LF because Git should do that itself.
* Fix #632. (#2101)Matthäus G. Chajdas2022-04-241-12/+18
| | | | | | | | | | | | | | | | | | * Fix #632. The doc string indicates that the linenos table is wrapped in <div class="highlight">, but the actual implementation puts the <div> inside the table cell containing the code. This seems to cause issues as explained in #632, and given it doesn't match the documentation, this PR restores the original behavior. * Fix sample code in comment. * Update CHANGES. * Refactor the wrapping logic. Instead of calling _wrap_div() at the end of wrap(), _wrap_div() is now called after wrap/_wrap_tablinelinenos. This yields the desired behavior but removes the custom <div> generation code.
* Add nowrap option to LatexFormatterTakeshi KOMIYA2022-03-021-13/+23
|
* Let Groff formatter inherit token styles correctly (#2024)Jean Abou-Samra2022-02-051-0/+2
|
* When using the HTML formatter with `linespans=foo`, `linenos=inline`, and ↵Maximilian Hils2022-01-311-4/+4
| | | | | `anchorlinenos=True`, (#2026) the generated anchor links should be `#foo-42` and not `#-42`.
* Happy new year.Georg Brandl2022-01-2514-16/+16
|
* Fix typos (#2030)Kian-Meng Ang2022-01-181-2/+2
|
* Fix #1986.Matthäus G. Chajdas2022-01-062-2/+2
| | | | | Some formatters did not backtrack to parent token types correctly when trying to find a matching style.
* Generate valid links if lineanchors but no linenos set (#2013)Chris Warrick2021-12-311-1/+1
|
* Add a tooltips option to HtmlFormatter. (#1822)Walter Dörwald2021-12-281-2/+17
| | | | | | | | | | | | | * Add a tooltips option to HtmlFormmater. * Rename option tooltips to debug_token_types. * Use explicit if block. * Fix check. * Document how to use the new debug_token_types option for the HTML formatter. * Remove output redirection from example call.
* Add links to lines with css-line numbersDavid Bold2021-11-261-1/+2
|
* Add versionadded info to groff formatter.Matthäus G. Chajdas2021-11-211-0/+2
|
* Merge branch 'master' of https://github.com/marcinzelent/pygments into ↵Matthäus G. Chajdas2021-11-212-0/+167
|\ | | | | | | marcinzelent-master
| * Added groff formattermarcinzelent2021-07-292-0/+167
| |
* | Clean-up unused imports (#1887)Mickaël Schoentgen2021-08-233-6/+0
| |
* | Fix a few make check failures.Matthäus G. Chajdas2021-08-151-2/+2
|/
* encode `str` into `bytes` for `_lookup_ctag` argument; (#1724)Cyker Way2021-05-021-1/+1
| | | | | | check source code of `python-ctags` and `python-ctags3` to see what argument type is expected (answer: `char *`); guess this is python 2 legacy; but now it should work in python 3;
* Filename to <th> if linenos=table (fixes #1757) (#1759)Andy Pearce2021-03-281-3/+14
| | | | | | | | | * Filename to <th> if linenos=table (fixes #1757) * Emit `<th>` for `filename` if `linenos=table`. * Added test cases for filename inclusion. * Updated CHANGES
* Minted compatibility patch (#1737)Jean-François B2021-03-061-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix #1735 pull request * LaTeX: workaround to ensure compatibility with minted This reverts already merged #1735 (after a commit from #1736 to fix it) and applies the first envisioned method discussed in #1734. The reason is that the #1735-#1736 method only partially repairs the minted compatibility. Minted queries from Pygments the stylesheet with a command prefix equal to the style name, which may contain (at least, so far) characters such as - and _, which are not normally allowed in LaTeX macros. So it modifies the meaning of - and _ before telling LaTeX to input the Pygments provided stylesheet. Restoring the normal meaning of - from inside the stylesheet must be carefully localized: at top and bottom of stylesheets some macros will use in their names the - and there the - must be the weird minted one, not the normal one. The #1735-#1736 method thus does fix compatibility with minted but *only* for those style names not using a -, but it creates another issue if used with e.g. style "paraiso-dark" which has a - character in its name. "De guerre lasse", I feel it is simpler to use the somewhat strange very localized hotfix of prefixing - by \string at the one spot where we need it to be its normal self. Hence this PR. Fix #1734.
* LaTeX: workaround minted incompatibility with Pygments 2.8.0 (#1735)Jean-François B2021-03-051-0/+5
| | | | | | Fix: #1731 Fix: #1734 Upstream issue: https://github.com/gpoore/minted/issues/294
* use `id` not `name` for line anchors; (#1725)Cyker Way2021-03-051-2/+2
| | | | | | | | | | | * use `id` not `name` for line anchors; `name` attribute on `a` element is obsolete in html5; * keep `name` to remain compatible with existing code; * update docstring; * update test files;
* Clarify hl_lines usage (fixes #959.)Matthäus G. Chajdas2021-03-051-1/+3
|
* nitsGeorg Brandl2021-03-051-1/+1
|
* Update CHANGES.Matthäus G. Chajdas2021-03-051-0/+2
|
* Add formatter for Pango Markup (#1727)Philipp Imhof2021-03-052-0/+82
| | | | | | | | | | | | | * Add formatter for Pango Markup * Code style improvement * Code improvement + test case * Changed test * retrigger checks * Make test independent of color style
* Fix various issues found by make check.Matthäus G. Chajdas2021-02-141-2/+4
|
* RawToken{Formatter,Lexer}: support Python 3 and handle exceptions (#1602)Anders Kaseorg2021-02-141-8/+6
| | | | | | | | | 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>
* image formatter supports background color (#1374)Hector Medina2021-02-141-6/+21
| | | | | | | | | 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 lineos wrapping (#1701)Matthäus G. Chajdas2021-02-121-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* LaTeX: avoid uneven baselines in case highlighting uses \fcolorbox (#1708)Jean-François B2021-02-121-2/+2
| | | | | | | | | | | | | | 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.
* LaTeX: keep scope of \fboxsep local (#1709)Jean-François B2021-02-121-2/+2
| | | | | | | 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
* LaTeX: use \@namedef (refactoring) (#1710)Jean-François B2021-02-121-2/+1
| | | | | | | | | | | | $ 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...
* LaTeX: \catcode assignment should be terminated (#1711)Jean-François B2021-02-121-1/+2
| | | | | | | | 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.
* Support anchored line numbers in inline mode (#1591)Kevin Deldycke2021-02-061-2/+10
| | | | | * Add support for anchored line numbers in inline rendering mode * Fix tests rendering anchored line number in inline mode
* linenos support for terminal256 (#1674)Jiamin Shen2021-02-061-1/+23
|
* 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>