-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
fix: render image in absolute path #1868
fix: render image in absolute path #1868
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e9fe6a9:
|
2526fed
to
e221023
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dandrade-meli , thx for ur investigation and input for this !
This change seems trick to match the regex of absolute condition tho.
I think maybe we should have a config
such as :absolute
to indicate an absolute
path, it can get rid of our own isAbsolutePath
check. and I could have a patch on it asap.
cc @docsifyjs/reviewers wdyt.
Let's identify the behavior we want first without worrying about implementation details. I think we also need to consider if/how Docsify's Given the following Docsify site structure:
I believe Docsify's HTML output for
The table can be a bit confusing but the rules required to match the proposed output are simple:
Thoughts? |
Yea, If the Personally, I think it is fine to give users more sugars and tricks if the change would not break a big thing. |
I believe the prefix |
TL;DR:
It could, but...
I believe the goal should be for Docsify to be as intuitive as possible. Docsify's path handling is not intuitive. This is the result of both bugs and questionable design decisions made long ago. These issues aren't obvious or common because they only present themselves is less-common scenarios (which is why they've survived this long), but when they do present themselves it's a mess. Adding configuration options and custom markdown syntax to get out of the mess instead of just fixing the issues that cause the mess is just avoiding the problem and adding more noise, both of which make Docsify less intuitive and less enjoyable for users. FWIW, I have no issues adding configuration options or custom markdown syntax to to make Docsify more capable or enjoyable to use. I'm okay adding an |
close via #1891. |
Summary
This PR documents support for including images with absolute paths and fixes a small bug that made it impossible to use.
This avoids the need to use ../../ to get to the root path.
Enable to fix bugs #850, #415
Example of use:
in /core/render/compiler/image.js which is responsible for generating the html
img
, there is a check if the href is not absolute.the
isAbsolutePath
function uses the following regex to do this check/(:|(\/{2}))/g
what this regex does:
if the url contains
:
or//
, then this path is absolute.but when we used this strategy, adding the
:
or//
, the image was not rendered because in the generated img tag the path kept the:
or//
and to fix this bug I applied a simple replace to remove
//
and:
by ``What kind of change does this PR introduce?
Bugfix
Feature
Docs
For any code change,
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
Related issue, if any:
#850
#415
Tested in the following browsers: