1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-15 01:14:21 +02:00
Commit Graph

50 Commits

Author SHA1 Message Date
19d5ee688c Highlight the line number targeted by the URL anchor
This currently works only when `html.WithClasses(true)` is used.
The same colors as for the pre-highlighted lines are used.
Only the line number is highlighted, so difficult to notice, but
better than nothing.
2019-12-31 11:10:38 +11:00
a41c89767d Add the option of making the line numbers linkable 2019-12-12 17:31:43 -08:00
5921c52787 Add bool argument to WithClasses, WithLineNumbers etc.
This allows the boolean options to be reconfigured, e.g:

```go
options := getOptions()
options = append(options, html.WithLineNumbers(true))
```

Fixes #301
2019-11-22 10:13:00 +11:00
d3926cc0e1 Add WithPreWrapper option 2019-11-20 20:09:17 +11:00
bbc59ac372 Emit error tokens when there's a group mismatch.
Also don't panic/recover, as we no longer use panic to report "real"
errors.

Fixes #295.
2019-10-24 17:03:35 +11:00
e6a56651ad Add width:100% to content <td> when inlining styles.
Fixes #225.
2019-07-20 23:19:20 +10:00
da5ac60d8c Add golangci-lint and fix all lint issues. 2018-12-31 22:46:59 +11:00
2a59c2c77e Synthesise meta style-entries on demand.
This includes line highlighting, numbers, etc.

