-
-
Notifications
You must be signed in to change notification settings - Fork 457
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
[Question] How I setup a base path for img or url that use relative path ? #143
Comments
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). |
I've had a crack at doing this in the
I've made some unit tests too, so if you like this approach I can issue a PR |
Yep, looks good for a PR |
@markheath this is great , that works for me !! public delegate string UrlMarkdownConverter(string rawValue,string extension,bool isRelative)
public UrlMarkdownConverter UrlConverter { get;set; } = (raw,ext,isrelative)=> rawUrl ; // default value and then I can do this reander.UrlConverter = (raw,ext,isRelative)=>
{
if( isRelative && string.Equals(ext,".md") )
{
return raw.Replace(ext,".html"); // better to use Regex class
}
} to actually generate markdown to HTML files |
I think if you went that approach it would make more sense to just have a |
@markheath I think 'get extension' and 'the path is relative or not' may be a very common action, if it not done by |
Any opinions @xoofx ? I can issue a PR with a |
@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. |
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 |
Closing as resolved by #201 |
How do I use this function now? |
There are tests in the PR just above that shows how to use it |
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: i'm sorry if i ask something very simple. Unfortunately, I am not very familiar with this area. |
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
![](image/imageName.jpg)
=><img src="/doc/?path=imageName.jpg" />
.Is there a way to do this ? Thanks.
The text was updated successfully, but these errors were encountered: