Knagis/CommonMark.NET

Support resolving of relative urls

Closed this issue · 1 comments

It would be great to be able to resolve relative urls.
For example, I would like to replace ~/ with application path.

How does this solution sound:

CommonMarkSettings extended with a new property Func<string, string> UriResolver {get;set;}

During format time (so the object model would still contain ~/xxx) if this delegate is set, it is called for every URL that is put in either href or src attribute (so if it is an autolink like <~/foo> it would be rendered <a href="/app/foo">~/foo</a>.

You can set that for each call to CommonMarkConverter or just use this in Application_Start event (or other startup code)

CommonMarkSettings.Default.UriResolver = VirtualPathUtility.ToAbsolute;