jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
190 stars 61 forks source link

Add provided classes to wrapper div #71

Open duckwork opened 5 years ago

duckwork commented 5 years ago

With a source like this:

``` {.python .numberLines}
if is_true:
    pass

pandoc generates

I'd like the enclosing `<div>` to include the classes I've specified in the source (or at least `python`.) I'm thinking of changing the style of different code blocks based on which language they are.

I've traced the issue to skylighting, in the [`formatHtmlBlock` function](https://hackage.haskell.org/package/skylighting-core-0.7.7/docs/src/Skylighting.Format.HTML.html#formatHtmlBlock). I think all that's needed is a change in the first line:

H.div ! A.class_ (toValue "sourceCode") $

to

H.div ! A.class_ (toValue $ Text.unwords classes) $



I'm writing this as an issue to see if there'd be interest in a pull request for this change.
dbaynard commented 5 years ago

The div is only there to fix a spacing issue. Can you just change the style of the pre?

duckwork commented 5 years ago

The issue comes in when adding background colors. Say I want to color all python blocks as blue and all bash as green, while everything else is black. Currently, it looks like this jsfiddle. With the proposed change, it'll look like this one. Note how in the first fiddle, also, the code lines are only highlighted to the end of each code line.