How to use the prismjs.languages function in prismjs

To help you get started, we’ve selected a few prismjs 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 rooseveltframework / roosevelt / lib / htmlValidator.js View on Github external
logger.error(error)
                detectErrors = true
                pageTitle = 'Cannot connect to validator'
                pageHeader = 'Unable to connect to HTML validator'
              }

              if (detectErrors) {
                markup = body
                // Highlight and add line numbers to html
                formattedHTML = '<pre class="\'markup\'">\n<code class="language-html">\n'
                markupArray = markup.split('\n')
                for (i = 0; i &lt; markupArray.length; i++) {
                  markupLine = markupArray[i]
                  if (errorMap.has(i + 1)) {
                    formattedHTML += `<span class="line-numbers error" title="${errorMap.get(i + 1)}">`
                    formattedHTML += Prism.highlight(`${markupLine}`, Prism.languages.markup)
                    formattedHTML += '</span>'
                  } else {
                    formattedHTML += '<span class="\'line-numbers\'">'
                    formattedHTML += Prism.highlight(`${markupLine}`, Prism.languages.markup)
                    formattedHTML += '</span>'
                  }
                }
                formattedHTML += '</code>\n</pre>'
                // build markup template
                formattedHTML = `<h2>Markup used:</h2>\n${formattedHTML}`

                res.status(500)
                model.prismStyle = prismStyleSheet.toString()
                model.pageTitle = pageTitle
                model.preWidth = markupArray.length.toString().length * 8
                model.pageHeader = pageHeader
github ffan-fe / fancyui / tests / rangepicker / controller.js View on Github external
}
    `;
    this.codeConfigHtml = $sce.trustAsHtml(Prism.highlight(codeConfig, Prism.languages.javascript));
    const codeConfigSame = `
    {
      viewFormat: 'YYYY-MM-DD HH:mm:ss',
      modelFormat: 'YYYY-MM-DD HH:mm:ss'
    }
    `;
    this.codeConfigHtmlSame = $sce.trustAsHtml(Prism.highlight(codeConfigSame, Prism.languages.javascript));
    const codePart1 = `
      
    `;
    this.part1Html = $sce.trustAsHtml(Prism.highlight(codePart1, Prism.languages.html));
    const codePart2 = `
      
    `;
    this.part2Html = $sce.trustAsHtml(Prism.highlight(codePart2, Prism.languages.html));
  }
}
github Houfeng / mditor / packages / embed / lib / common / parser.js View on Github external
require('prismjs/components/prism-livescript');
require('prismjs/components/prism-latex');
require('prismjs/components/prism-groovy');
require('prismjs/components/prism-graphql');
require('prismjs/components/prism-nginx');
require('prismjs/components/prism-erlang');
require('prismjs/components/prism-powershell');
require('prismjs/components/prism-makefile');
require('prismjs/components/prism-markdown');

//alias
Prism.languages.js = Prism.languages.javascript;
Prism.languages['c#'] = Prism.languages.csharp;
Prism.languages['f#'] = Prism.languages.fsharp;
Prism.languages.sh = Prism.languages.bash;
Prism.languages.md = Prism.languages.markdown;
Prism.languages.py = Prism.languages.python;
Prism.languages.yml = Prism.languages.yaml;
Prism.languages.rb = Prism.languages.ruby;

var Parser = function Parser(options) {
  options = options || {};
  this.options = options;
};

Parser.highlights = {};
Parser.marked = marked;
Parser.Prism = Prism;

//使标题解析 # 号可以无空格
marked.Lexer.rules.gfm.heading = marked.Lexer.rules.heading;
marked.Lexer.rules.tables.heading = marked.Lexer.rules.heading;
github conorhastings / react-syntax-highlighter / src / languages / q.js View on Github external
import Prism from 'prismjs';
export default Prism.languages.q;
github Houfeng / mditor / packages / embed / src / common / parser.js View on Github external
require('prismjs/components/prism-cpp');
require('prismjs/components/prism-lua');
require('prismjs/components/prism-livescript');
require('prismjs/components/prism-latex');
require('prismjs/components/prism-groovy');
require('prismjs/components/prism-graphql');
require('prismjs/components/prism-nginx');
require('prismjs/components/prism-erlang');
require('prismjs/components/prism-powershell');
require('prismjs/components/prism-makefile');
require('prismjs/components/prism-markdown');

//alias
Prism.languages.js = Prism.languages.javascript;
Prism.languages['c#'] = Prism.languages.csharp;
Prism.languages['f#'] = Prism.languages.fsharp;
Prism.languages.sh = Prism.languages.bash;
Prism.languages.md = Prism.languages.markdown;
Prism.languages.py = Prism.languages.python;
Prism.languages.yml = Prism.languages.yaml;
Prism.languages.rb = Prism.languages.ruby;

const Parser = function (options) {
  options = options || {};
  this.options = options;
};

Parser.highlights = {};
Parser.marked = marked;
Parser.Prism = Prism;

//使标题解析 # 号可以无空格
github conorhastings / react-syntax-highlighter / src / languages / refractor / markup.js View on Github external
import Prism from 'prismjs';
export default Prism.languages.markup;
github conorhastings / react-syntax-highlighter / src / languages / refractor / properties.js View on Github external
import Prism from 'prismjs';
export default Prism.languages.properties;
github pivotal-cf / pivotal-ui / styleguide / plugins / gatsby-pivotal-ui-styleguide / transform-code-block.js View on Github external
if (title) {
    return {
      type: 'html',
      value: `
        
        
      `
    };
  }

  if (prism.languages[lang]) {
    const highlighted = prism.highlight(strippedValue, prism.languages[lang], lang);
    const langClass = `language-${lang}`;

    return {
      type: 'html',
      value: `<pre class="sg-pre ${langClass}"><code class="sg-code ${langClass}">${highlighted}</code></pre>`
    };
  }
};
github conorhastings / react-syntax-highlighter / src / languages / r.js View on Github external
import Prism from 'prismjs';
export default Prism.languages.r;
github Houfeng / mditor / packages / embed / lib / common / parser.js View on Github external
require('prismjs/components/prism-latex');
require('prismjs/components/prism-groovy');
require('prismjs/components/prism-graphql');
require('prismjs/components/prism-nginx');
require('prismjs/components/prism-erlang');
require('prismjs/components/prism-powershell');
require('prismjs/components/prism-makefile');
require('prismjs/components/prism-markdown');

//alias
Prism.languages.js = Prism.languages.javascript;
Prism.languages['c#'] = Prism.languages.csharp;
Prism.languages['f#'] = Prism.languages.fsharp;
Prism.languages.sh = Prism.languages.bash;
Prism.languages.md = Prism.languages.markdown;
Prism.languages.py = Prism.languages.python;
Prism.languages.yml = Prism.languages.yaml;
Prism.languages.rb = Prism.languages.ruby;

var Parser = function Parser(options) {
  options = options || {};
  this.options = options;
};

Parser.highlights = {};
Parser.marked = marked;
Parser.Prism = Prism;

//使标题解析 # 号可以无空格
marked.Lexer.rules.gfm.heading = marked.Lexer.rules.heading;
marked.Lexer.rules.tables.heading = marked.Lexer.rules.heading;