1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-21 21:17:50 +02:00

29 Commits

Author SHA1 Message Date
Siavash Askari Nasr
d6e61d3cbe Use span for .line, put code inside <code>
Apparently only "phrasing content" are permitted inside `pre` and
`code`, and `div` is not one of them, so replace it with `span`, `div`
wasn't necessary anyway.

Also it makes sense to put code inside `code` tag(except for line
numbers).

Removed `overflow:auto` and `width: auto` as they didn't seem to be
necessary and actually prevented horizontal scroll bar to appear when content
didn't fit in the viewport.
2021-11-10 19:52:49 +11:00
Siavash Askari Nasr
5ed5054d73 Put lines in a div & code lines in a span, Add WrapLongLines Option 2021-11-09 19:14:33 +11:00
Alec Thomas
54fd3bc12f Clean up imports and make cmd/chroma its own module. 2021-06-18 16:56:50 +10:00
rhymes
c8581d47ee Add tabindex="0" to default <pre> wrapper 2021-05-24 07:16:54 +10:00
Alvaro Aleman
ab61726cdb Make linkeable lines a link to themselves
Currently its already possible to make line lumbers linkeable. Getting
such a link however requires the end user to look at the pages source
and then to manually edit the URL, which is not a great UX.

This PR changes that to make the line numbers a link to themselves, so
clicking on them gives a link to that line that can then be passed
around, similiar to e.G. GitHub.
2020-11-03 21:31:04 +11:00
Cameron Little
cc5e532d14 Add failing test for invalid css with allClasses
This was reported at https://github.com/gohugoio/hugo/issues/7207
2020-05-09 22:56:49 +10:00
Pablo Santiago Blum de Aguiar
9e22bd6e2f Consider baseLineNumber when calculating the column width 2020-01-10 08:23:54 +11:00
Bjørn Erik Pedersen
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
Bjørn Erik Pedersen
d3926cc0e1 Add WithPreWrapper option 2019-11-20 20:09:17 +11:00
Alec Thomas
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
Alec Thomas
da5ac60d8c Add golangci-lint and fix all lint issues. 2018-12-31 22:46:59 +11:00
Alec Thomas
881a441774 Don't keep trailing empty tokens when splitting tokens by line.
Fixes #155. Fixes #209.
2018-12-27 16:20:38 +11:00
Alec Thomas
fb4c38e204 Fix build (see #190). 2018-11-08 17:16:58 +11:00
Daniel Eloff
9c3abeae1d Tokens by value (#187)
This results in about a 8% improvement in speed.
2018-11-04 10:22:51 +11:00
Alec Thomas
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
John Millikin
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
John Millikin
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
John Millikin
df4ec264da Render HTML class prefixes. 2018-02-18 14:58:46 +11:00
Alec Thomas
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
Alec Thomas
71ddf5511a Fix README for test fixtures. 2018-01-02 20:59:02 +11:00
Denis Brodbeck
c9f612c194 Fix broken css rules output
Strip leading semicolons in combination with line numbers.

fixes #98
2017-12-11 21:20:14 -08:00
Alec Thomas
573c1d157d Ensure a newline exists at the end of files.
Fixes #42.
2017-09-29 21:59:52 +10:00
Alec Thomas
bc2d6680e4 Run gofmt -s over the codebase. 2017-09-26 22:05:55 +10:00
Alec Thomas
e2d6abaa64 Document and add iterator panic recovery. 2017-09-20 23:06:23 +10:00
Alec Thomas
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
Alec Thomas
3f230ec717 Add support for line numbers. 2017-09-20 13:33:44 +10:00
Alec Thomas
feb78ed6f3 Combine HTML formatting functions. 2017-09-19 23:04:10 +10:00
Alec Thomas
c8636118d5 Remove unused dark/light style type. 2017-09-18 14:19:59 +10:00
Alec Thomas
d12529ae61 HTML formatter + import all Pygments styles. 2017-07-20 00:01:29 -07:00