-
Notifications
You must be signed in to change notification settings - Fork 47
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: image not found in README.md while mdbook build #120
base: master
Are you sure you want to change the base?
Conversation
Since commit 1ca2a86, all assets embed to top directory in book and could not be found on reading. Another issue is not handle README.md path correctly while applying mdbook link preprocessor. This commit fixes above issues and update an integration test to ensure assets is embedded to expected path. svg image is from https://commons.wikimedia.org/wiki/File:Epub_logo.svg
fc1e086
to
7030f68
Compare
let filename = if cfg!(target_os = "windows") { | ||
binding.as_os_str().to_os_string() | ||
.into_string().expect("Error getting filename for Local Asset").replace('\\', "/") |
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.
I'm not sure if that is good to remove that code. I remember there were problems on Win, so I added that piece of code. I doubt that is good.
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.
Any exact cases could be added to testcases?
Things like https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?
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.
That code is related to problem of building epub book on Windows platform. We should change window's based '\' to path like '/' as that should be by epub specification.
See also
#[test] fn test_normalize_path_win() {
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.
I think epub-builder already do its best here to not use backspaces in zip files to conform ePub spec. And I check the book generated with this PR works fine with calibre ebook-viewer that images are embeded and displayed without error.
We need to normalize but not canonicalize the path causing issue. So just using strip_prefix
is enough.
Fix #115