yshavit / mdq

like jq but for Markdown: find specific elements in a md doc
Apache License 2.0
5 stars 0 forks source link

reorganize and re-divide MdqNode #53

Closed yshavit closed 3 months ago

yshavit commented 3 months ago

Today, MdqNode is sometimes a block, sometimes a leaf, sometimes an inline. When it's an inline, that's all it can say about it -- it can't say that it's a Link specifically, for example.

This is a bit unaesthetic, but it also makes selectors harder than they need to be. For example, you can't write a selector against a Link; it would have to be against an Inline, and do the "is it a link" checking internally, which would mean expanding the selector interface. Alternatively, I could introduce an MdqNodeRef for links, and another for images, and deal with the fact that that means those elements can be referenced either through MdqNodeRef::Inline or MdqNodeRef::Link (or ::Image). That's pretty ugly, though.

I should:

This effectively blocks link and image selectors