How to use the lowlight.highlight function in lowlight

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 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 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 sapegin / fledermaus / src / renderers / markdown.js View on Github external
visit(ast, 'code', node => {
			if (!node.data) {
				node.data = {};
			}

			const lang = node.lang;
			const highlighted = lang
				? low.highlight(aliases[lang] || lang, node.value).value
				: low.highlightAuto(node.value).value;
			node.data.hChildren = highlighted;
			node.data.hProperties = {
				className: ['hljs', lang && `language-${lang}`],
			};
		});
}
github indiejames / vscode-clojure-debug / src / extension.ts View on Github external
function highlight(code: string): string {
	const codeMap = lowlight.highlight('clojure', code)
	return walkCodeMap("", codeMap)
}
github gsuitedevs / md2googleslides / src / parser / syntax_highlight.ts View on Github external
function highlightSyntax(content: string, language: string, context: Context): void {
    const highlightResult = low.highlight(language, content);
    for (let node of highlightResult.value) {
        processHastNode(node, context);
    }
}
github logux / logux.io / scripts / steps / build-api.js View on Github external
function exampleHtml (example) {
  if (!example) return []
  let highlighted = lowlight.highlight('js', example.description, {
    prefix: 'code-block_'
  })
  let pre = tag('pre', [
    tag('code', highlighted.value)
  ])
  return [pre]
}
github remarkjs / remark-highlight.js / src / index.js View on Github external
(include && !include.includes(lang)) ||
      (exclude && exclude.includes(lang))
    ) {
      return
    }

    if (!data) {
      data = {}
      node.data = data
    }

    if (!data.hProperties) {
      data.hProperties = {}
    }

    data.hChildren = low.highlight(lang, node.value, {prefix}).value
    data.hProperties.className = [
      'hljs',
      ...(data.hProperties.className || []),
      'language-' + lang
    ]
  }
}