Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
convert(markdownText) {
this.root = null;
this.nodeStack = [];
const reader = new commonmark.Parser();
const parsed = reader.parse(markdownText);
const walker = parsed.walker();
let event;
event = walker.next();
while (event) {
const type = event.node.type;
// console.log(`Converting: ${type}`);
if (this[type]) {
// console.log(event.node);
this[type](event.node, event.entering);
this.dump();
} else {
import {Parser} from "commonmark";
import * as CodeMirror from "codemirror";
import {sendSwap, sendSave, sendParse} from "./client";
import {setActiveIds, renderer, renderEve} from "./renderer";
let codeEditor: MarkdownEditor;
let lineMarks = {"item": true, "heading": true, "heading1": true, "heading2": true, "heading3": true, "heading4": true};
let parser = new Parser();
type Pos = CodeMirror.Position;
type Range = CodeMirror.Range;
type Elem = Element&any;
function isRange(loc:any): loc is Range {
return loc.from !== undefined || loc.to !== undefined;
}
function isPosition(loc:any): loc is Position {
return loc.line !== undefined || loc.ch !== undefined;
}
//---------------------------------------------------------
// Spans (TextMarkers)
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) {
});
var text = doc.text;
var bits = text.split("\n");
if (ind !== -1) {
return el.slice(0, ind).trim() + el.slice(ind+3);
} else {
return el;
}
}).join("\n");
}
var reader = new commonmark.Parser();
var parsed = reader.parse(text);
var walker = parsed.walker();
var event, node, entering, htext = false, ltext = false, lang, code;
var ind, pipes, middle, title, href, directive; //for links
while ((event = walker.next())) {
node = event.node;
entering = event.entering;
switch (node.type) {
case "text" :
if (htext) {
htext.push(node.literal);
}
if (ltext) {
var commonmark = require("commonmark");
var infile = "../doc/standard/upnp.md";
var outfile = "../build/upnp.md";
var fs = require('fs');
var md = fs.readFileSync(infile, {encoding:"utf8"});
var reader = new commonmark.Parser();
var parsed = reader.parse(md);
var out = md.split("\n");
var walker = parsed.walker();
var event, node, source, i;
while ((event = walker.next())) {
node = event.node;
if (node.type === "code_block") {
source = node.sourcepos;
for (i = source[0][0]-1; i < source[1][0]; i +=1) {
out[i] = false;
}
}
}
'use strict';
var fs = require('fs');
var dox = require('dox');
var Handlebars = require('handlebars');
var commonmark = require('commonmark');
var path = require('path');
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(
this.isTrack = isTrack
this.description = description
this.subchapters = subchaptersData.map((d) => new Subchapter(d.title, d.alias, this))
}
}
interface SubchapterData {
title: string
alias: string
}
interface SubchapterDataWithMeta extends SubchapterData {
isLast: boolean
}
const parser = new Parser()
class Subchapter {
title: string
alias: string
chapter: Chapter
constructor(title: string, alias: string, chapter: Chapter) {
this.title = title
this.alias = alias
this.chapter = chapter
}
ast(): Node {
return parser.parse(require(`../../content/${this.chapter.alias}/${this.alias}.md`))
}
}
.then(source => {
const parser = new commonmark.Parser(),
renderer = new commonmark.HtmlRenderer();
this.setState({
content: renderer.render(this._postprocessParsedMarkdown(parser.parse(source)))
});
})
.then(undefined, (e: Error) => this.props.onMarkdownError(e));
export default (markdown, options) => {
const reader = new Parser();
const writer = options ? new HtmlRenderer(options) : new HtmlRenderer();
const parsed = reader.parse(markdown);
return writer.render(parsed);
};
const CommonMark = require('commonmark');
const ReactRenderer = require('commonmark-react-renderer');
const React = require('react');
const {stripIndent} = require('common-tags');
const parser = new CommonMark.Parser();
const renderer = new ReactRenderer();
module.exports = {
renderMarkdown,
wrapMarkdown,
Markdown
};
function renderMarkdown(text) {
return renderer.render(parser.parse(stripIndent`${text}`));
}
function Markdown(props) {
return React.createElement('div', undefined, renderMarkdown(props.children));
}