"Code Block" on GitHub Pages is not rendering and throws an error #23170
-
Situation: The repository I decided to clone was the Raspberry Pi documentation repository located here: The file in question is the cmio-camera.md file. My copy of it is located here: The problem I am experiencing: When I try to create a GitHub page based on the material downloaded, I get the following error: What I have done:
This is the block of offending code.
When I “view” the page, everywhere the three back-ticks surround a block, it’s properly rendered as a code block. Obviously it works on the Raspberry Pi documentation pages, as it is up and published. When I change the back-ticks to a four-space indent, the same thing happens - it formats correctly when “viewed” but throws the same error when I try to build the page. If someone can tell me why this is not compiling correctly, I wold greatly appreciate it. Thanks! Jim “JR” |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hey @jharris1993! 👋 Hmmm, so, the On GitHub, at least, the code block you posted is causing problems because Jekyll’s parser treats any code using double curly braces {{ text }} or curly braces and percent signs {% text %} that’s included in inline or fenced code blocks as if it’s a Liquid tag. To stop this happening you’ll need to surround any affected code blocks with some tags to tell Jekyll to ignore them: {% raw %} your code here {% endraw %} You can also surround these tags with Markdown comments, meaning they won’t render on GitHub.com: [//]: # ({% raw %}) your code here [//]: # ({% endraw %}) Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Perhaps this could be added to the documentation for code blocks since we can’t assume that any language is going to conform to Liquid’s standards. Or perhaps an even better way would be to instruct Liquid that anything within a code block is automatically assumed to be “raw” which is the universally expected behavior of code blocks. Thanks for your help, it’s appreciated! |
Beta Was this translation helpful? Give feedback.
-
“Unable to render code block” https://github.com/PopicLab/cue/blob/master/notebooks/tutorial.ipynb |
Beta Was this translation helpful? Give feedback.
Hey @jharris1993! 👋
Hmmm, so, the
raspberrypi/documentation
repo you link to isn’t actually generating a GitHub Pages site, so they’re not using GitHub’s build system. How they process markdown during the page build process might be totally different.On GitHub, at least, the code block you posted is causing problems because Jekyll’s parser treats any code using double curly braces {{ text }} or curly braces and percent signs {% text %} that’s included in inline or fenced code blocks as if it’s a Liquid tag.
To stop this happening you’ll need to surround any affected code blocks with some tags to tell Jekyll to ignore them:
{% raw %}
your code here
{% endraw %}
You can also surround the…