How to use lowlight - 10 common examples

To help you get started, we’ve selected a few lowlight examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github patternplate / patternplate / packages / client / src / app / components / common / code / highlight.js View on Github external
import scss from "highlight.js/lib/languages/scss.js";
import stylus from "highlight.js/lib/languages/stylus.js";

import js from "highlight.js/lib/languages/javascript.js";
import ts from "highlight.js/lib/languages/typescript.js";
import json from "highlight.js/lib/languages/json.js";

import xml from "highlight.js/lib/languages/xml.js";
import md from "highlight.js/lib/languages/markdown.js";

import bash from "highlight.js/lib/languages/bash.js";

// CSS and friends
low.registerLanguage("css", css);
low.registerLanguage("less", less);
low.registerLanguage("scss", scss);
low.registerLanguage("stylus", stylus);

// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);

// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);
github patternplate / patternplate / packages / client / src / app / components / common / code / highlight.js View on Github external
low.registerLanguage("stylus", stylus);

// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);

// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);

// (s)hell(ish)s
low.registerLanguage("bash", bash);
// Low.registerLanguage('shell', bash);

const languages = [
  "css",
  "less",
  "scss",
  "stylus",
  "js",
  "javascript",
  "jsx",
  "ts",
  "tsx",
  "typescript",
github patternplate / patternplate / packages / client / src / app / components / common / code / highlight.js View on Github external
import json from "highlight.js/lib/languages/json.js";

import xml from "highlight.js/lib/languages/xml.js";
import md from "highlight.js/lib/languages/markdown.js";

import bash from "highlight.js/lib/languages/bash.js";

// CSS and friends
low.registerLanguage("css", css);
low.registerLanguage("less", less);
low.registerLanguage("scss", scss);
low.registerLanguage("stylus", stylus);

// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);

// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);

// (s)hell(ish)s
low.registerLanguage("bash", bash);
// Low.registerLanguage('shell', bash);
github patternplate / patternplate / packages / components / lib / code / index.js View on Github external
const hast = highlight(language, source);
  return toElements(hast);
}

// Highlight configuration

// CSS and friends
low.registerLanguage('css', css);
low.registerLanguage('less', less);
low.registerLanguage('scss', scss);
low.registerLanguage('stylus', stylus);

// JS and friends
low.registerLanguage('js', js);
low.registerLanguage('javascript', js);
low.registerLanguage('jsx', js);
low.registerLanguage('ts', ts);
low.registerLanguage('tsx', ts);
low.registerLanguage('typescript', ts);
low.registerLanguage('json', json);

// HTML and friends
low.registerLanguage('html', xml);
low.registerLanguage('xml', xml);
low.registerLanguage('md', md);
low.registerLanguage('markdown', md);

// (s)hell(ish)s
low.registerLanguage('bash', bash);
// Low.registerLanguage('shell', bash);

const languages = ['css', 'less', 'scss', 'stylus', 'js', 'javascript', 'jsx', 'ts', 'tsx', 'typescript', 'json', 'html', 'xml', 'md', 'markdown', 'bash'];
github patternplate / patternplate / packages / components / lib / code / index.js View on Github external
}

// Highlight configuration

// CSS and friends
low.registerLanguage('css', css);
low.registerLanguage('less', less);
low.registerLanguage('scss', scss);
low.registerLanguage('stylus', stylus);

// JS and friends
low.registerLanguage('js', js);
low.registerLanguage('javascript', js);
low.registerLanguage('jsx', js);
low.registerLanguage('ts', ts);
low.registerLanguage('tsx', ts);
low.registerLanguage('typescript', ts);
low.registerLanguage('json', json);

// HTML and friends
low.registerLanguage('html', xml);
low.registerLanguage('xml', xml);
low.registerLanguage('md', md);
low.registerLanguage('markdown', md);

// (s)hell(ish)s
low.registerLanguage('bash', bash);
// Low.registerLanguage('shell', bash);

const languages = ['css', 'less', 'scss', 'stylus', 'js', 'javascript', 'jsx', 'ts', 'tsx', 'typescript', 'json', 'html', 'xml', 'md', 'markdown', 'bash'];

function highlight(language, source) {
github gsuitedevs / md2googleslides / src / extract_slides.js View on Github external
inlineTokenRules['fence'] = function(token, env) {
    const style = getStyle(token, {fontFamily: 'Courier New'});
    startStyle(style, env);
    const language = token.info ? token.info.trim() : undefined;
    if(language) {
        const htmlTokens = low.highlight(language, token.content);
        for(let token of htmlTokens.value) {
            processHtmlToken(token, env);
        }
    } else {
        // For code blocks, replace line feeds with vertical tabs to keep
        // the block as a single paragraph. This avoid the extra vertical
        // space that appears between paragraphs
        env.text.rawText += token.content.replace(/\n/g, '\u000b');
    }
    env.text.rawText += '\n';
    endStyle(env);
};
github wooorm / emphasize / lib / core.js View on Github external
'use strict'

var chalk = require('chalk')
var lowlight = require('lowlight/lib/core.js')

var high = lowlight.highlight
var auto = lowlight.highlightAuto

// Inherit.
function Lowlight() {}

Lowlight.prototype = lowlight

var emphasize = new Lowlight()

// Expose.
module.exports = emphasize

emphasize.highlight = highlight
emphasize.highlightAuto = highlightAuto

// Default style sheet.
github wooorm / emphasize / lib / core.js View on Github external
'use strict'

var chalk = require('chalk')
var lowlight = require('lowlight/lib/core.js')

var high = lowlight.highlight
var auto = lowlight.highlightAuto

// Inherit.
function Lowlight() {}

Lowlight.prototype = lowlight

var emphasize = new Lowlight()

// Expose.
module.exports = emphasize

emphasize.highlight = highlight
emphasize.highlightAuto = highlightAuto

// Default style sheet.
var defaultSheet = {
github DefinitelyTyped / DefinitelyTyped / lowlight / lowlight-tests.ts View on Github external
keywords: {
            keyword:
                'forall all exists exist only m M i e 1 2 3 4 5 6 7 8 9 0 - + * / \ % ! . , ; : | lim limsup liminf infinity not'
        },
        contains: [
        {
            className: 'variable',
            begin: '(', end: ')'
        },
        ]
    };
}

registerLanguage('math', highlighter);

console.log(highlight('typescript',
`class CPP {
    private year: number;
    public constructor(private version: string) {
        this.year = Number(version.match(/.+\d+$/));
    }

    public version(): string {
        return this.version;
    }
}
`
));

console.info(highlightAuto(
`class CPP {
    private year: number;
github DefinitelyTyped / DefinitelyTyped / lowlight / lowlight-tests.ts View on Github external
`class CPP {
    private year: number;
    public constructor(private version: string) {
        this.year = Number(version.match(/.+\d+$/));
    }

    public version(): string {
        return this.version;
    }
}
`
));

core.registerLanguage('math', highlighter);

console.log(core.highlight('javascript',
`class CPP {
    constructor(version) {
        this.version = version;
        this.year = Number(version.match(/.+\d+$/));
    }

    version(){
        return this.version;
    }
}
`
, { prefix: 'core-' }));


console.info(core.highlightAuto(
`class CPP {