Xpath and markdown -- how to interoperate

Hi, I’ve started on a new personal blog site powered by SWI having read Annes excellent tutorial first, hacked it all and ready to go!

Because the markdown parse doesn’t allow attributes (like Pandoc for example) I can’t type this in my source: BLAH{target="_blank"}

So…I started thinking that I could post process the results of the markdown conversion to add in anything that I needed.

I am loading in a markdown file, then using md_parse_string but the format is not the same as load_structure gives. I read a post from @jamesnvc and realised I could instead use md_html_string and then make a stream from the string and pass it into load_structure.

My question then is what is a good and efficient (without going to overboard) way to systematically perform a transformation on the pre rendered HTML ?

Looking for cool and novel suggestions whilst I continue to explore.
I have to say that apart from Python/Flask this is the fastest toolchain I can remember for playing around with local web servers. Brilliant stuff, as usual.

Thanks,
Sean.

1 Like

Can you provide a link. I don’t know which one you are specifically refering.

Well, I read this first:

and then I found another post which had your name on it, which is the one I referredf to:

1 Like

HTML from that Markdown parser can be transformed using a simple recursive predicate that just replaces matching terms. I used this for adding rel=nofollow to comment links in Markdown-based comments. https://github.com/Blog-Core/blog-core/blob/b54f33c6824d91d2add758b8c4aa8efed035cc48/prolog/bc/bc_comment_format.pl#L20

Source for bc_walk is here: https://github.com/Blog-Core/blog-core/blob/b54f33c6824d91d2add758b8c4aa8efed035cc48/prolog/bc/bc_walk.pl

Brilliant stuff Raivo, I decided to maintain my hakyll site however I still have plans for Prolog for an API server I want to experiment with so I will study your code for sure.

Thank you.
Sean.

1 Like