
이것은 내 질문에 대한 후속 조치입니다.여기그리고여기. 설정 파일은 @Michal.h21에서 제공되었습니다.
tex4ebook을 사용하고 epub 및 mobi 출력을 생성할 때 오류가 발생합니다.
입력 파일(sample.tex)은 다음과 같습니다.
\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}
구성 파일은 다음과 같습니다.
\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
빌드 파일은 다음과 같습니다.
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)
epubcheck로 epub를 확인하면 로그에 오류가 표시됩니다.
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.'.
Kindlegen을 사용하면 오류가 발생합니다.
*************************************************************
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는 문제 없이 두 버전을 모두 표시할 수 있습니다.
이러한 오류를 수정할 수 있는 방법이 있나요? 아니면 그냥 무시해도 되나요?
감사합니다.
답변1
문제에는 두 가지 주요 소스가 있습니다. 첫 번째는 chesboard
패키지가 Tikz를 사용하여 체스판에 일부 항목을 그려서 깨진 SVG 이미지를 생성한다는 것이고, 두 번째 문제는 \usestorebox
아마도 일부 다른 구성이 HTML에서 잘못된 단락을 생성한다는 것입니다.
SVG 이미지를 비활성화하는 것은 쉽습니다. 다른 Tikz 백엔드를 사용하여 그림을 생성하기만 하면 됩니다. 패키지를 \usepackage{xskak}
로드하는 앞에 다음 코드를 추가합니다 chessboard
.
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvips.def}
\fi
잘못된 단락 태그를 처리하려면 다음 수정된 .cfg
파일을 사용해 보세요.
\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
주요 차이점은 다음과 같습니다.
\renewcommand\mychessboard[1][]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\HCode{<div class="chessboard">}\Picture*{}\chessboard[#1]\EndPicture\HCode{</div>}\HtmlParOn}
체스판에 어떤 단락도 포함하지 않도록 하는 명령을 \HtmlParOff
추가 했습니다 . \HtmlParOn
그렇지 않으면 다음과 같은 잘못된 HTML 코드가 표시됩니다.
<!--l. 56--><p class="indent" >
<!--l. 58--><p class="indent" > This is a chessboard from storebox.
</p>
</p>
</p>
다음 이후에도 잘못된 태그를 비활성화해야 합니다 \usestorebox
.
\let\tmpusavebox\usestorebox
\renewcommand\usestorebox[1]{\ifvmode\IgnorePar\fi\EndP\HtmlParOff\tmpusavebox{#1}\HtmlParOn\ifvmode\IgnorePar\fi\par\EndP\HCode{ }}
끝에 있는 와일드 코드: \HtmlParOn\ifvmode\IgnorePar\fi\par\EndP\HCode{ }
저장된 상자 뒤에 새 단락을 포함하도록 요청합니다. 나는 그것이 약간 비밀스럽다는 것을 깨닫는다 :)
\Configure{@BODY}{\def\clearpage{\bgroup\mypagebreak\oldclrearpage\egroup}\HtmlParOn}
\Configure{@/BODY}{\global\let\clearpage\oldclrearpage\Configure{newpage}{}\HtmlParOff}
</html>
이렇게 하면 태그 뒤에 단락을 포함할 수 없게 되며 \HtmlParOff
다시 사용됩니다.
epubcheck
지금은 행복해야 해:
$ 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