-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 GitHub-like absolute /path/to/image
#8272
Comments
@tarleb - Tried |
OK, right, I'm not sure what the best solution is. In the mean time, an easy workaround would be a Lua filter that matches Image elements with absolute paths and removes the leading |
function Image (img)
img.src = pandoc.path.make_relative(img.src, '/')
return img
end May require 2.19.2 due to a bug in |
I tried the above solution with pandoc version 2.17.1.1 and apparently it worked. Btw for completion of information (hoping to be helpful to other pandoc beginners like me) the lua script above, must be saved as it is into a file (i.e. makerelativepaths.lua) and pandoc must be launched with the following parameter: pandoc ... --lua-filter makerelativepaths.lua |
In a GitHub README, we reference images like:
Where the absolute filepath is actually resolved while treating
cwd
as the root. GitHub resolves paths this way because it's analogous to parking the project on a server, where/assets/...
would correctly reference the file in question.Request: Support GitHub-like absolute paths
It is not sensible to change the default behavior, and Pandoc should probably treat absolute filepaths the way it currently does out of the box. But it would be appropriate to have a
--github-absolute-paths
flag or something similar to tell Pandoc that/path/to/file
actually means./path/to/file
with respect tocwd
, i.e.${pwd}/path/to/file
.Current workaround is to manually replace
/assets/...
withassets/...
(relative), run Pandoc, and then swap back so GitHub can display the images correctly.Related Issues
-f markdown+rebase_relative_paths
flag)The text was updated successfully, but these errors were encountered: