Hello, I would like to share an undocumented trick to render markdown at a specific position with dataviewjs.
Pursuant to the official documentation, the functions dv.paragraph
and dv.span
only accept one parameter, i.e. the markdown text to be rendered. By default, it is rendered at the current possition in the dataview container, i.e. at the end of it.
There is however an undocumented argument which allows to pass a HTML element to specify the position where the markdown must be rendered. An an argument, you need to pass an object whose property container
is the HTML element. For instance:
let a = dv.paragraph("This is a **first** paragraph")
let b = dv.paragraph("This is a **second** paragraph")
a.innerHTML = ""
dv.paragraph("This is a **third** paragraph", {container: a})
I hope this can be of use to others!