Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Prepend image links with custom URL #8



First of all, thanks for your continued work on this library! I've also never used pegdown or flexmark before, so this is probably a stupid question…. I'd like to parse a markdown document and then change all image links to some other generative url. I saw that Eike already had a question on how to replace URL's in general. I'm just specifically trying to prepend image url's with a generative url in the following way:



<p><a href="">image</a></p>

Where would be the prepended URL.

What would be a good starting point to accomplish such an endeavour?

Kind regards and thanks again for your great efforts,

  • replies 3
  • views 3K
  • likes 0

@Frituurpanda, the best example for this is in the new module flexmark-docx-converter it has a custom link resolver with separate prefix for page relative links like your example and site relative links that start with /.

Registering it as a custom link resolver can be seen in sample code PegdownCustomLinkResolverOptions

I suggest you create your own data keys for the options used by the resolver so you don't need to add the docx converter module as a dependency.

I don't understand what you mean by can't edit the context to set different URL. You set the URL in options before you create the renderer. You cannot change this after creation because extensions can and do cache the options for their use.


Hi @vsch, thanks. I had the logic in the wrong handler (renderer). Thanks again!