0

I've seen the docs https://marked.js.org/using_pro#renderer and it has no example for the list i want to customize

more detail https://github.com/markedjs/marked/blob/master/src/Tokens.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]


0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.