Git Product home page Git Product logo

swig-highlight's Introduction

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!

swig-highlight's People

Watchers

James Cloos avatar Marcel A. Weder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.