jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
195 stars 62 forks source link

Inline syntax highlighting background (LaTeX) #122

Open Kangie opened 3 years ago

Kangie commented 3 years ago

The \VERB environment as implemented in the pandoc defaults template does not apply the background specified in the skylighting theme, resulting in potentially unreadable code if syntax highlighting is enabled on inline code and a dark theme is in use (e.g. breezedark).

Example:

A line with `function update_post_thumbnail_cache( $wp_query = null )`{.php} inline code and syntax highlighting.
A line with `function update_post_thumbnail_cache( $wp_query = null )` inline code.

An effective workaround in the short term is to not use fenced code attributes on inline code, which has pandoc use \texttt rather than \VERB.

jgm commented 3 years ago

It is reported on pandoc-discuss that surrounding the \VERB with \colorbox can work. That's something I want to try when I have a chance.

jgm commented 3 years ago

This would need to be done (if it is done) for all formats, not just LaTeX.

In HTML, this would require putting the color and background-color attributes on .sourceCode rather than div.sourceCode in the CSS.

In LaTeX, it's not so easy. \colorbox works but doesn't wrap, which is a problem. See https://tex.stackexchange.com/questions/5959/cool-text-highlighting-in-latex for some overly complex solutions (wouldn't want to go there).

in Word, TODO...

In MS, TODO...