Prism Code Highlighting Showcase
This theme uses Prism for code highlighting. Other Hugo themes usually include a pre-configured version of Prism, which complicates updates and clutters the source code base with third-party JavaScript.
Only the Prism features you select in the Hugo site configuration are bundled by
the build process. This way, Prism can be easily updated with npm
and the
size of the JavaScript and CSS bundles are minimized by only including what you
need.
Here is a an example configuration demonstrating how to configure languages
and plugins
in the config.toml
file of your Hugo site:
Languages
The following languages are available:
Plugins
Before using a plugin in production, read its documentation and test it
thoroughly. E.g., the remove-initial-line-feed
plugin
is still available despite being deprecated in favor of normalize-whitespace
.
Many Prism plugins require using <pre>
tags with custom attributes. Hugo uses
Goldmark as Markdown handler, which by default doesn’t render raw inline HTML,
so make sure to enable unsafe
rendering if required:
The following plugins are available:
Examples
Copy to Clipboard
copy-to-clipboard
requires the toolbar
plugin, so make sure to add it
after adding toolbar
in the config.toml
file:
Config:
Line Numbers
Config:
Input:
Output:
Command Line
Config:
Input:
Output:
Diff Highlight
Config:
Input:
Output: