Open nkalvi opened 9 years ago
I think this ought to be the default, actually, not something you have to set an option for.
Note: (undocument feature) I think you can actually specify any
media file to be included in the epub using --epub-embed-font
.
None of the code processing that is actually font-specific.
(I haven't tried it, though.)
Aha - adding via 'embed-font' worked very well - thank you!
Maybe this should remain open, since ideally the epub writer would scan the CSS for linked files and include them automatically...
+++ nkalvi [Feb 14 15 16:24 ]:
Closed #1941.
Reply to this email directly or view it on GitHub: https://github.com/jgm/pandoc/issues/1941#event-235913023
I agree.
@jgm How are you envisaging supporting this? Do we currently depend on a library which can parse CSS or should we roll our own?
@jgm How are you envisaging supporting this? Do we currently depend on a library which can parse CSS or should we roll our own?
@mpickering, I hadn't thought about it much. SelfContained
currently
has something that does limited looking through CSS files for external
references; maybe that could be adapted? We don't depend on a CSS
parsing library.
Another option is to make either --epub-embed-resource
or --epub-embed-image
.
The former could allow including any type of file (video, image, font, stylesheet).
The latter would be an alias for --epub-embed-font
.
Meanwhile, for anyone looking for a quick fix to automate this:
#!/bin/bash
FILENAME=filename.epub
CSS=style.css
IMAGES_DIR=images
for url in $(grep image $CSS | grep url | sed 's/.*url( *\(.*\) *).*/\1/g'); do
EMBED="$EMBED --epub-embed-font=$IMAGES_DIR/$url"
done
pandoc \
--smart \
--epub-cover-image=cover/cover.png \
--epub-metadata=metadata.xml \
--epub-stylesheet=$CSS \
--epub-embed-font=fonts/EmbeddedFont.ttf \
$EMBED \
-t epub -o $FILENAME output/*.md
I tried '--epub-embed-font' like this:
--epub-embed-font ../images/icon/facebook-icon.png
And I found image file under 'Images' directory not 'Fonts' like this:
\Images\facebook-icon.png
But in content.opf, item href is like this:
<item id="facebook-icon_png" href="fonts/facebook-icon.png" media-type="image/png"/>
Please make another options. :cry:
hi @jgm
I'm using pandoc 2.18 to convert from html + css -> epub and it'd be great to have this feature, since I'm having the same issue as described in the first message (url("my_media.png"
) in css will be ignored).
As a workaround I have tried to add the media as a font (--epub-embed-font my_image.png
), but then I need to manually edit the css anyway).
Any chance we could add an --epub-embed-image
option? Many thanks!
A possible workaround: add a dummy metadata field (e.g. extra_images
) with the extra images. That should be enough to get them included.
In a tweet presumably inspired by this issue, here is the exact syntax for the workaround:
In ePub writer, would you consider adding an option to add media files that are referenced only the style sheet, but not in the source documents?
https://groups.google.com/forum/#!topic/pandoc-discuss/BRqy-SEjBiQ