Fixes #211.
2018-12-31 11:33:36 +11:00
69c9a262c3 Expose Colour.BrightenOrDarken (useful for #211). 2018-12-31 10:48:45 +11:00
881a441774 Don't keep trailing empty tokens when splitting tokens by line.
Fixes #155. Fixes #209.
2018-12-27 16:20:38 +11:00
fb4c38e204 Fix build (see #190). 2018-11-08 17:16:58 +11:00
a4f179974b move SplitTokensIntoLines into chroma/iterator.go, fixes issue #190 2018-11-08 16:21:45 +11:00
9c3abeae1d Tokens by value (#187)
This results in about a 8% improvement in speed.
2018-11-04 10:22:51 +11:00
e36baa268a Add option to prevent surroundign pre tags 2018-09-18 19:44:44 +10:00
371820dad6 Assign .gl class to GenericUnderline; add CSS rules for the same
'l' in gl is for under(l)ine, as the "gu" class is taken by
GenericSubheading.

- Rules for GenericUnderline are added to all the styles
- Make "Underline" style insert "text-decoration: underline" in CSS.

Fixes https://github.com/alecthomas/chroma/issues/159.
2018-08-01 17:28:52 -04:00
3020e2ea8c Fix bug with nested newlines.
Fixes #124.

Also reinstitute lexer tests that disappeared during package split.
2018-03-03 10:16:21 +11:00
aaa96c6984 Avoid adding an HTML prefix to empty class names.
This makes the raw markup a bit cleaner when there's lots of `Text`
tokens.
2018-02-25 19:46:48 +11:00
d7ee3c10b0 Add newlines in line number spans when wrapping in an HTML table.
Since these are wrapped in a `<pre>`, newlines hint the browser that the
line numbers should be on separate lines. This helps when rendering
content with broken CSS, or in a text-only browser.
2018-02-25 17:52:15 +11:00
df4ec264da Render HTML class prefixes. 2018-02-18 14:58:46 +11:00
563aadc53c Moved lexers into alphabetical sub-packages.
This was done to speed up incremental compilation when working on
lexers. That is, modifying a single lexer will no longer require
recompiling all lexers.

This is a (slightly) backwards breaking change in that lexers are no
longer exported directly in the lexers package. The registry API is
"aliased" at the old location.
2018-02-15 21:09:02 +11:00
e4cd1649a3 Ensure that HTML code column expands to full width of container.
Fixes #114.
2018-02-11 21:14:56 +11:00
03fd03809c fix func compressStyle(s string) for CSS Shorthand properties 2018-02-11 19:10:59 +11:00
71ddf5511a Fix README for test fixtures. 2018-01-02 20:59:02 +11:00
c9f612c194 Fix broken css rules output
Strip leading semicolons in combination with line numbers.

fixes #98
2017-12-11 21:20:14 -08:00
02c4adc066 Add a chroma class wrapper when in "table mode" (#63)
This commits adds a div wrapper when linenumbers are formatted in table, to get the correct CSS matchers.

This commit also fixes some CSS table issues when tables are put into a larger context with other stylesheets:

* No borders.
* Overflow to fit in potentially narrower containers.

Fixes #62
2017-10-14 20:02:40 +11:00
4a55aefee6 Adding HasClasses method for HTML formatter (#61)
* Adding HasClasses method for HTML formatter

* Removing helper function and simply export the field
2017-10-14 08:41:40 +11:00
27733ac753 Add table styled line numbers (#54)
Fixes #52
2017-10-13 10:49:20 +11:00
0e0960930d Don't output trailing \n for HTML-only fragment.
See #47.
2017-09-30 14:45:37 +10:00
573c1d157d Ensure a newline exists at the end of files.
Fixes #42.
2017-09-29 21:59:52 +10:00
33f604c892 Always use CSS class from StandardTypes.
As opposed to remapping to classes that exist in the current style.
2017-09-27 22:05:47 +10:00
80d3b96869 Ensure class names from default set exist. 2017-09-27 22:01:03 +10:00
bc2d6680e4 Run gofmt -s over the codebase. 2017-09-26 22:05:55 +10:00
bdc1124369 Switch to Pygments-style CSS class names.
Add GitHub theme + CSS to style importer.
2017-09-25 21:46:25 +10:00
b0295f66bd Remove spurious newline in HTML output.
Fixes #29.
2017-09-25 15:25:32 +10:00
c984ca45c7 Add html.BaseLineNumber(n).
Fixes #22.
2017-09-24 20:33:50 +10:00
1af7e1a0bc Adjust line number padding a bit. 2017-09-23 22:45:05 +10:00
d5083b3f7c Big changes to the style and colour APIs.
- Styles now use a builder system, to enforce immutability of styles.
- Corrected and cleaned up how style inheritance works.
- Added a brightening function to colours
- HTML formatter will now automatically pick line and highlight colours
  if they are not provided in the style. This is done by slightly
  darkening or lightening.

Fixes #21.
2017-09-23 22:09:46 +10:00
1724aab879 Implement compile-time lexer mutators.
This should fix #15.
2017-09-21 20:02:53 +10:00
e2d6abaa64 Document and add iterator panic recovery. 2017-09-20 23:06:23 +10:00
cc0e4a59ab Switch to an Iterator interface.
This is to solve an issue where writers returned by the Formatter
were often stateful, but this fact was not obvious to the API consumer,
and failed in interesting ways.
2017-09-20 22:19:36 +10:00
3f941ddff4 Correctly add styles for line numbers and line highlights when inling.
Fixes #7. Fixes #9.
2017-09-20 20:32:15 +10:00
a5637e60b2 Support for highlighting ranges of lines. 2017-09-20 14:24:49 +10:00
3f230ec717 Add support for line numbers. 2017-09-20 13:33:44 +10:00
feb78ed6f3 Combine HTML formatting functions. 2017-09-19 23:04:10 +10:00
87183b3633 Add HTML formatter option for setting the tab width. 2017-09-19 13:14:29 +10:00
fbc889aad6 Correct HTML output + add R/S.
Fixes #1, #2, #3.
2017-09-19 10:30:10 +10:00
c8636118d5 Remove unused dark/light style type. 2017-09-18 14:19:59 +10:00
1374cf9ffb More README. 2017-09-18 13:59:11 +10:00
86bda70acd Switch to github.com/dlclark/regexp2 2017-09-15 22:18:20 +10:00
d12529ae61 HTML formatter + import all Pygments styles. 2017-07-20 00:01:29 -07:00