Conditionally process url instead of encoding #568

Open
opened 2026-01-29 14:39:57 +00:00 by claunia · 2 comments
Owner

Originally created by @marcselman on GitHub (Sep 28, 2022).

Markdown links will automatically be URL encoded when turned into an HTML anchor.
Is it possible to process the url string instead of it gettingURL encoded?

For example:

This is [a test](#|MY_URL|#). Normal [link](https://url.com/my|title)

will be turned into:

This is <a href="#%7CMY_URL%7C#">a test</a>. Normal <a href="https://url.com/my%7Ctitle">link</a>

I want to match urls that start with #| and end with |# and replace that with *| and |* consecutively and skip url encoding (because it will be sent to another process that expects this format).
So that the output would be:

This is <a href="*|MY_URL|*">a test</a>. Normal <a href="https://url.com/my%7Ctitle">link</a>

Is that possible by creating an extension for example?

Originally created by @marcselman on GitHub (Sep 28, 2022). Markdown links will automatically be URL encoded when turned into an HTML anchor. Is it possible to process the url string instead of it gettingURL encoded? For example: ```md This is [a test](#|MY_URL|#). Normal [link](https://url.com/my|title) ``` will be turned into: ```html This is <a href="#%7CMY_URL%7C#">a test</a>. Normal <a href="https://url.com/my%7Ctitle">link</a> ``` I want to match urls that start with `#|` and end with `|#` and replace that with `*|` and `|*` consecutively and skip url encoding (because it will be sent to another process that expects this format). So that the output would be: ```html This is <a href="*|MY_URL|*">a test</a>. Normal <a href="https://url.com/my%7Ctitle">link</a> ``` Is that possible by creating an extension for example?
claunia added the question label 2026-01-29 14:39:57 +00:00
Author
Owner

@xoofx commented on GitHub (Oct 21, 2022):

Is that possible by creating an extension for example?

Yes, there are many potential solutions, but maybe inheriting LinkInlineRenderer to override the default renderer and avoid the encoding is a good place to try.

@xoofx commented on GitHub (Oct 21, 2022): > Is that possible by creating an extension for example? Yes, there are many potential solutions, but maybe inheriting [LinkInlineRenderer](https://github.com/xoofx/markdig/blob/master/src/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs) to override the default renderer and avoid the encoding is a good place to try.
Author
Owner

@jjxtra commented on GitHub (Mar 18, 2023):

How to override / inherit in this way?

@jjxtra commented on GitHub (Mar 18, 2023): How to override / inherit in this way?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#568