admin管理员组

文章数量:1343915

I've seen the docs and it has no example for the list i want to customize

more detail .ts#L137 as the list doesn't have tokens like heading, and others do. Only items

so i try

import { marked } from 'marked'
const renderer = {
  list({ items, ordered }) {
  const listitems = this.parser.parse(items); // the problem occurs
  // not work for `this.parser.parseInline(items)` as well
  const tag = ordered ? 'ol' : 'ul';

    return `<${tag} class="">${listitems}</${tag}>`
  },
  listitem({ tokens }) {
  const text = this.parser.parseInline(tokens);

    return `<li class="ml-2">${text}</li>`
  },
};
marked.use({ renderer });
let html = marked.parse(`
**Ingredients:**
* **For the Coffee Jelly:**  
  * Strong brewed coffee or espresso 
`)

nothing come out for the entire html

I think i don't understand how to work for items property for list in the renderer. could anyone help?

but if I delete this line const listitems = this.parser.parse(items);

  list({ items, ordered }) {
  const tag = ordered ? 'ol' : 'ul';

    return `<${tag} class="">${items}</${tag}>`
  },

it will result as below. other parts work expected, except the list parts


Ingredients:

[object Object]


本文标签: markdownparse marked customize for listStack Overflow