forestryio / hugo-theme-novela

Novela, the simplest way to start publishing with Hugo and Forestry.
https://hugo-novela-forestry.netlify.app/
MIT License
361 stars 192 forks source link

Syntax highlighting #56

Closed vinaygaba closed 4 years ago

vinaygaba commented 4 years ago

I've tried a bunch of stuff that I read in different forums but none seem to work for me. I've included this in my config.yaml file

PygmentsCodeFencesGuessSyntax: true
PygmentsCodeFences: true
pygmentsUseClasses: true

This is what the code in the blog looks like when I try to either use backticks with language or make use of hugu's highlight block.

Screen Shot 2020-09-27 at 9 35 15 PM
DirtyF commented 4 years ago

Syntax highlighting is working fine on our demo: https://hugo-novela-forestry.netlify.app/post/2019-04-31-understanding-the-gatsby-lifecycle/

This theme is using Prism to highlight code.

vinaygaba commented 4 years ago

@DirtyF That is strange :( Does it require me to set any flags in my yaml file? Do I have to do anything special in the post? I can't find the code for the page you linked in the exampleSite folder.

DirtyF commented 4 years ago

You don't need to, as it's using a JS library and not Hugo options. You need to add triple fenced codeblock with the name of the language you want to highlight: https://raw.githubusercontent.com/forestryio/novela-hugo-starter/master/content/post/2019-04-31-understanding-the-gatsby-lifecycle.md

vinaygaba commented 4 years ago

@DirtyF So I copy pasted the code from this example and this works fine. But when I change the programming language to java it doesn't. That's the language I was using it with. Seems to be a problem with that. You can try it with this code

ArrayMap<String, String> arrayMap = new ArrayMap<String, String>();
arrayMap.put("key", "value");
String value = arrayMap.get("key");
vinaygaba commented 4 years ago

Seems like only the languages listed in this comment are currently working - https://github.com/forestryio/hugo-theme-novela/blob/811b4ca4ebef064f7e016ea589175cccdd75cbab/assets/css/prism.css#L2

DirtyF commented 4 years ago

@vinaygaba Thanks for the feedback, adding those files in your repository to customize what prism version you need seems the best way to go here.

vinaygaba commented 4 years ago

Seems reasonable! Thanks!