How to use the marked.TextRenderer function in marked

To help you get started, we’ve selected a few marked 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 interactivethings / catalog / packages / core / src / markdown / marked-react.js View on Github external
parse(src) {
    this.inline = new ReactInlineLexer(src.links, this.options);
    // use an InlineLexer with a TextRenderer to extract pure text
    this.inlineText = new marked.InlineLexer(
      src.links,
      Object.assign({}, this.options, { renderer: new marked.TextRenderer() })
    );
    this.tokens = src.reverse();

    let out = [];
    while (this.next()) {
      out.push(this.tok());
    }

    return out;
  }
github DefinitelyTyped / DefinitelyTyped / types / marked / marked-tests.ts View on Github external
console.log(lexer.token(text, true));
const lexerOptions: marked.MarkedOptions = lexer.options;

const renderer = new marked.Renderer();
renderer.heading = (text, level, raw, slugger) => {
    return text + level.toString() + slugger.slug(raw);
};
renderer.hr = () => {
    return `\n`;
};
renderer.checkbox = (checked) => {
    return checked ? 'CHECKED' : 'UNCHECKED';
};
const rendererOptions: marked.MarkedOptions = renderer.options;

const textRenderer = new marked.TextRenderer();
console.log(textRenderer.strong(text));

const parseTestText = '- list1\n  - list1.1\n\n listend';
const parseTestTokens: marked.TokensList = marked.lexer(parseTestText, options);
const parser = new marked.Parser();
console.log(parser.parse(parseTestTokens));
console.log(marked.Parser.parse(parseTestTokens));
const parserOptions: marked.MarkedOptions = parser.options;

const links = ['http', 'image'];
const inlineLexer = new marked.InlineLexer(links);
console.log(inlineLexer.output('http://'));
console.log(marked.InlineLexer.output('http://', links));
console.log(marked.InlineLexer.rules);
const inlineLexerOptions: marked.MarkedOptions = inlineLexer.options;