How to use the highlight.js.getLanguage function in highlight

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 alibaba-fusion / next / scripts / utils / marked.js View on Github external
highlight: function(code, lang) {
        const result =
            lang && highlight.getLanguage(lang)
                ? highlight.highlight(lang, code)
                : highlight.highlightAuto(code);
        return `<div class="hljs">${result.value}</div>`;
    },
});
github CHENXCHEN / hexo-renderer-markdown-it-plus / lib / renderer.js View on Github external
checkValue(config, _res, 'highlight', function(str, lang) {
        if (lang &amp;&amp; hljs.getLanguage(lang)) {
            try {
                return '<pre class="' + pre_class + '"><code class="' + lang + '">' + hljs.highlight(lang, str, true).value + '</code></pre>';
            } catch (__) {}
        }
        return '<pre class="' + pre_class + '"><code class="' + lang + '">' + utils.escapeHtml(str) + '</code></pre>';
    }, function(str, lang) {
        return '<pre class="' + pre_class + '"><code class="' + lang + '">' + utils.escapeHtml(str) + '</code></pre>';

highlight

Highlight code syntax with node.js

Unrecognized
Latest version published 9 years ago

Package Health Score

48 / 100
Full package analysis