mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-12 21:39:32 +00:00
[Question] How I setup a base path for img or url that use relative path ? #138
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @John0King on GitHub (Sep 15, 2017).
I'm new to this project, and I try to render a markdown file through MVC.
I need to config the relative path to a absolute path such like
=><img src="/doc/?path=imageName.jpg" />.Is there a way to do this ? Thanks.
@xoofx commented on GitHub (Sep 15, 2017):
Currently, there is no interface to do this automatically. Either you have to process the Markdown AST and fix the links, and then render this AST to HTML. Or make a PR that can introduce this as part of the HTML rendering part, as an option (base url for relative url for example).
@markheath commented on GitHub (Jan 17, 2018):
I've had a crack at doing this in the
HtmlRendererclass. Should be minimal perf impact if the feature isn't being usedI've made some unit tests too, so if you like this approach I can issue a PR
@xoofx commented on GitHub (Jan 17, 2018):
Yep, looks good for a PR
@John0King commented on GitHub (Jan 22, 2018):
@markheath this is great , that works for me !!
but I think maybe it better be a delegate method instead just a property , for example
and then I can do this
to actually generate markdown to HTML files
@markheath commented on GitHub (Jan 23, 2018):
I think if you went that approach it would make more sense to just have a
Func<string,string>and give complete control to the caller to decide how they want to interpret and transform the URL@John0King commented on GitHub (Jan 24, 2018):
@markheath I think 'get extension' and 'the path is relative or not' may be a very common action, if it not done by
render,then it need to be done in your code anyway. and add those two parameter you still have complete control.Func<string,string>is still good for me too . :P@markheath commented on GitHub (Jan 24, 2018):
Any opinions @xoofx ? I can issue a PR with a
Func<string,string>with the property calledLinkRewriter@xoofx commented on GitHub (Jan 24, 2018):
@markheath Sure, we can have a LinkRewriter callback as well (but we keep the BaseUrl). It would run just after the BaseUrl rewrite if any.
@carlowahlstedt commented on GitHub (Mar 23, 2018):
Curious when you're planning on releasing this? I stumbled on this when looking to get this working. Fundamentally, I just need the BaseUrl concept. The only other improvement I can see is adding a way to set it in
Markdown.ToHtml(text, pipeline);but I can see why you wouldn't want to do that.@MihaZupan commented on GitHub (Apr 5, 2019):
Closing as resolved by #201
@Matix-Media commented on GitHub (Sep 9, 2020):
How do I use this function now?
@xoofx commented on GitHub (Sep 10, 2020):
There are tests in the PR just above that shows how to use it
@Matix-Media commented on GitHub (Sep 10, 2020):
I am really new to this, and I can't figure out how to use it.
I only know how to setup the basic markdown renderer but that's all. Do I set this up in brackets at the initialization of markdown-it like this:
new markdownit({BaseUrl: my_url})Because that didn't worked for me.
i'm sorry if i ask something very simple. Unfortunately, I am not very familiar with this area.