Fork me on GitHub
#nextjournal
<
2023-02-06
>
simongray13:02:47

using nextjournal/markdown, is it possible to pull every consecutive paragraph into a section? e.g.

p1

p2

p3
should become
[:section
 [:p "p1"]
 [:p "p2"]
 [:p "p3]]
I would like to style consecutive paragraphs as a single block, but it is hard to accomplish with the defaults which produces a div containing a flat list of elements.

borkdude14:02:39

you can maybe write <section> around those ?

simongray15:02:18

@U04V15CAJ perhaps, though that doesn't solve the general case.

Andrea10:02:47

I think you’d need 2 steps, first “postprocess” markdown data as returned by nextjournal.markdown/parse, wrapping consecutive paragraph into a {:type :section :content [...]} node, preserving the same nested structure.

Andrea10:02:21

then you’d add a :section type to the map of the “renderes” like described in https://github.com/nextjournal/markdown/blob/f3e40c37d312b0bd964cfe1660b3dd42a0f3068d/README.md?plain=1#L104-L114 (see https://nextjournal.github.io/markdown/README.html for a clerk notebook rendering results)

Andrea10:02:13

this way, I believe, should be easier than postprocessing the hiccup data itself, but it’s certainly not the only way to do it...

simongray10:02:49

Thank you for the guidance @U9EQP1K0X. I'll take a look at it.

👍 2
simongray13:02:27

I can postprocess the result myself, but I would rather use the rendering options in the library, though I have a hard time figuring out how they work.