Code Monkey home page Code Monkey logo

highlight-loader's Introduction

build status

highlight-loader - Applies highlight.js to given module

This loader can apply syntax-highlighting via highlight.js in two ways:

  1. Given HTML (either straight HTML or the output of something like markdown-loader), it will replace the contents of <code> blocks with syntax-highlighted HTML generated by highlight.js. This is the default behavior.

  2. Given a raw file, it will return syntax-highlighted HTML generated by highlight.js. This can be enabled by using the raw parameter.

You probably want to pass the HTML output of this loader through html-loader.

Parameters

raw

If any value is provided, the loader will interpret its input as a raw string to run through highlight.js.

By default, the language is auto-detected. To specify a language, use the lang parameter.

lang

Specify a language for highlight.js. Only works in combination with the raw parameter.

(To specify a language for non-raw input, apply lang-[something] classes to your <code> blocks.)

Examples

// Reading HTML from parsed markdown ...
var highlightedMarkdown = require('html!highlight!markdown!./README.md');

// Reading a file's raw contents and auto-detecting the language ...
var highlightedRaw = require('html!highlight?raw=true!./example-script.js');

// Reading a file's raw contents and specifying the language ...
var highlightedRawCss = require('html!highlight?raw=true&lang=css!./example-stylesheet.css');

Contributors

License

highlight-loader is available under MIT. See LICENSE for more details.

highlight-loader's People

Contributors

bebraw avatar davidtheclark avatar jacargentina avatar zanemiller avatar

Watchers

 avatar James Cloos avatar  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.