theNewDynamic / gohugo-theme-ananke

Ananke: A theme for Hugo Sites
https://gohugo-ananke-theme-demo.netlify.app/
MIT License
1.15k stars 1.16k forks source link

Syntax highlight not working #215

Open bilotAIcore opened 5 years ago

bilotAIcore commented 5 years ago

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.

susodapop commented 5 years ago

Would you post an example of the code so we can investigate?

jmezach commented 4 years ago

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:

Screenshot 2019-11-13 15 29 07

As you can see it's just white text on a black background, but no highlighting of keywords or anything. Am I missing something?

agrrh commented 4 years ago

I managed to fix this:

$ hugo version
Hugo Static Site Generator v0.63.1-CE9ACEB7/extended linux/amd64 BuildDate: 2020-01-23T20:15:47Z
  1. Generate syntax CSS style:
    hugo gen chromastyles --style=monokai > static/css/syntax-monokai.css
  2. 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:

jmooring commented 5 hours ago

This can be closed. This is the rendered page when building with Hugo v0.135.0:

image