How to use highlights - 3 common examples

To help you get started, we’ve selected a few highlights 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 aigis-styleguide / aigis / src / md_to_html.js View on Github external
highlight: function (code, type) {
    var scope = {
      js: "source.js",
      javascript: "source.js",
      html: "text.html.gohtml",
      block: "text.html.gohtml",
      css: "source.css"
    };
    var scopeName = scope[type] || "text.html.gohtml";
    
    var highlighter = new Highlights();
    var html = highlighter.highlightSync({
      fileContents: code,
      scopeName
    });
    if (type) {
      html = `<div class="ronde-codeblock__header">${type}</div>${html}`;
    }
    return html;
  }
});
github aigis-styleguide / aigis / src2 / CommentModel.js View on Github external
highlight: function (code, type) {
        var scope = {
          js: "source.js",
          javascript: "source.js",
          html: "text.html.gohtml",
          block: "text.html.gohtml",
          css: "source.css"
        };
        var scopeName = scope[type] || "text.html.gohtml";
        
        var highlighter = new Highlights();
        var html = highlighter.highlightSync({
          fileContents: code,
          scopeName
        });
        if (type) {
          html = `<div class="ronde-codeblock__header">${type}</div>${html}`;
        }
        return html;
      }
    });
github elastic / kibana / x-pack / plugins / code / server / highlights.ts View on Github external
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import { CodeLine } from '../model';

import Selector from 'first-mate-select-grammar';
import Highlights from 'highlights';
const highlighter = new Highlights();

highlighter.loadGrammarsSync();

const selector = Selector();

export function tokenizeLines(filePath: string, fileContents: string): CodeLine[] {
  const grammar = selector.selectGrammar(highlighter.registry, filePath, fileContents);
  if (grammar) {
    return grammar.tokenizeLines(fileContents);
  } else {
    return [];
  }
}

export function computeRanges(lines: CodeLine[]) {
  let pos = 0;

highlights

Syntax highlighter

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Popular highlights functions