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.
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.
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.
This allows the boolean options to be reconfigured, e.g:
```go
options := getOptions()
options = append(options, html.WithLineNumbers(true))
```
Fixes#301
- location and size looks fine now even when scaled and with larger files (used `em` for line height and `ch` for
width)
- svg width/height looks ok now, width has some problems on scaling (seems this needs to be a unit like `px` and cannot be `ch` so it's a rough estimate)
- updated liberation mono font to 2.00.5 since the current one had wrong width for the full block character (https://github.com/liberationfonts/liberation-fonts)
basic version without any options. colors and font-styles seem to be ok.
rough support for text background in styles like `murphy` using predrawn
rectangles (svg has no text background attribute).
things to improve:
- svg width attribute (`<svg width=""`)
- linenumbers
- highlighting
- embedded font
- tabwidth option
- margins?
- better position/width calculation (rectangles not correctly drawn on
resize)
'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.
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.
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.
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