But now I have an article which causes problems (https://gist.github.com/Fryboyter/a06cd3f8ecb87fb3892affe09fb6715c). Here for example only Fryboyter is shown in line 19. For lines 20 to 22 only empty lines are displayed instead of the code. And so on. The problem here seems to be the div.
If I look at the source code of the page Hugo created, then the complete code I want to highlight is present.
So does anyone have any idea how to display the complete code with Hugo and Prism.js? When I use the highlighter of Hugo everything is displayed, but here long lines of code are not wrapped, so that you have to scroll horizontally or the text overlaps to the right. Therefore I would prefer Prism.js.
hugo env
Hugo Static Site Generator v0.54.0/extended linux/amd64 BuildDate: unknown
GOOS=“linux”
GOARCH=“amd64”
GOVERSION=“go1.11.5”
It’s really difficult to say what is wrong here. How are you implementing Prism? How are you rendering your content? What other styles are present? I would suggest having a read about Requesting Help and perhaps creating a minimal repo you can share to help us help you.
I refer to the CSS file in the file header.html. In the file footer.html I refer to the JS file. I already tried to put everything into the header file. In the article the code will be highlighted as follows:
Sorry I didn’t get the chance to test it before today. If I take your example, everything works.
If I exchange the code you have highlighted for the one that is causing me problems, it won’t work again. But I also noticed something. If I call the markdown file directly from Codeberg (https://codeberg.org/Fryboyter/hugo/src/branch/master/content/posts/2017/index-twig-des-fryboyter-themes.md) I get the same incomplete display of the highlighted code. But in this case neither prism.js nor prism.css should be loaded, right? If I’m right (and I didn’t do anything wrong) it should be a markdown problem.
You can not use plain HTML code inside <code> because it will be parsed as HTML. You have to encode each < and > Symbol to prevent this. This is not an hugo or prism.js issue.
I would have expected all sorts of reasons causing the problem. But not that one. Sometimes you can’t see the forest for the trees. Now it works. Many thanks for the hint.