Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dieterplex
Copy link
Contributor

@dieterplex dieterplex commented Jul 23, 2024

Fix #115

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
Comment on lines -87 to -89
let filename = if cfg!(target_os = "windows") {
binding.as_os_str().to_os_string()
.into_string().expect("Error getting filename for Local Asset").replace('\\', "/")
Copy link
Collaborator

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.

Copy link
Contributor Author

@dieterplex dieterplex Dec 1, 2024

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?

Copy link
Collaborator

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() {

#11

Copy link
Contributor Author

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.

src/resources/resource.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown images break the plugin invoking errors
2 participants