Skip to content

Commit

Permalink
epub: fix logo not declared in the OPF manifest
Browse files Browse the repository at this point in the history
We need to list all the resources included in the EPUB file in the OPF
manifest, we missed doing that for the logo.

Basically this PR should fix the following error found by `epubcheck`:

```json
  {
    "ID" : "RSC-008",
    "severity" : "ERROR",
    "message" : "Referenced resource \"OEBPS/assets/logo.png\" is not declared in the OPF manifest.",
    "locations" : [ {
      "path" : "OEBPS/title.xhtml",
      "line" : 21,
      "column" : 55
    } ]
  }
```

I also some small refactor in this template.
  • Loading branch information
milmazz committed Jan 25, 2024
1 parent 67e03ea commit a4a1e92
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions lib/ex_doc/formatter/epub/templates/content_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,30 @@
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav scripted"/>
<item id="cover" href="title.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
<%= for {_title, extras} <- config.extras do %>
<%= for extra <- extras do %>
<item id="<%= URI.encode extra.id %>" href="<%= URI.encode extra.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
<% end %>
<%= for {_title, extras} <- config.extras, extra <- extras do %>
<item id="<%= URI.encode extra.id %>" href="<%= URI.encode extra.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
<% end %>
<%= for filter <- [:modules, :tasks] do %>
<%= for node <- nodes[filter] do %>
<item id="<%= URI.encode node.id %>" href="<%= URI.encode node.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
<% end %>
<%= for filter <- [:modules, :tasks], node <- nodes[filter] do %>
<item id="<%= URI.encode node.id %>" href="<%= URI.encode node.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/>
<% end %>
<%= for static_file <- static_files do %>
<item id="<%= static_file_to_id(static_file) %>" href="<%= static_file %>" media-type="<%= media_type(Path.extname(static_file)) %>"/>
<% end %>
<%= if config.cover do %>
<%= if Path.extname(config.cover) == ".png" do %>
<item id="cover-image" href="assets/cover.png" media-type="image/png"/>
<% end %>
<%= if Path.extname(config.cover) == ".jpg" do %>
<item id="cover-image" href="assets/cover.jpg" media-type="image/jpeg"/>
<% end %>
<item id="cover-image" href="assets/cover<%= Path.extname(config.cover) %>" media-type="<%= media_type(Path.extname(config.cover))%>"/>
<% end %>
<%= if config.logo do %>
<item id="logo" href="assets/logo<%= Path.extname(config.logo) %>" media-type="<%= media_type(Path.extname(config.logo))%>"/>
<% end %>
</manifest>
<spine>
<itemref idref="cover"/>
<itemref idref="nav"/>
<%= for {_title, extras} <- config.extras do %>
<%= for extra <- extras do %>
<itemref idref="<%= URI.encode extra.id %>"/>
<% end %>
<% end %>
<%= for filter <- [:modules, :tasks] do %>
<%= for node <- nodes[filter] do %>
<itemref idref="<%= URI.encode node.id %>"/>
<% end %>
<%= for {_title, extras} <- config.extras, extra <- extras do %>
<itemref idref="<%= URI.encode extra.id %>"/>
<% end %>
<%= for filter <- [:modules, :tasks], node <- nodes[filter] do %>
<itemref idref="<%= URI.encode node.id %>"/>
<% end %>
</spine>
</package>

0 comments on commit a4a1e92

Please sign in to comment.