Is there currently a way to get the previous heading of the current paragraph in markdown? #1277
-
I am attempting to transform markdown into HTML using the marked renderer. const renderer = new marked.Renderer();
let renderedHtml: string = marked.parse(markdown, { renderer }); I want to adapt the paragraph rendering so that the class names of the sections match the preceding headings. Can this be achieved? renderer.paragraph = (text) => {
return `<section>${text}</section>`;
} I am using marked and dompurify but i heard you could also to create an AST using the following syntax const file = await unified()
.use(remarkParse)
.use(remarkRehype) My goal is to build a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, see https://www.npmjs.com/package/remark-sectionize and https://www.npmjs.com/package/@hbsnow/rehype-sectionize as an examples of how to do this. |
Beta Was this translation helpful? Give feedback.
Yes, see https://www.npmjs.com/package/remark-sectionize and https://www.npmjs.com/package/@hbsnow/rehype-sectionize as an examples of how to do this.