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

Markdown to EPUB: images (path separator issue) #9695

Open
Darthagnon opened this issue Apr 25, 2024 · 4 comments
Open

Markdown to EPUB: images (path separator issue) #9695

Darthagnon opened this issue Apr 25, 2024 · 4 comments
Labels

Comments

@Darthagnon
Copy link

Darthagnon commented Apr 25, 2024

Explain the problem.

I'm compiling an EPUB from Markdown source files, one file per chapter. I'm compiling the book using the following command in a batch file:

pandoc --toc --toc-depth=3 --metadata-file=metadata-file.yaml --epub-cover-image=Images/cover.jpg --css=stylesheet.css -o "Ishtar's Odyssey.epub" 03_A_Mission.md 04_Truant.md 05_The_Caravan.md 06_Error_of_Judgment.md 07_The_Substitute.md 08_Peril.md 09_The_Debate.md 10_Enemies.md 11_Outpost.md 12_Birthday_Surprise.md
rem LIST INCOMPLETE CHAPTERS HERE: 13_Attack.md 14_The_Law.md 15_Two_Rivers.md 16_Desert.md 17_Friends.md 18_Jothams Journey.md 19_Decha_of_Megiddo.md 20_Courage.md 21_Tabithas_Travels.md 22_Special_Instructions.md 23_Ishtars_Odyssey.md 24_Messiah.md 25_Advent_Thru_Time.md
pause

Some of the chapters reference images, e.g.

![](Images/p19_screenshot.png) 

The images exist, but are ignored by Pandoc and are not included in the rendered EPUB. Except for the cover, which is included. How can I make sure they're included?

Pandoc version?

What version of pandoc are you using, on what OS? v3.1.13 amd64 Win10 v1709

Possibly related issues:

Some of the above issue threads seem to suggest referencing the images in ways not standard to Markdown in order to force Pandoc to include them. Surely there's a better, simpler way? Any advice would be appreciated!

@Darthagnon Darthagnon added the bug label Apr 25, 2024
@jgm
Copy link
Owner

jgm commented Apr 26, 2024

This should work! I just did a small test and it worked fine.
You'll have to provide a complete test case we can run to duplicate the issue. (Not your whole book -- just pare things down to the minimum necessary to reproduce it, and give us all the files necessary.)

@jgm
Copy link
Owner

jgm commented Apr 26, 2024

I see you're on Windows. It's possible that the problem involves / as a path separator? Does the image appear if you use \ instead of / in the image path?

@Darthagnon
Copy link
Author

Aha, that's it. When I use backslashes for image paths, it works. Thank you!

Any chance slash translation could be added as a feature? The Markdown editors I use, MarkdownPad 2 and Notepad++ with NppMarkdownPanel, and previewers 1218 Seer and QuickLook display images regardless of back/forward slash; guess that's why I didn't spot this as the solution earlier.

@jgm jgm changed the title Markdown to EPUB: cannot embed images Markdown to EPUB: cannot embed images (path separator issue) Apr 28, 2024
@jgm jgm changed the title Markdown to EPUB: cannot embed images (path separator issue) Markdown to EPUB: images (path separator issue) Apr 28, 2024
@Darthagnon
Copy link
Author

Darthagnon commented May 4, 2024

I just realised, 1218 Seer uses Pandoc v1.16.0.2 under the hood, and when previewing Markdown files with linked images on Windows, it does the opposite to the issue I'm observing here with Pandoc v3.1.13: images linked with backslashes \ are not displayed, but images linked with forward slashes / are displayed.

Although, on closer examination, I'm not sure if it's using Pandoc to render Markdown, as the plugin folder only contains scripts for DOCX and EPUB:

{
	"name": "docx2md",
	"suffix": ["docx","odt"], 
	"exec": "pandoc.exe -s \"*SEER_INPUT_PATH*\" -t markdown -o \"*SEER_OUTPUT_PATH*.md\""
}
{
	"name": "epub2text",
	"suffix": ["epub"],
	"exec": "pandoc.exe -s \"*SEER_INPUT_PATH*\" -t plain -o \"*SEER_OUTPUT_PATH*.txt\""
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants