How to use highlight - 10 common examples

To help you get started, we’ve selected a few highlight 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 Coding / WebIDE-Frontend / app / components / MonacoEditor / Editors / MarkDownEditor.jsx View on Github external
highlight: (str, lang) => {
    require('highlight.js/styles/monokai-sublime.css')
    const hljs = require('highlight.js')
    if (lang && hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(lang, str).value
      } catch (__) {}
    }

    try {
      return hljs.highlightAuto(str).value
    } catch (__) {}

    return '' // use external default escaping
  }
})
github Coding / WebIDE-Frontend / app / components / Editor / components / MarkdownEditor / index.jsx View on Github external
highlight: (str, lang) => {
    require('highlight.js/styles/github-gist.css')
    const hljs = require('highlight.js')
    if (lang && hljs.getLanguage(lang)) {
      try {
        return hljs.highlight(lang, str).value
      } catch (__) {}
    }

    try {
      return hljs.highlightAuto(str).value
    } catch (__) {}

    return '' // use external default escaping
  }
})
github thangngoc89 / blog / old / scripts / webpack.config.babel.js View on Github external
highlight: (code, lang) => {
            code = code.trim()
            const hljs = require("highlight.js")
            // language is recognized by highlight.js
            if (lang && hljs.getLanguage(lang)) {
              return hljs.highlight(lang, code).value
            }
            // ...or fallback to auto
            return hljs.highlightAuto(code).value
          },
        })
github heyui / heyui / doc / js / vuehighlight.js View on Github external
componentUpdated: function componentUpdated(el, binding) {
      // after an update, re-fill the content and then highlight
      const targets = el.querySelectorAll('code');

      for (let i = 0; i < targets.length; i += 1) {
        const target = targets[i];
        if (binding.value) {
          target.textContent = binding.value;
          hljs.highlightBlock(target);
        }
      }
    }
  });
github fortes / metalsmith-code-highlight / transform.js View on Github external
module.exports = function(options) {
  highlight.configure(options);
  let normalizedOptions = Object.assign({}, defaults, options);
  let {selector} = normalizedOptions;

  return function highlightContent(root, data, metalsmith, done) {
    Array.from(root.querySelectorAll(selector)).forEach(node => {
      highlight.highlightBlock(node);

      // Tag the parent node as well for style adjustments
      if (node.parentNode && node.parentNode.classList) {
        node.parentNode.classList.add('lang-highlight');
      }
    });

    done();
  };
};
github gentics / gentics-ui-core / src / docs / components / highlighted-code / highlighted-code.component.ts View on Github external
ngAfterViewInit(): void {
        let codeEl = this.elementRef.nativeElement.querySelector('code');
        hljs.highlightBlock(codeEl);
    }
github future-architect / cheetah-grid / packages / docs / scripts / metalsmith / metalsmith-code-highlight.js View on Github external
module.exports = function(options = {}) {
	highlightjs.configure(options);

	/**
	 * @param {Object} files files
	 * @param {Metalsmith} metalsmith metalsmith
	 * @param {Function} done done
	 * @returns {void}
	 */
	return function(files, metalsmith, done) {
		let file, data;
		for (file in files) {
			if (HTML_FILENAME_REGEXP.test(file)) {
				data = files[file];
				data.contents = Buffer.from(highlightFile(data.contents.toString()));
			}
		}
github helpers / handlebars-helpers / lib / helpers / helpers-markdown.js View on Github external
highlight: function (code, lang) {
      var res;
      res = void 0;
      if (!lang) {
        return code;
      }
      switch (lang) {
      case "js":
        lang = "javascript";
      }
      try {
        return res = hljs.highlight(lang, code).value;
      } finally {
        return res || code;
      }
    }
  };
github jonschlinkert / swig-extensions / lib / markdown.js View on Github external
highlight: function (code, lang) {
    var res = void 0;
    if (!lang) {
      return code;
    }
    switch (lang) {
    case "js":
      lang = "javascript";
    }
    try {
      return res = hljs.highlight(lang, code).value;
    } finally {
      return res || code;
    }
  }
}, (opts.marked || {})));
github juliangruber / me / browser / index.js View on Github external
highlight : function(code, lang) {
      if (lang == 'js') lang = 'javascript';
      if (lang && hljs.LANGUAGES[lang]) {
        return hljs.highlight(lang, code).value;
      }
      return hljs.highlightAuto(code).value;
    }
  });

highlight

Highlight code syntax with node.js

Unrecognized
Latest version published 9 years ago

Package Health Score

48 / 100
Full package analysis