nextjournal

simongray 2023-02-06T13:23:47.649939Z

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.

borkdude 2023-02-06T14:48:39.945119Z

you can maybe write <section> around those ?

simongray 2023-02-06T15:48:18.782599Z

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

Andrea 2023-02-07T10:20:47.473659Z

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.

Andrea 2023-02-07T10:22:21.316789Z

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)

Andrea 2023-02-07T10:23:40.353049Z

@simongray 👆

Andrea 2023-02-07T10:25:13.166539Z

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

simongray 2023-02-07T10:42:49.490119Z

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

👍 1
simongray 2023-02-06T13:24:27.995739Z

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.