How to use the commonmark.HtmlRenderer function in commonmark

To help you get started, we’ve selected a few commonmark 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 markedjs / marked / test / index.js View on Github external
bench('commonmark', files, (function() {
      var commonmark = require('commonmark'),
          parser = new commonmark.Parser(),
          writer = new commonmark.HtmlRenderer();
      return function(text) {
        return writer.render(parser.parse(text));
      };
    })());
  } catch (e) {
github spinnaker / deck / app / scripts / modules / core / src / entityTag / entitySource.component.ts View on Github external
public $onInit(): void {
    this.executionType = 'Task';
    if (this.execution || this.loadingExecution) {
      return;
    }
    if (this.metadata && this.metadata.value.comments) {
      const parser: Parser = new Parser();
      const renderer: HtmlRenderer = new HtmlRenderer();
      this.comments = renderer.render(parser.parse(this.metadata.value.comments));
    }
    if (this.metadata && this.metadata.value.executionType === 'pipeline') {
      this.executionType = 'Pipeline';
      this.loadingExecution = true;
      this.executionService
        .getExecution(this.metadata.value.executionId)
        .then((execution: IExecution) => (this.execution = execution))
        .catch(() => (this.executionNotFound = true))
        .finally(() => (this.loadingExecution = false));
    }
  }
github artisonian / erudite / src / renderer.js View on Github external
function loadMarkdown (event, fileName, options) {
  console.debug('load-markdown', fileName);

  if (options != null) {
    _autorun = options.autorun;
    ui.toggleAutorun.querySelector('input').checked = _autorun;
  }

  const reader = new commonmark.Parser();
  const writer = new commonmark.HtmlRenderer();

  readFileAsync(fileName, 'utf8')
    .then(text => ({ fileName, text }))
    .then(({ fileName, text }) => {
      const parsed = reader.parse(text);
      const body = document.querySelector('.markdown-body');

      _markdown = writer.render(parsed);
      showMarkdown();

      return { fileName, parsed };
    })
    .then(({ fileName, parsed }) => {
      const walker = parsed.walker();
      const chunks = [];
github readium / readium-desktop / src / renderer / components / dialog / Information.tsx View on Github external
public async componentDidMount() {
        const { locale } = this.props;
        const infoFolderRelativePath = "assets/md/information";

        let folderPath: string = path.join((global as any).__dirname, infoFolderRelativePath);
        try {
            if (_PACKAGING === "0") {
                folderPath = path.join(process.cwd(), "dist", infoFolderRelativePath);
            }
            const fileContent = await promisify(readFile)(path.join(folderPath, `${locale}.md`), {encoding: "utf8"});
            this.parsedMarkdown = (new commonmark.HtmlRenderer()).render((new commonmark.Parser()).parse(fileContent));
        } catch (__) {
            this.parsedMarkdown = "<h1>There is no information for your language</h1>";
        }
        this.forceUpdate();
    }
github matcha-tools / graphql-matcha / src / components / visualizer / components / utils / Markdown.tsx View on Github external
constructor(props) {
    super(props);
    this.renderer = new HtmlRenderer({ safe: true });
    this.parser = new Parser();
  }
  shouldComponentUpdate(nextProps) {
github loic-sharma / BaGet / src / BaGet.UI / components / DisplayPackage.tsx View on Github external
constructor(props: DisplayPackageProps) {
    super(props);

    this._parser = new Parser();
    this._htmlRenderer = new HtmlRenderer();

    this.state = {package: undefined};
  }
github Twipped / QueryizeJS / docs / index.js View on Github external
var template = Handlebars.compile(fs.readFileSync(path.join(__dirname, '/template.hbs.html')).toString('utf8'));

/** Build Changelog
*******************************************************************************************/
var changelog = fs.readFileSync(path.join(__dirname, '/../CHANGELOG.md')).toString('utf8');
changelog = (new commonmark.Parser()).parse(changelog);
var walker = changelog.walker();
var event;
var node;
while ((event = walker.next())) {
	node = event.node;
	if (node.t === 'SetextHeader' && node.level === 1) {
		node.level = 3;
	}
}
changelog = (new commonmark.HtmlRenderer()).render(changelog);

/** Build Docs
*******************************************************************************************/

var parsed = dox.parseComments(
	fs.readFileSync(
		path.join(__dirname, '/../lib/queryize.js')
	).toString('utf8')
);

parsed = parsed.concat(
	dox.parseComments(
		fs.readFileSync(
			path.join(__dirname, '/../lib/mutators.js')
		).toString('utf8')
	)
github aws / jsii / packages / jsii-pacmak / lib / markdown.ts View on Github external
export function md2html(text: string): string {
  const parser = new commonmark.Parser({ smart: false });
  const renderer = new commonmark.HtmlRenderer({ smart: false, safe: true });
  return renderer.render(parser.parse(text));
}
github APIs-guru / graphql-voyager / src / components / utils / Markdown.tsx View on Github external
constructor(props) {
    super(props);
    this.renderer = new HtmlRenderer({ safe: true });
    this.parser = new Parser();
  }
  shouldComponentUpdate(nextProps) {

commonmark

a strongly specified, highly compatible variant of Markdown

BSD-2-Clause
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis