Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resolving of relative urls #5

Closed
mstijak opened this issue Oct 10, 2014 · 1 comment
Closed

Support resolving of relative urls #5

mstijak opened this issue Oct 10, 2014 · 1 comment

Comments

@mstijak
Copy link

mstijak commented Oct 10, 2014

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

@mstijak mstijak mentioned this issue Oct 10, 2014
@Knagis
Copy link
Owner

Knagis commented Oct 10, 2014

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants