gohugo-theme-ananke
gohugo-theme-ananke copied to clipboard
Syntax highlight not working
I'm trying to get syntax (r/python) to be highlighted properly in Rmarkdown posts but sofar had 0 luck. For example, changing the pygments options only seem to affect code blocks in .md files. I would apreciate a guide on what to alter in the site source codes to make this work.
Thanks.
Would you post an example of the code so we can investigate?
I'm seeing the same thing. For example, I've put this into my post markdown:
```csharp
[Route("api/v2/products/{productName}/groups/{groupName}/features")]
public class FeatureV2Controller
{
...
[Route("{title}/versions/{version}")]
[HttpPost]
public async Task<ActionResult<Feature>> PostAsync(Feature feature, string productName, string groupName, string title, string version)
{
if (!feature.Title.Equals(title, StringComparison.OrdinalIgnoreCase))
...
}
...
}
And it renders like this:

As you can see it's just white text on a black background, but no highlighting of keywords or anything. Am I missing something?
I managed to fix this:
$ hugo version
Hugo Static Site Generator v0.63.1-CE9ACEB7/extended linux/amd64 BuildDate: 2020-01-23T20:15:47Z
- Generate syntax CSS style:
hugo gen chromastyles --style=monokai > static/css/syntax-monokai.css
- Enable syntax CSS and highlight settings in config:
markup: highlight: codeFences: true guessSyntax: false hl_Lines: "" lineNoStart: 1 lineNos: false lineNumbersInTable: true noClasses: false style: monokai # looks like this has no effect, only imported CSS matters tabWidth: 4 params: ... custom_css: - css/custom.css - css/syntax-monokai.css
Then my site properly highlight code which is just placed between "```" blocks.
References:
- https://gohugo.io/content-management/syntax-highlighting/#generate-syntax-highlighter-css
- https://gohugo.io/getting-started/configuration-markup#highlight