
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
swig-highlight
Advanced tools
extension for the swig templating engine, adding highlight.js code blocks to be rendered!
extension for the swig templating engine, adding highlight.js code blocks to be rendered!
Wherever you're including require('swig')
, you'll have to include swig-highlight
as
well.
Enable it with the helper like this:
var swig = require('swig');
require('swig-highlight').apply(swig);
apply
adds the new tag into swig.
Use it barebone like this (tag name is customizable here):
var swig = require('swig'),
swig-hl = require('swig-highlight');
swig.setTag('hlcode', swig-hl.parse, swig-hl.compile, swig-hl.ends, swig-hl.block);
You can start using {% highlight %}<CODE>{% endhighlight %}
in your code.
For now you can enforce a language highlighting (list), or let highlight.js guess by omitting it.
{% highlight 'bash' %}
###### COMMENT HERE
if [ "$UID" -ne 0 ]
then
echo "Superuser rights is required"
echo 'Printing the # sign'
exit 2
fi
{% endhighlight %}
You will need to read also highlight.js usage to make your html be correctly colorized.
As an easy hint, just include (as suggested by highlight.js authors) a default css from Yandex
<link rel="stylesheet" href="http://yandex.st/highlightjs/8.0/styles/default.min.css">
Using the highlight tag with the code being a variable instead of a string does not work currently.
There is no limitation around this, just requires quite a bit of coding, so PR are welcome!
FAQs
extension for the swig templating engine, adding highlight.js code blocks to be rendered!
The npm package swig-highlight receives a total of 12 weekly downloads. As such, swig-highlight popularity was classified as not popular.
We found that swig-highlight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.