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

RSC-005 [EPUB3 Error Code] if \caption before \includegraphics #112

Open
Kuan-Lun opened this issue Aug 12, 2023 · 1 comment
Open

RSC-005 [EPUB3 Error Code] if \caption before \includegraphics #112

Kuan-Lun opened this issue Aug 12, 2023 · 1 comment

Comments

@Kuan-Lun
Copy link

The following is an example. I use tex4ebook --format epub3 "main.tex".

% main.tex
\documentclass{article}
\usepackage{graphicx}
\title{Test}
\author{Test}
\date{2023-08-12}
\begin{document}
\maketitle
\tableofcontents
\begin{figure}
\caption{123}
\includegraphics{test.png}
\end{figure}
%%%% The following is fine.
% \begin{figure}
% \includegraphics{test.png}
% \caption{123}
% \end{figure}
\end{document}

The mainli1.xhtml in the output file main.epub is incorrect by EPUBCheck.

Validating using EPUB version 3.2 rules.
ERROR(RSC-005): [path]/main.epub/OEBPS/mainli1.xhtml(19,33): Error while parsing file: element "img" not allowed here; expected the element end-tag

Check finished with errors
Messages: 0 fatals / 1 error / 0 warnings / 0 infos

EPUBCheck completed

@michal-h21
Copy link
Owner

It should be fixed in the development version of make4ht. Until it is available in TeX Live (I am not sure when I will release the new version), you can use this build file:

local domfilter = require "make4ht-domfilter"

local process = domfilter {
  function(dom)
    for _, el in ipairs(dom:query_selector("figure > a")) do
      local id = el:get_attribute "id" 
      if id then
        local parent = el:get_parent()
        if not parent:get_attribute("id") then
          parent:set_attribute("id", id)
          el:remove_node()
        end
      end
    end
    return dom
  end
}

Make:match("html$", process)

Compile using

$ tex4ebook -e build.lua --format epub3 "main.tex".

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

No branches or pull requests

2 participants