summaryrefslogtreecommitdiff
path: root/pygments/formatters/html.py
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* 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
|
* 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.
* 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-251-3/+3
|
* 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
|
* 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
* 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
|
* 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.
* 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
* Run pyupgrade across codebase to modernize syntax and patterns (#1622)Jon Dufresne2021-01-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-031-3/+3
|
* 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
* 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.
* all: remove "u" string prefix (#1536)Georg Brandl2020-09-081-6/+6
| | | | | | | | | | | * 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-061-8/+4
|
* Update copyright year (fixes #1514.)Matthäus G. Chajdas2020-08-221-3/+3
|
* 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
* Remove Python 2 compatibility (#1348)Georg Brandl2020-02-291-6/+6
| | | | | | | | | | | * 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
|
* html formatter: lineseparator needs to be unicodeGeorg Brandl2019-11-261-1/+1
| | | | Fixes #1053
* 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-071-4/+3
| | | | Also uniformize usage of the 'with' contact manager to prevent resource leaks.
* Copyright update.Georg Brandl2017-01-221-1/+1
|
* Add support for partials and path segments for Handlebars.Christian Hammond2016-11-041-0/+851
This introduces support for some missing features to the Handlebars lexer: Partials and path segments. Partials mostly appeared to work before, but the `>` in `{{> ... }}` would appear as a syntax error, as could other components of the partial. This change introduces support for: * Standard partials: `{{> partialName}}` * Partials with parameters: `{{> partialName varname="value"}}` * Ddynamic partials: `{{> (partialFunc)}}` * Ddynamic partials with lookups: `{{> (lookup ../path "partialName")}}` * Partial blocks: `{{> @partial-block}}` * Inline partials: `{{#*inline}}..{{/inline}}` It also introduces support for path segments, which can reference content in the current context or in a parent context. For instance, `this.name`, `this/name`, `./name`, `../name`, `this/name`, etc. These are all now tracked as variables.