pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
600 stars 165 forks source link

Error checking diagram-containing epub file #257

Closed piccolbo closed 1 year ago

piccolbo commented 1 year ago

Hi, I am using diagram-generator to create diagrams like this

{.graphviz #fig:cyclomatic caption="Graphs corresponding to `if` and `while` statements resp."}
graph {
  if -- then; if--else; then -- "end if" ; else -- "end if" ;
  while -- body; body-- while; while -- "end while";
  }

They look just fine, but the epub containing them doesn't pass epubcheck 4.2.6 with a raft of errors like ERROR(HTM-003): <some svg file name here> External entities are not allowed in EPUB v3 documents. External entity declaration found

As you may know, passing a clean epubcheck, an official w3c tool, is a pre-condition to accepting a submission for some publishers. I was wondering if anyone has seen this and knows the solutions.

As a workaround, can I force png output?

I know reporting this here may be useless, since these files are generated by graphviz. On the other hand, the graphviz team may have no clue about epub and its requirements. I am kind of caught in between. It seems this is an additional restriction on svg specified by the epub committee. It isn't enough for an svg tool to generate legal svg to guarantee that the inclusion into an epub will be standard compliant. It seems like a bad design to me. Thanks!

piccolbo commented 1 year ago

I am not sure this is related, but if it is these errors may disappear in future versions of epubcheck.

https://github.com/w3c/epubcheck/issues/1114

tarleb commented 1 year ago

Thanks, that's all interesting information. You can force PNG output by changing lines 66, 67 to

local filetype = "png"
local mimetype = "image/png"
piccolbo commented 1 year ago

I can confirm the workaround works. Of course, there are side effects like losing the scalability of svg and increasing the file size. But it beats not being able to submit your book to a publisher. It will also increase compatibility with older readers, I understand early kindles don't support svg.