Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swig-highlight

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swig-highlight

extension for the swig templating engine, adding highlight.js code blocks to be rendered!

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

swig-highlight Build Status Dependencies status

extension for the swig templating engine, adding highlight.js code blocks to be rendered!

How-To install

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.

Usage

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">

Known Issues

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!

Keywords

FAQs

Package last updated on 18 Apr 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc