Errores al generar formatos epub y mobi con tex4ebook

Errores al generar formatos epub y mobi con tex4ebook

Este es un seguimiento de mis preguntas deaquíyaquí. Los archivos de configuración han sido proporcionados por @Michal.h21.

Recibo errores al usar tex4ebook y generar resultados epub y mobi.

El archivo de entrada (sample.tex) es:

\documentclass[ebook,12pt,oneside,openany]{memoir}

\begin{filecontents}{\jobname.bib}
@book{Hiemenz,
author={Hiemenz},
title={Polymer Chemistry}
}
\end{filecontents}

\usepackage{lipsum}

\usepackage{storebox}
\newstorebox{\mybox}

\usepackage{xskak}
\usepackage{chess-workshop-symbols}
\newcommand\mychessboard[1][]{\chessboard[#1]}

\usepackage[backend=biber,hyperref=auto,backref=true]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{imakeidx}

\makeindex[intoc=true,columns=1,noautomatic]

\usepackage[hyperindex=true]{hyperref}

\title{Book}
\author{Author}
\date{}

\begin{document}

\maketitle

\frontmatter

\tableofcontents \newpage

\mainmatter

\chapter{C1}

aword\index{aword}

\newchessgame

This is a chessboard.

\mychessboard

\storebox{\mybox}{\mychessboard}

This is a chessboard from storebox.

\usestorebox{\mybox}

Here comes a quotation \cite{Hiemenz}.

This is a chessboard from storebox.

\usestorebox{\mybox}

\newpage

\lipsum[1]

bword\index{bword}

\backmatter

\printbibliography \newpage
\printindex

\end{document}

El archivo de configuración es:

\RequirePackage{addfont4ht} % needed for skaknew font
%
% save the clearpage before it is redefined by tex4ht
%
\let\oldclrearpage\clearpage
%
% define macro for newpage insertion
%
\def\mypagebreak{\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}}
%
% new chessboard command
%
\renewcommand\mychessboard[1][]{\HCode{<div class="chessboard">}\Picture*{}\chessboard[#1]\EndPicture\HCode{</div>}}
%
\Preamble{xhtml}
%
% italic and bold
%
\Configure{textit}{\HCode{<span class="italic">}\NoFonts}{\EndNoFonts\HCode{</span>}}
\Configure{textbf}{\HCode{<span class="bold">}\NoFonts}{\EndNoFonts\HCode{</span>}}
\Css{.bold{font-weight:bold;}}
\Css{.italic{font-style:italic;}}
%
\catcode`\:=12
%
% enforce newpage
%
% define it for \newpage
%
\mypagebreak
\Css{.newpage{page-break-before:always;}}
%
% modify \Configure{BODY} so our configurations work on all extracted pages
%
\Configure{@BODY}{\def\clearpage{\bgroup\mypagebreak\oldclrearpage\egroup}}
\Configure{@/BODY}{\global\let\clearpage\oldclrearpage\Configure{newpage}{}}
%
% skak fonts
%
\AddFontFace{SkakNewFigurine}{SkakNew-Figurine}{SkakNew-Figurine.woff}{}
\Css{.SkakNew-Figurine-{font-family:"SkakNewFigurine",sans-serif;}}
%\Css{.SkakNew-Figurine-{font-family:"SkakNewFigurine",serif;}}
%
\begin{document}
%
\EndPreamble

El archivo de compilación es:

local filter    = require "make4ht-filter"

local process = filter{"cleanspan", "fixligatures"}

local used_images = {}
Make:image("png$", function(par)
  local output = par.output
  if not used_images[output] then
    local command = "dvipng -bg Transparent -T tight -D 167 -o ${output}  -pp ${page} ${source}" % par
    print(command)
    used_images[output] = true
    os.execute(command)
  end
  return true
end)

Make:add("biber","biber ${input}")

Make:add("xindy", function(par)
  -- par.encoding  = par.encoding or "utf8"
  -- par.language = par.language or "english"
  par.idxfile = par.idxfile or par.input .. ".idx"
  local modules = par.modules or {}
  local t = {}
  for k,v in ipairs(modules) do
    t[#t+1] = "-M ".. v
  end
  par.moduleopt = table.concat(t, " ")
  local xindy_call = "xindy -L ${language} -C ${encoding} ${moduleopt} ${idxfile}" % par
  print(xindy_call)
  return os.execute("xindy -L ${language} -C ${encoding} ${moduleopt} ${idxfile}" % par)
end, {modules = {"texindy"}, language = "english", encoding = "utf8"})

if mode=="draft" then
  Make:htlatex {}
else
  Make:htlatex {}
  Make:biber {}
  -- xindymodule = Make.params["input"]
  Make:xindy {modules = {"sample"}}
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}
end

Make:match("html$",process)

Cuando reviso el epub con epubcheck, el registro muestra errores:

Validating using EPUB version 2.0.1 rules.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(19,63): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(36,32): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(37,32): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(41,36): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(41,63): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(57,36): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(59,36): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(63,36): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(63,63): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(80,25): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(84,32): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(100,36): Error while parsing file 'element "p" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(103,25): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(107,25): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(111,40): Error while parsing file 'element "div" not allowed here; expected the element end-tag, text or element "a", "abbr", "acronym", "applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em", "i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg", "object", "q", "samp", "script", "small", "span", "strong", "sub", "sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")'.
FATAL(RSC-016): sample.epub/OEBPS/samplech1.html(113,3): Fatal Error while parsing file 'The element type "p" must be terminated by the matching end-tag "</p>".'.
ERROR(RSC-005): sample.epub/OEBPS/samplech1.html(-1,-1): Error while parsing file 'The element type "p" must be terminated by the matching end-tag "</p>".'.
FATAL(RSC-016): sample.epub/OEBPS/sample-1.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-1.svg(-1,-1): Error while parsing file 'Premature end of file.'.
FATAL(RSC-016): sample.epub/OEBPS/sample-2.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-2.svg(-1,-1): Error while parsing file 'Premature end of file.'.
FATAL(RSC-016): sample.epub/OEBPS/sample-3.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-3.svg(-1,-1): Error while parsing file 'Premature end of file.'.
FATAL(RSC-016): sample.epub/OEBPS/sample-4.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-4.svg(-1,-1): Error while parsing file 'Premature end of file.'.
FATAL(RSC-016): sample.epub/OEBPS/sample-5.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-5.svg(-1,-1): Error while parsing file 'Premature end of file.'.
FATAL(RSC-016): sample.epub/OEBPS/sample-6.svg(1,1): Fatal Error while parsing file 'Premature end of file.'.
ERROR(RSC-005): sample.epub/OEBPS/sample-6.svg(-1,-1): Error while parsing file 'Premature end of file.'.

El uso de Kindlegen también genera errores:

*************************************************************
 Amazon kindlegen(Windows) V2.9 build 1029-0897292
 A command line e-book compiler
 Copyright Amazon.com and its Affiliates 2014
*************************************************************

Info(prcgen):I1047: Added metadata dc:Title        "Book"
Info(prcgen):I1047: Added metadata dc:Date         "2017-02-01T14:26:00Z"
Info(prcgen):I1047: Added metadata dc:Creator      "Author"
Info(prcgen):I1002: Parsing files  0000005
Warning(htmlprocessor):W28003: Value specified for CSS property in content is not supported by Kindle readers. Please refer Kindle Publishing Guidelines about usage of property: 'position: relative' in file: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample.css
Warning(inputpreprocessor):W29004: Forcefully closed opened Tag: <p class="indent">
      in file: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\samplech1.html     line: 0000035
Warning(inputpreprocessor):W29004: Forcefully closed opened Tag: <p class="indent">
      in file: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\samplech1.html     line: 0000041
Warning(inputpreprocessor):W29004: Forcefully closed opened Tag: <p class="indent">
      in file: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\samplech1.html     line: 0000056
Warning(inputpreprocessor):W29004: Forcefully closed opened Tag: <p class="indent">
      in file: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\samplech1.html     line: 0000078
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-1.svg
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-2.svg
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-3.svg
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-4.svg
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-5.svg
Warning(prcgen):W14010: media file not found  C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample-6.svg
Info(prcgen):I1015: Building PRC file
Info(prcgen):I1006: Resolving hyperlinks
Info(prcgen):I1049: Building table of content     URL: C:\Users\User\AppData\Local\Temp\mbp_7E1_2_1_E_2A_3A_EF_2114_B00_1\OEBPS\sample.ncx
Warning(prcgen):W14016: Cover not specified
Info(pagemap):I8000: No Page map found in the book
Info(prcgen):I1045: Computing UNICODE ranges used in the book
Info(prcgen):I1046: Found UNICODE range: Basic Latin [20..7E]
Info(prcgen):I1017: Building PRC file, record count:   0000002
Info(prcgen):I1039: Final stats - text compressed to (in % of original size):  41.83%
Info(prcgen):I1040: The document identifier is: "Book"
Info(prcgen):I1041: The file format version is V6
Info(prcgen):I1031: Saving PRC file
Info(prcgen):I1033: PRC built with WARNINGS!
Info(prcgen):I1016: Building enhanced PRC file
Info(prcgen):I1007: Resolving mediaidlinks
Info(prcgen):I1011: Writing mediaidlinks
Info(prcgen):I1009: Resolving guide items
Info(prcgen):I1017: Building PRC file, record count:   0000006
Info(prcgen):I1039: Final stats - text compressed to (in % of original size):  36.92%
Info(prcgen):I1041: The file format version is V8
Info(prcgen):I1032: PRC built successfully
Info(prcgen):I15000:  Approximate Standard Mobi Deliverable file size :   0000125KB
Info(prcgen):I15001:  Approximate KF8 Deliverable file size :   0000139KB
Info(prcgen):I1037: Mobi file built with WARNINGS!

Calibre puede mostrar ambas versiones sin problemas.

¿Hay alguna manera de corregir estos errores o puedo simplemente ignorarlos?

Gracias.

Respuesta1

Hay dos fuentes principales de problemas: primero, el chesboardpaquete usa Tikz para dibujar algunas cosas en el tablero de ajedrez y produce imágenes SVG rotas; el segundo problema es ese \usestorebox y probablemente algunas otras configuraciones produzcan párrafos incorrectos en el HTML.

Es fácil deshabilitar las imágenes SVG, solo necesitamos usar diferentes servidores de Tikz para producir dibujos. Agregue el siguiente código antes \usepackage{xskak}, que carga chessboardel paquete:

\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvips.def}
\fi

Para manejar las etiquetas de párrafo incorrectas, pruebe este .cfgarchivo modificado:

\RequirePackage{addfont4ht} % needed for skaknew font
%
% save the clearpage before it is redefined by tex4ht
%
\let\oldclrearpage\clearpage
%
% define macro for newpage insertion
%
\def\mypagebreak{\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}}
%
% new chessboard command
%
\renewcommand\mychessboard[1][]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\HCode{<div class="chessboard">}\Picture*{}\chessboard[#1]\EndPicture\HCode{</div>}\HtmlParOn}
\let\tmpusavebox\usestorebox
\renewcommand\usestorebox[1]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\tmpusavebox{#1}\HtmlParOn\ifvmode\IgnorePar\fi\par\EndP\HCode{ }}

%
\Preamble{xhtml}
%
% italic and bold
%
\Configure{textit}{\HCode{<span class="italic">}\NoFonts}{\EndNoFonts\HCode{</span>}}
\Configure{textbf}{\HCode{<span class="bold">}\NoFonts}{\EndNoFonts\HCode{</span>}}
\Css{.bold{font-weight:bold;}}
\Css{.italic{font-style:italic;}}
%
\catcode`\:=12
%
% enforce newpage
%
% define it for \newpage
%
\mypagebreak
\Css{.newpage{page-break-before:always;}}
%
% modify \Configure{BODY} so our configurations work on all extracted pages
%
\Configure{@BODY}{\def\clearpage{\bgroup\mypagebreak\oldclrearpage\egroup}\HtmlParOn}
\Configure{@/BODY}{\global\let\clearpage\oldclrearpage\Configure{newpage}{}\HtmlParOff}
%
% skak fonts
%
\AddFontFace{SkakNewFigurine}{SkakNew-Figurine}{SkakNew-Figurine.woff}{}
\Css{.SkakNew-Figurine-{font-family:"SkakNewFigurine",sans-serif;}}
%\Css{.SkakNew-Figurine-{font-family:"SkakNewFigurine",serif;}}
%
\begin{document}
%
\EndPreamble

Las principales diferencias son:

\renewcommand\mychessboard[1][]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\HCode{<div class="chessboard">}\Picture*{}\chessboard[#1]\EndPicture\HCode{</div>}\HtmlParOn}

Agregué \HtmlParOffcomandos \HtmlParOnpara deshabilitar la inclusión de cualquier párrafo en el tablero de ajedrez. De lo contrario, obtendría el siguiente código HTML no válido:

<!--l. 56--><p class="indent" >
<!--l. 58--><p class="indent" >   This is a chessboard from storebox.
</p>

   </p>

Necesitamos deshabilitar </p>las etiquetas incorrectas también después de \usestorebox:

\let\tmpusavebox\usestorebox
\renewcommand\usestorebox[1]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\tmpusavebox{#1}\HtmlParOn\ifvmode\IgnorePar\fi\par\EndP\HCode{ }}

El código comodín al final: \HtmlParOn\ifvmode\IgnorePar\fi\par\EndP\HCode{ }solicita la inclusión de un nuevo párrafo después del cuadro almacenado. Me doy cuenta de que es un poco críptico :)

\Configure{@BODY}{\def\clearpage{\bgroup\mypagebreak\oldclrearpage\egroup}\HtmlParOn}
\Configure{@/BODY}{\global\let\clearpage\oldclrearpage\Configure{newpage}{}\HtmlParOff}

Esto desactiva la inclusión de párrafos después de </html>la etiqueta y se vuelve a utilizar \HtmlParOff.

epubcheckdebería ser feliz ahora:

$ epubcheck sample.epub 
Validating against EPUB version 2.0 - custom validation
Validating using EPUB version 2.0 rules.
No errors or warnings detected.
epubcheck completed

información relacionada