How do I get this to collect an arbitrary number of paragraphs after a heading?
(m/search (:content (md/parse s))
(m/scan {:type :heading
:content [{:text ?heading}]
:heading-level 2}
{:type :paragraph
:content [{:text ?content}]}
{:type :paragraph
:content [{:text ?content-1}]})
{?heading [?content ?content-1]})Can you give an example of the input data?
I can do this tomorrow. The input is from md/parse of https://github.com/nextjournal/markdown. Basically taking markdown and wanting to collect the paragraphs under headings whilst maintaining which heading it comes from.
@markaddleman Basically I want to be able to scope in and extract all paragraphs under a the headings. Keeping the source order of those paragraphs. I want to know how I can generalize this but also get just the paragraphs under specific headings. Which could be done by specifying it to match on like so.
{:type :heading
:content [{:text "Specific heading"}]
:heading-level 2}
At present what I have is broken. It only works when there is 2 paragraphs under a heading level 2. If there is any less Meander returns nothing.
If I just specify just 1 and there is more I get just the 1 under that heading. The current way I was getting back a list of maps. I would then use (into {} to get them all into a map and destructure to pluck out the paragraphs by the heading as a key.
I think this gives you what you want. The key piece is first partitioning the data into a form that meander can handle easily.