Closed maelle closed 3 years ago
And when not using downlit, I see a missing space after the line numbers:
Hmm I think it is using Hugo, but not updated for goldmark rendering options:
from config.toml https://github.com/apreshill/blogophonic/blob/81181a6529087fc3d6931a2584bdf95c6619e864/config.toml#L10-L13
May need to reconfigure: https://gohugo.io/getting-started/configuration-markup#highlight
Oops you are right, I should have known better, I removed these lines from the config. I suppose my issue is now
Ok, working on this in the chroma
branch! Is this the setting for the classes variable now?
https://chroma--cranky-lalande-e3373f.netlify.app/blog/
[markup]
[markup.highlight]
anchorLineNos = false
codeFences = true
guessSyntax = false
hl_Lines = ""
lineAnchors = ""
lineNoStart = 1
lineNos = false
lineNumbersInTable = true
noClasses = false <--?
style = "monokai"
tabWidth = 4
Also some helpful links for me: https://discourse.gohugo.io/t/pygmentsuseclasses-true-not-generating-classes/15080/9 https://github.com/zwbetz-gh/minimal-bootstrap-hugo-theme/blob/master/README.md#syntax-highlighting
OK hitting a stopping point. Notes:
noClasses = true
, I don't need to supply my own CSS. This works.noClasses = false
, then I need to include my chroma.css
file. BUT if I do that, the background color from the highlighter is overriden by the site background color. 😞 And more generally, you cannot select your highlighter style any longer, i.e., this style = "dracula"
does nothing.:sob: and if there is no chroma.css one cannot use downlit, right?
I just don't know. I think the difference is that I can control everything within like tidyverse.org, because we don't want to configure things. But if I want to give users the option to change highlighters, I would need to configure each one to support individually. So, trade-offs. Relevant thread?
https://github.com/matcornic/hugo-theme-learn/issues/187
I think I have 3 choices to make a highlighter that people can choose:
noClasses = true
and it works great, but not for .Rmd
😭 . But people can select any chroma style in config.toml using style = "manni"
for example.highlight.js
instead- that would work for .Rmd
and .Rmarkdown
files, so has benefits. This now surprisingly feels like the easiest, but would also have to build in a config flag to turn "off" Hugo Chroma highlighting (maybe codeFences = false
does this for me?).noClasses = false
and add support for specific chroma highlight styles (i.e., maybe dracula
, fruity
, friendly
, and pygments
; list) by including some kind of "themeable" highlight style. This feels like the heaviest lift, and still won't work for .Rmd
until downlit support gets integrated.At the end this highlighting thing will always bit complicated. I would sum up technically with this:
At the end, it is a matter of who does the highlighting :
First two will only work with one type of file only. having consistency in a website will require to use only one type of file. highlight.js is the more generic as it will apply no matter the format used. downlit would approach that but it will only work for .Rmd when using only R code. If you have for example a YAML chunk you want to highlight, and you configured the Rmd file to use downlit to output Chroma, then the other code non R code chunk would not be highlighted by Chroma at the end.
Hope it helps understand a bit more how all this works together to see what is possible.
One (crazy?) solution would be to some CSS for Pandoc and some CSS for Chroma using the same color ! The parser would result a bit different in what is highlighted with which color but I think it would be minimal difference.
Maybe there could be a few lines in the docs to tell people how they'd need to customize things based on their workflow? Or maybe this theme should discourage people from using Rmd to html 😜
In any case I think having an external css, not inline default Chroma style is better since none of the Chroma styles has high enough contrast (unless it changed since the last time I looked).
@maelle
In any case I think having an external css, not inline default Chroma style is better since none of the Chroma styles has high enough contrast (unless it changed since the last time I looked).
I think this can always be an option for more advanced users- I'll build in a slot in the config file to name/import in your own CSS highlighter. For everyone else though, I'm going to go with option 1:
.Rmarkdown
and .md
will look the same, plus I have some layouts that bring in {{ .TableOfContents }}
so this is good.
Users get to pick their highlight style of choice from the built-in Chroma options.
[x] TODO: add a slot in config.toml to specify custom CSS (for a highlighter or just any .css
file)
Done here: https://github.com/apreshill/apero/pull/62
https://distracted-yonath-b034c9.netlify.app/blog/2021-01-04-hi-hugo/ from https://github.com/maelle/apresacademic where I used R/build.R to get downlit highlighting.
I think blogophonic has some special code highlighting (to number lines) :thinking: