summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-02-24 03:01:46 +0000
committerNorbert Preining <norbert@preining.info>2024-02-24 03:01:46 +0000
commitf325bd88d1d4db13f51277bc59c8ff8814e937bc (patch)
treee39af6619c91d812dd93cb57d25149da5a84d801 /support
parente7a321bba289c40f39563c19bbeac355f7c0eeeb (diff)
CTAN sync 202402240301
Diffstat (limited to 'support')
-rw-r--r--support/TeX4ht/source/ChangeLog21
-rw-r--r--support/TeX4ht/source/tex4ht-4ht.tex82
-rw-r--r--support/TeX4ht/source/tex4ht-html4.tex4
-rw-r--r--support/TeX4ht/source/tex4ht-jats.tex94
-rw-r--r--support/TeX4ht/source/tex4ht-mathml.tex19
-rw-r--r--support/make4ht/README43
-rw-r--r--support/make4ht/changelog.tex211
-rw-r--r--support/make4ht/domfilters/make4ht-collapsetoc.lua2
-rw-r--r--support/make4ht/domfilters/make4ht-idcolons.lua30
-rw-r--r--support/make4ht/domfilters/make4ht-inlinecss.lua2
-rw-r--r--support/make4ht/domfilters/make4ht-mathmlfixes.lua120
-rw-r--r--support/make4ht/domfilters/make4ht-sectionid.lua29
-rw-r--r--support/make4ht/domfilters/make4ht-tablerows.lua8
-rw-r--r--support/make4ht/extensions/make4ht-ext-copy_images.lua68
-rw-r--r--support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-latexmk_build.lua4
-rw-r--r--support/make4ht/extensions/make4ht-ext-staticsite.lua17
-rw-r--r--support/make4ht/filters/make4ht-domfilter.lua5
-rw-r--r--support/make4ht/formats/make4ht-jats.lua6
-rw-r--r--support/make4ht/formats/make4ht-odt.lua8
-rwxr-xr-xsupport/make4ht/make4ht14
-rw-r--r--support/make4ht/make4ht-doc.pdfbin156343 -> 161887 bytes
-rw-r--r--support/make4ht/make4ht-errorlogparser.lua22
-rw-r--r--support/make4ht/make4ht-htlatex.lua20
-rw-r--r--support/make4ht/make4ht-indexing.lua4
-rw-r--r--support/make4ht/make4ht-lib.lua7
-rw-r--r--support/make4ht/mkparams.lua14
-rw-r--r--support/make4ht/mkutils.lua81
-rw-r--r--support/make4ht/readme.tex52
-rw-r--r--support/tex4ebook/README4
-rw-r--r--support/tex4ebook/changelog.tex57
-rw-r--r--support/tex4ebook/readme.tex8
-rwxr-xr-xsupport/tex4ebook/tex4ebook8
-rw-r--r--support/tex4ebook/tex4ebook-doc.pdfbin90565 -> 91455 bytes
-rw-r--r--support/tex4ebook/tex4ebook-epub3.4ht4
-rw-r--r--support/tex4ebook/tex4ebook-exec_epub.lua29
-rw-r--r--support/tex4ebook/tex4ebook.4ht11
-rw-r--r--support/tex4ebook/tex4ebook.sty12
38 files changed, 954 insertions, 168 deletions
diff --git a/support/TeX4ht/source/ChangeLog b/support/TeX4ht/source/ChangeLog
index 9169988704..62528a3a28 100644
--- a/support/TeX4ht/source/ChangeLog
+++ b/support/TeX4ht/source/ChangeLog
@@ -1,3 +1,24 @@
+2024-02-22 Michal Hoftich <michal.h21@gmail.com>
+
+ * tex4ht-jats.tex (jats.4ht): fixed DOCTYPE.
+
+ * tex4ht-jats.tex (jats.4ht): added support for BibLaTeX.
+
+2024-02-21 Michal Hoftich <michal.h21@gmail.com>
+
+ * tex4ht-jats.tex (jats.4ht): removed \space commands from inside of
+ the <title> element. It is suppossed to be used after the \TitleMark
+ command, and to be eaten by \:gobble if section numbers shoulnd't be
+ shown.
+
+ * tex4ht-4ht.tex (mhchem.4ht): added support for Mhchem characters
+ in pictures.
+
+ * tex4ht-4ht.tex (mhchem.4ht),
+ * tex4ht-mathml.tex (mathml.4ht),
+ * tex4ht-html4.tex (html4.4ht): fixed some issues with Mhchem
+ superscripts and subscripts.
+
2024-02-19 Michal Hoftich <michal.h21@gmail.com>
* tex4ht-mathml.tex (mathml.4ht): fixed rendering of
diff --git a/support/TeX4ht/source/tex4ht-4ht.tex b/support/TeX4ht/source/tex4ht-4ht.tex
index b48cac55f5..13c70fc3d2 100644
--- a/support/TeX4ht/source/tex4ht-4ht.tex
+++ b/support/TeX4ht/source/tex4ht-4ht.tex
@@ -1,4 +1,4 @@
-% $Id: tex4ht-4ht.tex 1461 2024-02-13 15:20:24Z michal_h21 $
+% $Id: tex4ht-4ht.tex 1465 2024-02-21 13:48:35Z michal_h21 $
% tex tex4ht-4ht or ht tex tex4ht-4ht
%
% Copyright 2009-2024 TeX Users Group
@@ -30838,6 +30838,8 @@ it come out as a complete mess.
\NewConfigure{mhchemsup}{2}
+\NewConfigure{mhchemsupsub}{3}
+
\cs_set_protected:Npn \__mhchem_output_coreFivefourht:nnnnnnn #1#2#3#4#5#6#7
{
\bool_if:nT
@@ -30872,11 +30874,11 @@ it come out as a complete mess.
\b:mhchemsup
}
{
- \HCode { <span~class="mhchem-supsub"> }
+ \a:mhchemsupsub
\__mhchem_output_withFont:n { #4#5#7 }
- \HCode { <br~/>&\#xfeff; }
+ \c:mhchemsupsub
\__mhchem_output_withFont:n { #6 }
- \HCode { </span> }
+ \b:mhchemsupsub
}
}
}
@@ -30905,58 +30907,56 @@ it come out as a complete mess.
% replace original coreFive with our alternative version. it will work in picture math
\HLet\__mhchem_output_coreFive:nnnnnnn\__mhchem_output_coreFivefourht:nnnnnnn
-\cs_set_protected:Npn \__mhchem_output_withFont:n #1 %. output #1 as math or text
+\cs_set_protected:Npn \__mhchem_output_withFontfourht:n #1 %. output #1 as math or text
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
{ \begingroup\mathrm {#1}\endgroup }
{ \begingroup\text {#1}\endgroup }
}
+\HLet\__mhchem_output_withFont:n\__mhchem_output_withFontfourht:n
+
\NewConfigure{mhchemoperator}{2}
-% ideally, the following commands should be redefined using \HLet, to support picture math.
-% the current definition should work in MathML, I am not sure about normall HTML, as
-\cs_set_protected:Npn \__mhchem_output_skipAfterAmount: {\HCode { ~ } } % space for copy & paste
-\cs_set_protected:Npn \__mhchem_output_skipBeforeStateOfAggregation: {}
-\cs_set_protected:Npn \__mhchem_output_minus: {\HCode{&\#x2212;}} % minus
-\cs_set_protected:Npn \__mhchem_output_operatorPlus:
- { \HCode {\a:mhchemoperator + \b:mhchemoperator }}
-\cs_set_protected:Npn \__mhchem_output_operatorMinus:
- { \HCode {\a:mhchemoperator&\#x2212; \b:mhchemoperator }} % minus
-\cs_set_protected:Npn \__mhchem_output_operatorEquals:
- { \HCode {\a:mhchemoperator = \b:mhchemoperator }}
-\cs_set_protected:Npn \__mhchem_output_operatorPlusMinus:
- {\HCode {\a:mhchemoperator &\#xB1; \b:mhchemoperator }} % plusmn
-\cs_set_protected:Npn \__mhchem_output_electronDot: { \HCode {&\#x2022;} } % bull
-\cs_set_protected:Npn \__mhchem_output_additionCompound: { \HCode {&\#xB7;} } % middot
-\cs_set_protected:Npn \__mhchem_output_excited: { \HCode { &\#x2731; } }
-\cs_set_protected:Npn \__mhchem_output_commaDecimal: { , }
-\cs_set_protected:Npn \__mhchem_output_commaEnumeration: {,\HCode {&\#x2009;} } % thinsp
-\cs_set_protected:Npn \__mhchem_output_commaEnumerationSmall: {,\HCode{&\#x2009;} } % thinsp
-
-\cs_set_protected:Npn \__mhchem_output_bond_single: { \HCode { \a:mhchemoperator&\#x2212;\b:mhchemoperator}}
-\cs_set_protected:Npn \__mhchem_output_bond_double: { \HCode { \a:mhchemoperator=\b:mhchemoperator}}
-\cs_set_protected:Npn \__mhchem_output_bond_triple: { \HCode { \a:mhchemoperator&\#x2261;\b:mhchemoperator}}
+\def\:tempa#1#2{%
+ \cs_set_protected:Npn\:tempb:{#2}%
+ \HLet#1\:tempb:%
+}
+
+\:tempa \__mhchem_output_skipAfterAmount: {\HCode { ~ } } % space for copy & paste
+\:tempa \__mhchem_output_skipBeforeStateOfAggregation: {}
+\:tempa \__mhchem_output_minus: {\HCode{&\#x2212;}} % minus
+\:tempa \__mhchem_output_operatorPlus:{ \HCode {\a:mhchemoperator + \b:mhchemoperator }}
+\:tempa \__mhchem_output_operatorMinus:{ \HCode {\a:mhchemoperator&\#x2212; \b:mhchemoperator }} % minus
+\:tempa \__mhchem_output_operatorEquals:{ \HCode {\a:mhchemoperator = \b:mhchemoperator }}
+\:tempa \__mhchem_output_operatorPlusMinus:{\HCode {\a:mhchemoperator &\#xB1; \b:mhchemoperator }} % plusmn
+\:tempa \__mhchem_output_electronDot: { \HCode {&\#x2022;} } % bull
+\:tempa \__mhchem_output_additionCompound: { \HCode {&\#xB7;} } % middot
+\:tempa \__mhchem_output_excited: { \HCode { &\#x2731; } }
+\:tempa \__mhchem_output_commaDecimal: { , }
+\:tempa \__mhchem_output_commaEnumeration: {,\HCode {&\#x2009;} } % thinsp
+\:tempa \__mhchem_output_commaEnumerationSmall: {,\HCode{&\#x2009;} } % thinsp
+
+\:tempa \__mhchem_output_bond_single: { \HCode { \a:mhchemoperator&\#x2212;\b:mhchemoperator}}
+\:tempa \__mhchem_output_bond_double: { \HCode { \a:mhchemoperator=\b:mhchemoperator}}
+\:tempa \__mhchem_output_bond_triple: { \HCode { \a:mhchemoperator&\#x2261;\b:mhchemoperator}}
% todo: add MathML support for these
-\cs_set_protected:Npn \__mhchem_output_bond_half: % todo: improve
- {\a:mhchembondhalf}
-\cs_set_protected:Npn \__mhchem_output_bond_oneAndHalf: % todo: improve
- {\a:mhchembondoneandhalf}
-\cs_set_protected:Npn \__mhchem_output_bond_twoAndHalf: % todo: improve
- {\a:mhchembondtwoandhalf}
-\cs_set_protected:Npn \__mhchem_output_bond_twoAndHalff: % todo: improve
- {\a:mhchembondtwoandhalff}
+\:tempa \__mhchem_output_bond_half:{\a:mhchembondhalf}
+\:tempa \__mhchem_output_bond_oneAndHalf:{\a:mhchembondoneandhalf}
+\:tempa \__mhchem_output_bond_twoAndHalf:{\a:mhchembondtwoandhalf}
+\:tempa \__mhchem_output_bond_twoAndHalff:{\a:mhchembondtwoandhalff}
+
+\:tempa \__mhchem_output_bond_dotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;} } % &middot;&middot;&middot;
+\:tempa \__mhchem_output_bond_dotdotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;&\#xB7;} } % &middot;&middot;&middot;&middot;
+\:tempa \__mhchem_output_bond_rightArrow: { \HCode { &\#xffeb; } }
+\:tempa \__mhchem_output_bond_leftArrow: { \HCode { &\#xffe9; } }
+
\NewConfigure{mhchembondhalf}{1}
\NewConfigure{mhchembondoneandhalf}{1}
\NewConfigure{mhchembondtwoandhalf}{1}
\NewConfigure{mhchembondtwoandhalff}{1}
-\cs_set_protected:Npn \__mhchem_output_bond_dotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;} } % &middot;&middot;&middot;
-\cs_set_protected:Npn \__mhchem_output_bond_dotdotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;&\#xB7;} } % &middot;&middot;&middot;&middot;
-\cs_set_protected:Npn \__mhchem_output_bond_rightArrow: { \HCode { &\#xffeb; } }
-\cs_set_protected:Npn \__mhchem_output_bond_leftArrow: { \HCode { &\#xffe9; } }
-
\NewConfigure{mhchemarrow}{2}
diff --git a/support/TeX4ht/source/tex4ht-html4.tex b/support/TeX4ht/source/tex4ht-html4.tex
index e09bb507b2..8077218bec 100644
--- a/support/TeX4ht/source/tex4ht-html4.tex
+++ b/support/TeX4ht/source/tex4ht-html4.tex
@@ -1,4 +1,4 @@
-% $Id: tex4ht-html4.tex 1461 2024-02-13 15:20:24Z michal_h21 $
+% $Id: tex4ht-html4.tex 1464 2024-02-21 09:46:01Z michal_h21 $
% Compile 4 times: latex tex4ht-html4
% Copy html4.4ht into the work directory before all but the last compilation.
%
@@ -21757,13 +21757,13 @@ users redefine the latter macro.
%%%%%%%%%%%%%%%%%%%%%
\<configure html4 mhchem\><<<
-\typeout{***************** hello mhchem}
\Configure{mhchemcf}{\HCode{<span class="mhchem">}}{\HCode{</span>}}
\Configure{mhchemce}{\HCode{<span class="mhchem">}}{\HCode{</span>}}
\Configure{mhchemisotope}{\HCode{<span class="mhchem-isotope">}}{\HCode{<br />&\#xfeff;}}{\HCode{</span>}}
\Configure{mhchemsub}{\HCode {<sub class="mhchem-sub">}}{\HCode{</sub>} }
\Configure{mhchemsup}{\HCode {<sup class="mhchem-sup">}}{\HCode{</sup>} }
+\Configure{mhchemsupsub}{\HCode{<span class="mhchem-supsub">}}{\HCode{<br />&\#xfeff;}}{\HCode{</span>}}
% mhchemoperator is always used inside \HCode, so we need not to use \HCode in it's configuration
\Configure{mhchemoperator}{<span class="mhchem-operator">}{</span>}
\Configure{mhchemarrow}{\HCode {<span class="mhchem-arrow">}}{\HCode{</span>}}
diff --git a/support/TeX4ht/source/tex4ht-jats.tex b/support/TeX4ht/source/tex4ht-jats.tex
index dc9ae8e5b9..071826a31e 100644
--- a/support/TeX4ht/source/tex4ht-jats.tex
+++ b/support/TeX4ht/source/tex4ht-jats.tex
@@ -1,8 +1,8 @@
-% $Id: tex4ht-jats.tex 269 2020-03-03 23:06:07Z karl $
+% $Id: tex4ht-jats.tex 1472 2024-02-22 22:12:22Z karl $
% compile 3 times: latex tex4ht-jats
% or xhlatex tex4ht-jats "html,3,sections+"
%
-% Copyright 2009-2022 TeX Users Group
+% Copyright 2009-2024 TeX Users Group
% Copyright 2000-2009 Eitan M. Gurari
% Released under LPPL 1.3c+.
% See tex4ht-cpright.tex for license text.
@@ -26,7 +26,7 @@
\<jats\><<<
% jats.4ht (|version), generated from |jobname.tex
-% Copyright 2022 TeX Users Group
+% Copyright 2022-2024 TeX Users Group
|<TeX4ht copywrite|>
>>>
@@ -223,7 +223,9 @@ Configurations that are shared only for article and report
\NewConfigure{DtdVersion}{1}
\Configure{DtdVersion}{1.3}
-\Configure{DOCTYPE}{\HCode{<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v\a:DtdVersion\space 20130915//EN" "http://jats.nlm.nih.gov/archiving/\a:DtdVersion/JATS-archivearticle1-mathml3.dtd">\Hnewline}}
+\def\:DTD{jats} % this is necessary to prevent html-mml from overriding DOCTYPE
+%
+\Configure{DOCTYPE}{\HCode{<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v\a:DtdVersion\space 20210610//EN" "JATS-archivearticle1-3.dtd">\Hnewline}}
% XML configuratins
\edef\html:xmlns{}
@@ -587,7 +589,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{chapter}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\TitleMark\HCode{<title>}\space\HtmlParOff}
+ {\TitleMark\space\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\ConfigureMark{chapter}
@@ -598,7 +600,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{appendix}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\TitleMark\HCode{<title>}\space\HtmlParOff}
+ {\TitleMark\space\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\ConfigureMark{appendix}{\HCode{<label>}%
@@ -609,7 +611,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{likechapter}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
>>>
@@ -622,7 +624,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{section}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\TitleMark\HCode{<title>}\space\HtmlParOff}
+ {\TitleMark\space\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\ConfigureMark{section}
@@ -635,7 +637,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{subsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\TitleMark\HCode{<title>}\space\HtmlParOff}
+ {\TitleMark\space\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\ConfigureMark{subsection}
@@ -648,7 +650,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{subsubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\TitleMark\HCode{<title>}\space\HtmlParOff}
+ {\TitleMark\space\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\ConfigureMark{subsubsection}
@@ -661,7 +663,7 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{paragraph}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
>>>
@@ -670,25 +672,25 @@ This macro is used to print zeropaded days and months in the ISO date attribute
\Configure{likesection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\Configure{likesubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\Configure{likesubsubsection}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
\Configure{likeparagraph}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{<sec>\Hnewline}}
{\ifvmode\IgnorePar\fi\EndP\IgnorePar\HCode{</sec>\Hnewline}}
- {\HCode{<title>}\space\HtmlParOff}
+ {\HCode{<title>}\HtmlParOff}
{\HCode{</title>}\HtmlParOn \ShowPar\par}
>>>
@@ -837,6 +839,8 @@ them separatelly.
\chapter{Packages}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\section{Hyperref}
+
\<configure jats url\><<<
|<url links|>
>>>
@@ -845,4 +849,64 @@ them separatelly.
|<hyperref links|>
>>>
+\section{Bibliographies}
+
+\<configure jats biblatex\><<<
+|<biblatex environment|>
+|<biblatex fields|>
+>>>
+
+
+\<biblatex environment\><<<
+ \def\bibConfigure{%
+ \ConfigureList{thebibliography}
+ {\ifvmode \IgnorePar \fi \EndP \EndP
+ \HCode{<ref-list>}\HtmlParOff%
+ \immediate\write\@auxout{%
+ \string\providecommand\string\BibFileName[2][]{}
+ }%
+ \immediate\write\@auxout{%
+ \string\BibFileName[\therefsection]{\FileName}}%
+ \PushMacro \end:itm \global \let \end:itm =\empty}%
+ {\ifvmode \IgnorePar \fi \EndP
+ \PopMacro \end:itm \global \let \end:itm \end:itm \EndP
+ \HCode {</mixed-citation></ref></ref-list>}\HtmlParOn\ShowPar}%
+ {\ifvmode \IgnorePar \fi \EndP \gHAdvance \bibN by 1
+ \end:itm \global \def \end:itm {\EndP \HCode{</mixed-citation></ref>}}%
+ \Tag{X\therefsection-\abx@field@entrykey}{bibitem-\bibN}
+ \HCode {<ref id="bibitem-\bibN"><label>}}%
+ {\ifvmode \IgnorePar \fi \EndP
+ \HCode {</label><mixed-citation publication-type="\thefield{entrytype}" id="bib-\bibN">}}%
+}
+>>>
+
+We use BibLaTeX's formatting commands to add JATS elements around some bibliographic
+fields.
+
+\<biblatex fields\><<<
+\DeclareFieldFormat{title}{\HCode{<source>}#1\HCode{</source>}}
+\DeclareFieldFormat{booktitle}{\HCode{<source>}#1\HCode{</source>}}
+\DeclareFieldFormat{maintitle}{\HCode{<source>}#1\HCode{</source>}}
+\DeclareFieldFormat{journaltitle}{\HCode{<source>}#1\HCode{</source>}}
+\DeclareFieldFormat[article]{title}{\HCode{<article-title>}#1\HCode{</article-title>}}
+\DeclareFieldFormat[incollection]{title}{\HCode{<part-title>}#1\HCode{</part-title>}}
+\DeclareFieldFormat[inbook]{title}{\HCode{<part-title>}#1\HCode{</part-title>}}
+\DeclareFieldFormat{year}{\HCode{<year>}#1\HCode{</year>}}
+\DeclareFieldFormat{date}{\HCode{<date-in-citation content-type="published">}#1\HCode{</date-in-citation>}}
+\DeclareFieldFormat{pages}{\HCode{<page-range>}#1\HCode{</page-range>}}
+\DeclareListFormat{publisher}{\usebibmacro{list:delim}{#1}\HCode{<publisher-name>}#1\HCode{</publisher-name>}\isdot\usebibmacro{list:andothers}}
+\DeclareListFormat{location}{\usebibmacro{list:delim}{#1}\HCode{<publisher-loc>}#1\HCode{</publisher-loc>}\isdot\usebibmacro{list:andothers}}
+\DeclareNameFormat{author}{%
+ \nameparts{#1}% This command initializes commands used in the following bibmacro
+ \HCode{<string-name>}% use
+ \usebibmacro{name:family-given}%
+ {\namepartfamily}%
+ {\namepartgiveni}%
+ {\namepartprefix}%
+ {\namepartsuffix}%
+ \HCode{</string-name>}%
+ \usebibmacro{name:andothers}%
+}
+>>>
+
\endinput
diff --git a/support/TeX4ht/source/tex4ht-mathml.tex b/support/TeX4ht/source/tex4ht-mathml.tex
index 74132b6ac0..68ed7dfddc 100644
--- a/support/TeX4ht/source/tex4ht-mathml.tex
+++ b/support/TeX4ht/source/tex4ht-mathml.tex
@@ -1,4 +1,4 @@
-% $Id: tex4ht-mathml.tex 1463 2024-02-19 13:33:57Z michal_h21 $$
+% $Id: tex4ht-mathml.tex 1464 2024-02-21 09:46:01Z michal_h21 $$
% compile 3 times: latex tex4ht-mathltx
% or xhlatex tex4ht-mathltx "html,3,sections+"
%
@@ -5518,23 +5518,26 @@ with small shifting.
\Configure{mhchemcf}{\HCode{<\:mhmathmlorhtml{mrow}{span}\space class="mhchem-cf">}}{\HCode{</\:mhmathmlorhtml{mrow}{span}>}}
\Configure{mhchemce}{\HCode{<\:mhmathmlorhtml{mrow}{span}\space class="mhchem-ce">}}{\HCode{</\:mhmathmlorhtml{mrow}{span}>}}
+% we configure subscripts and superscripts to have empty bases. it is because if superscript followed subscript, we got wrong
+% MathML markup, with mismatched tags. For example: \ce{CrO4^2-}
\Configure{mhchemsub}{%
\:mhmathmlorhtml{%
- \Send{BACK}%
- {<\a:mathml msub><\a:mathml mrow\Hnewline>}%
- \Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base%
+ \HCode{<\a:mathml msub><mrow></mrow><\a:mathml mrow>}%
}{%
\HCode{<sub>}}%
-}{\:mhmathmlorhtml{\Tg</\a:mathml mrow>\TG</\a:mathml msub\Hnewline>}{\HCode{</sub>}}}
+}{\:mhmathmlorhtml{\Tg</\a:mathml mrow>\TG</\a:mathml msub>}{\HCode{</sub>}}}
\Configure{mhchemsup}{%
\:mhmathmlorhtml{
- \Send{BACK}
- {<\a:mathml msup><\a:mathml mrow\Hnewline>}%
- \Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base
+ \HCode{<\a:mathml msup><mrow></mrow><\a:mathml mrow>}%
}{%
\HCode{<sup>}}%
}{\:mhmathmlorhtml{\Tg</\a:mathml mrow>\TG</\a:mathml msup\Hnewline>}{\HCode{</sup>}}}
+
+\Configure{mhchemsupsub}{\setbox0=\hbox\bgroup}{\egroup\setbox1=\hbox\bgroup}{\egroup\HCode{<\a:mathml msubsup><\a:mathml mrow></\a:mathml mrow><\a:mathml mrow>}\box1\HCode{</\a:mathml mrow><\a:mathml mrow>}\box0\HCode{</\a:mathml mrow></\a:mathml msubsup>}}
+\Configure{mhchemisotope}{\setbox0=\hbox\bgroup}{\egroup\setbox1=\hbox\bgroup}{\egroup\HCode{<\a:mathml msubsup><\a:mathml mrow></\a:mathml mrow><\a:mathml mrow>}\box1\HCode{</\a:mathml mrow><\a:mathml mrow>}\box0\HCode{</\a:mathml mrow></\a:mathml msubsup>}}
+
+
% mhchemoperator is always used inside \HCode, so we need not to use \HCode in it's configuration
\Configure{mhchemoperator}{<\:mhmathmlorhtml{mo}{span} class="mhchem-operator">}{</\:mhmathmlorhtml{mo}{span}>}
diff --git a/support/make4ht/README b/support/make4ht/README
index 0675e1d0ce..561d6bd14d 100644
--- a/support/make4ht/README
+++ b/support/make4ht/README
@@ -34,6 +34,7 @@ It will produce a file named `filename.html` if the compilation goes without fat
possible values: tex4ht or lua4ht
-c,--config (default xhtml) Custom config file
-d,--output-dir (default "") Output directory
+ -B,--build-dir (default nil) Build directory
-e,--build-file (default nil) If the build filename is different
than `filename`.mk4
-f,--format (default nil) Output file format
@@ -207,6 +208,12 @@ should copy all output files to the correct destinations.
$ make4ht -d outputdir filename.tex
+`make4ht` can also output temporary files to a build directory, thanks to the `--build-dir` (or `-B`)
+option. The following command with put `.aux`, `.4tc` and other auxiliary files to the
+`build` dir, and the generated `.html` and `.css` files to the `outputdir` directory.
+
+ $ make4ht -B build -d outputdir filename.tex
+
## Image conversion and postprocessing of the generated files
\TeX4ht\ can convert parts of the document to images. This is useful
@@ -248,7 +255,13 @@ may post-process the output files or request additional commands for the compila
The extensions can be enabled or disabled by appending `+EXTENSION` or `-EXTENSION` after
the output format name:
- $ make4ht -uf html5+tidy filename.tex
+ $ make4ht -f html5+tidy filename.tex
+
+In `xhtml` and `html5` output formats, the `common_domfilters` extension is triggered automatically, but
+it can still be disabled using:
+
+ $ make4ht -f html5-common_domfilters filename.tex
+
Available extensions:
@@ -260,8 +273,14 @@ common\_filters
common\_domfilters
: clean the HTML file using DOM filters. It is more powerful than
-`common_filters`. Used DOM filters are `fixinlines`, `idcolons`,
-`joincharacters`, `sectionid` and `tablerows`.
+ `common_filters`. It used following DOM filters: `fixinlines`, `idcolons`,
+ `joincharacters`, `mathmlfixes`, `tablerows`,`booktabs`, `sectionid`
+ and`itemparagraphs`
+
+copy\_images
+
+: Copies the images to the output directory. This is useful if the original
+ images are stored in directories above the document directory.
detect\_engine
@@ -1015,6 +1034,24 @@ Default values:
}
}
+## The `copy_images` extension
+
+extensions
+
+: table with list of image extensions that should be processed.
+
+
+img\_dir
+
+: name of the output directory where images should be stored
+
+Default values:
+
+ filter_settings "copy_images" {
+ extensions = {"png", "jpg", "jpeg", "svg"},
+ img_dir = ""
+ }
+
## The `fixinlines` dom filter
inline\_elements
diff --git a/support/make4ht/changelog.tex b/support/make4ht/changelog.tex
index 4516805f3a..e17af6d5db 100644
--- a/support/make4ht/changelog.tex
+++ b/support/make4ht/changelog.tex
@@ -3,6 +3,217 @@
\begin{itemize}
\item
+ 2024/02/22
+
+ \begin{itemize}
+ \tightlist
+ \item
+ version \texttt{0.4} released
+ \item
+ fixed name of the \texttt{\textless{}title-group\textgreater{}}
+ element in JATS output.
+ \end{itemize}
+\item
+ 2024/02/21
+
+ \begin{itemize}
+ \tightlist
+ \item
+ add standalone minus sign to the
+ \texttt{\textless{}mn\textgreater{}} element in MathML.
+ \end{itemize}
+\item
+ 2024/01/26
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed passing of the params table in the \texttt{staticsite}
+ extension.
+ \end{itemize}
+\item
+ 2024/01/22
+
+ \begin{itemize}
+ \tightlist
+ \item
+ don't enable parsing of void elements in DOM filter with XML output
+ formats.
+ \end{itemize}
+\item
+ 2023/12/15
+
+ \begin{itemize}
+ \tightlist
+ \item
+ call \texttt{fix\_rel\_mo} MathML fix only in the ODT output.
+ \end{itemize}
+\item
+ 2023/12/11
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed handling of the \texttt{-\/-build-dir} argument in
+ \texttt{dvisvgm\_hashes} extension.
+ \end{itemize}
+\item
+ 2023/11/03
+
+ \begin{itemize}
+ \tightlist
+ \item
+ remove leading dashes in ids created by the \texttt{sectionid} DOM
+ filter.
+ \end{itemize}
+\item
+ 2023/10/26
+
+ \begin{itemize}
+ \tightlist
+ \item
+ check that removed elements in the \texttt{sectionid} DOM filter are
+ \texttt{\textless{}a\textgreater{}} elements.
+ \end{itemize}
+\item
+ 2023/10/25
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed addition of named IDs to figures.
+ \end{itemize}
+\item
+ 2023/10/19
+
+ \begin{itemize}
+ \tightlist
+ \item
+ print info about packages with no corresponding \texttt{.4ht} file.
+ \end{itemize}
+\item
+ 2023/10/05
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added fix for LibreOffice's bug regarding relation type math
+ operators.
+ \end{itemize}
+\item
+ 2023/10/03
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed most features that didn't work with the \texttt{-\/-build-dir}
+ argument.
+ \end{itemize}
+\item
+ 2023/10/02
+
+ \begin{itemize}
+ \tightlist
+ \item
+ working on new command line argument \texttt{-\/-build-dir}. It
+ should allow moving of temporary files to a temporary directory. The
+ idea and most of the code comes from Robin Seth Ekman.
+ \end{itemize}
+\item
+ 2023/09/07
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fix spacing for the \texttt{dcases*} environment in the
+ \texttt{mathml\_fixes} DOM filter.
+ \end{itemize}
+\item
+ 2023/08/24
+
+ \begin{itemize}
+ \tightlist
+ \item
+ support non-numerical values in index entry destinations (for
+ example roman numerals).
+ \end{itemize}
+\item
+ 2023/08/22
+
+ \begin{itemize}
+ \tightlist
+ \item
+ updated list of DOM filters used by the \texttt{common\_domfilters}
+ extension, and documented that it is used automatically in the HTML
+ output.
+ \end{itemize}
+\item
+ 2023/08/12
+
+ \begin{itemize}
+ \tightlist
+ \item
+ remove unnecessary \texttt{\textless{}a\textgreater{}} elements with
+ \texttt{id} attributes and set the \texttt{id} on the parent.
+ \end{itemize}
+\item
+ 2023/07/06
+
+ \begin{itemize}
+ \tightlist
+ \item
+ add prefix to section IDs if the section name is empty.
+ \end{itemize}
+\item
+ 2023/06/20
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added the \texttt{copy\_images} extension.
+ \end{itemize}
+\item
+ 2023/06/14
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed bug in the \texttt{mathmlfixes} DOM filter -- non-empty last
+ rows were removed if they contained only one element.
+ \end{itemize}
+\item
+ 2023/05/26
+
+ \begin{itemize}
+ \tightlist
+ \item
+ load \texttt{tex4ht.sty} before input file processing starts.
+ \end{itemize}
+\item
+ 2023/04/19
+
+ \begin{itemize}
+ \tightlist
+ \item
+ handle additional characters in the \texttt{idcolons} DOM filter.
+ \end{itemize}
+\item
+ 2023/04/06
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed handling of ID attributes in the \texttt{idcolons} DOM filter.
+ \end{itemize}
+\item
+ 2023/03/07
+
+ \begin{itemize}
+ \tightlist
+ \item
+ remove empty rows in \texttt{longtable}.
+ \end{itemize}
+\item
2023/02/24
\begin{itemize}
diff --git a/support/make4ht/domfilters/make4ht-collapsetoc.lua b/support/make4ht/domfilters/make4ht-collapsetoc.lua
index ede6e1f908..1c7011c1b7 100644
--- a/support/make4ht/domfilters/make4ht-collapsetoc.lua
+++ b/support/make4ht/domfilters/make4ht-collapsetoc.lua
@@ -168,7 +168,7 @@ end
-- process the .4tc file and convert entries to a tree structure
-- based on the sectioning level
local function parse_4tc(parameters, toc_levels)
- local tcfilename = parameters.input .. ".4tc"
+ local tcfilename = mkutils.file_in_builddir(parameters.input .. ".4tc", parameters)
if not mkutils.file_exists(tcfilename) then
log:warning("Cannot find TOC: " .. tcfilename)
return {}
diff --git a/support/make4ht/domfilters/make4ht-idcolons.lua b/support/make4ht/domfilters/make4ht-idcolons.lua
index ccdafbd6d4..589c515ef9 100644
--- a/support/make4ht/domfilters/make4ht-idcolons.lua
+++ b/support/make4ht/domfilters/make4ht-idcolons.lua
@@ -1,18 +1,36 @@
+local allowed_chars = {
+ ["-"] = true,
+ ["."] = true
+}
+local function fix_colons(id)
+ -- match every non alphanum character
+ return id:gsub("[%W]", function(s)
+ -- some characters are allowed, we don't need to replace them
+ if allowed_chars[s] then return s end
+ -- in other cases, replace with underscore
+ return "_"
+ end)
+end
+
local function id_colons(obj)
- -- replace : characters in links and ids with unserscores
+ -- replace non-valid characters in links and ids with underscores
obj:traverse_elements(function(el)
local name = string.lower(obj:get_element_name(el))
if name == "a" then
- local href = obj:get_attribute(el, "href")
+ local href = el:get_attribute("href")
+ -- don't replace colons in external links
if href and not href:match("[a-z]%://") then
- obj:set_attribute(el, "href", href:gsub(":", "_"))
+ local base, id = href:match("(.*)%#(.*)")
+ if base and id then
+ id = fix_colons(id)
+ el:set_attribute("href", base .. "#" .. id)
+ end
end
end
- local id = obj:get_attribute( el , "id")
+ local id = el:get_attribute("id")
if id then
- obj:set_attribute(el, "id", id:gsub(":", "_"))
+ el:set_attribute("id", fix_colons(id))
end
- -- local id = obj:get_attribute(el, "id")
end)
return obj
end
diff --git a/support/make4ht/domfilters/make4ht-inlinecss.lua b/support/make4ht/domfilters/make4ht-inlinecss.lua
index b086a2fc42..3240df275c 100644
--- a/support/make4ht/domfilters/make4ht-inlinecss.lua
+++ b/support/make4ht/domfilters/make4ht-inlinecss.lua
@@ -58,7 +58,7 @@ return function(dom, par)
if not processed then
-- process the CSS file before everything else, but only once
processed = true
- local css_file = par.input .. ".css"
+ local css_file = mkutils.file_in_builddir(par.input .. ".css", par)
local status, msg = parse_css(css_file)
if not status then log:warning(msg) end
end
diff --git a/support/make4ht/domfilters/make4ht-mathmlfixes.lua b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
index 7fa74f4632..fe8384619a 100644
--- a/support/make4ht/domfilters/make4ht-mathmlfixes.lua
+++ b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
@@ -35,10 +35,39 @@ local function update_element_name(el, name, prefix)
el._name = newname
end
-local function create_element(el, name, prefix)
- return el:create_element(newname)
+local function create_element(el, name, prefix, attributes)
+ local attributes = attributes or {}
+ local newname = get_new_element_name(name, prefix)
+ return el:create_element(newname, attributes)
end
+local function element_pos(el)
+ local pos, count = 0, 0
+ for _, node in ipairs(el:get_siblings()) do
+ if node:is_element() then
+ count = count + 1
+ if node == el then
+ pos = count
+ end
+ end
+ end
+ return pos, count
+end
+
+-- test if element is the first element in the current element list
+local function is_first_element(el)
+ local pos, count = element_pos(el)
+ return pos == 1
+end
+
+-- test if element is the last element in the current element list
+local function is_last_element(el)
+ local pos, count = element_pos(el)
+ return pos == count
+end
+
+
+
local function is_token_element(el)
local name, prefix = get_element_name(el)
return token_elements[name], prefix
@@ -275,6 +304,14 @@ end
local function fix_numbers(el)
-- convert <mn>1</mn><mo>.</mo><mn>3</mn> to <mn>1.3</mn>
if get_element_name(el) == "mn" then
+ -- sometimes minus sign can be outside <mn>
+ local x = el:get_sibling_node(-1)
+ if x and x:is_text()
+ and x:get_text() == "−"
+ then
+ el:add_child_node(x:copy_node(), 1)
+ x:remove_node()
+ end
local n = el:get_sibling_node(1)
-- test if next element is <mo class="MathClass-punc">.</mo>
if n and n:is_element()
@@ -357,18 +394,45 @@ local function fix_operators(x)
end
end
-local function is_last_element(el)
- local siblings = el:get_siblings()
- -- return true only if the current element is the last in the parent's children
- for i = #siblings, 1, -1 do
- local curr = siblings[i]
- if curr == el then
- return true
- elseif curr:is_element() then
- return false
- end
- end
- return false
+local function get_third_parent(el)
+ local first = el:get_parent()
+ if not first then return nil end
+ local second = first:get_parent()
+ if not second then return nil end
+ return second:get_parent()
+end
+
+local function add_space(el, pos)
+ local parent = el:get_parent()
+ local name, prefix = get_element_name(el)
+ local space = create_element(parent, "mspace", prefix)
+ space:set_attribute("width", "0.3em")
+ parent:add_child_node(space, pos)
+end
+
+local function fix_dcases(el)
+ -- we need to fix spacing in dcases* environments
+ -- when you use something like:
+ -- \begin{dcases*}
+ -- 1 & if $a=b$ then
+ -- \end{dcases*}
+ -- the spaces around $a=b$ will be missing
+ -- we detect if the <mtext> elements contains spaces that are collapsed by the browser, and add explicit <mspace>
+ -- elements when necessary
+ if el:get_element_name() == "mtext" then
+ local parent = get_third_parent(el)
+ if parent and parent:get_element_name() == "mtable" and parent:get_attribute("class") == "dcases-star" then
+ local text = el:get_text()
+ local pos = el:find_element_pos()
+ if pos == 1 and text:match("%s$") then
+ add_space(el, 2)
+ elseif text:match("^%s") and not el._used then
+ add_space(el, pos)
+ -- this is necessary to avoid infinite loop, we mark this element as processed
+ el._used = true
+ end
+ end
+ end
end
local function is_empty_row(el)
@@ -378,6 +442,9 @@ local function is_empty_row(el)
for _, child in ipairs(el:get_children()) do
if child:is_element() then count = count + 1 end
end
+ else
+ -- row is not empty if it contains any text
+ return false
end
-- if there is one or zero childrens, then it is empty row
return count < 2
@@ -398,6 +465,29 @@ local function delete_last_empty_mtr(el)
end
+local function fix_rel_mo(el)
+ -- this is necessary for LibreOffice. It has a problem with relative <mo> that are
+ -- first childs in an element list. This often happens in equations, where first
+ -- element in a table column is an operator, like non-equal-, less-than etc.
+ local el_name, prefix = get_element_name(el)
+ if el_name == "mo"
+ and not get_attribute(el, "fence") -- ignore fences
+ and not get_attribute(el, "form") -- these should be also ignored
+ and not get_attribute(el, "accent") -- and accents too
+ then
+ local parent = el:get_parent()
+ if is_first_element(el) then
+ local mrow = create_element(parent, "mrow", prefix)
+ parent:add_child_node(mrow, 1)
+ elseif is_last_element(el) then
+ local mrow = create_element(parent, "mrow", prefix)
+ parent:add_child_node(mrow)
+ end
+ end
+
+end
+
+
return function(dom)
dom:traverse_elements(function(el)
if settings.output_format ~= "odt" then
@@ -405,6 +495,7 @@ return function(dom)
fix_mfenced(el)
else
fix_mo_to_mfenced(el)
+ fix_rel_mo(el)
end
fix_radicals(el)
fix_token_elements(el)
@@ -413,6 +504,7 @@ return function(dom)
fix_numbers(el)
fix_operators(el)
fix_mathvariant(el)
+ fix_dcases(el)
top_mrow(el)
delete_last_empty_mtr(el)
end)
diff --git a/support/make4ht/domfilters/make4ht-sectionid.lua b/support/make4ht/domfilters/make4ht-sectionid.lua
index 4a1f522e6e..c8e9892bb1 100644
--- a/support/make4ht/domfilters/make4ht-sectionid.lua
+++ b/support/make4ht/domfilters/make4ht-sectionid.lua
@@ -58,7 +58,9 @@ local escape_name = function(name)
--- convert table with normalized characters to string
local name = table.concat(result)
-- remove spaces
- return name:gsub("%s+", "-")
+ name = name:gsub("%s+", "-")
+ name = name:gsub("^%-", "")
+ return name
end
local function parse_toc_line(line)
@@ -78,6 +80,9 @@ local function parse_toc(filename)
if not mkutils.file_exists(filename) then return nil, "Cannot open TOC file " .. filename end
for line in io.lines(filename) do
local id, name = parse_toc_line(line)
+ -- if section name doesn't contain any text, it would lead to id which contains only number
+ -- this is invalid in HTML
+ if name == "" then name = "_" end
local orig_name = name
-- not all lines in the .4tc file contains TOC entries
if id then
@@ -109,10 +114,20 @@ local function set_id(el, id)
end
+-- we want to remove <a id="xxx"> elements from some elements, most notably <figure>
+local elements_to_remove = {
+ figure = true,
+ figcaption
+}
+
+local function remove_a(el, parent, id)
+ parent:set_attribute("id", id)
+ el:remove_node()
+end
return function(dom, par)
local msg
- toc, msg = toc or parse_toc(par.input .. ".4tc")
+ toc, msg = toc or parse_toc(mkutils.file_in_builddir(par.input .. ".4tc", par))
msg = msg or "Cannot load TOC"
-- don't do anyting if toc cannot be found
if not toc then
@@ -135,8 +150,16 @@ return function(dom, par)
local id, href = el:get_attribute("id"), el:get_attribute("href")
if id then
local name = toc[id]
+ local parent = el:get_parent()
+ -- remove unnecessary <a> elements if the parent doesn't have id yet
+ if elements_to_remove[parent:get_element_name()]
+ and not parent:get_attribute("id")
+ and el:get_element_name() == "a"
+ then
+ remove_a(el, parent, id)
+ set_id(el, name)
-- replace id with new section id
- if name and not toc_ids[name] then
+ elseif name and not toc_ids[name] then
set_id(el, name)
else
if name then
diff --git a/support/make4ht/domfilters/make4ht-tablerows.lua b/support/make4ht/domfilters/make4ht-tablerows.lua
index ef36a85750..11dbfcaa71 100644
--- a/support/make4ht/domfilters/make4ht-tablerows.lua
+++ b/support/make4ht/domfilters/make4ht-tablerows.lua
@@ -4,11 +4,17 @@ return function(dom)
-- detect if the element contains child elements
local child_elements = 0
local children = child:get_children()
- for _, el in ipairs(children) do
+ local last_child_pos
+ for pos, el in ipairs(children) do
+ last_child_pos = pos
local step = el:is_element() and 1 or 0
-- log:info("element name", el._name)
child_elements = child_elements + step
end
+ -- longtable has <td><p></p></td> inside empty rows, we regard them as empty
+ if child_elements == 1 and children[last_child_pos]:get_element_name() == "p" and child:get_text():gsub("%s", "") == "" then
+ child_elements = 0
+ end
return child_elements > 0
end
local is_empty_row = function(row)
diff --git a/support/make4ht/extensions/make4ht-ext-copy_images.lua b/support/make4ht/extensions/make4ht-ext-copy_images.lua
new file mode 100644
index 0000000000..7b927c7d9f
--- /dev/null
+++ b/support/make4ht/extensions/make4ht-ext-copy_images.lua
@@ -0,0 +1,68 @@
+local M = {}
+local mkutils = require "mkutils"
+local domfilter = require "make4ht-domfilter"
+
+local copied_images = {}
+
+local function image_copy(path, parameters, img_dir)
+ if mkutils.is_url(path) then return nil, "External image" end
+ -- get image basename
+ local basename = path:match("([^/]+)$")
+ -- if outdir is empty, keep it empty, otherwise add / separator
+ local outdir = parameters.outdir == "" and "" or parameters.outdir .. "/"
+ if img_dir ~= "" then
+ outdir = outdir .. img_dir .. "/"
+ end
+ -- handle trailing //
+ outdir = outdir:gsub("%/+","/")
+ local output_file = outdir .. basename
+ if outdir == "" then
+ mkutils.cp(path, output_file)
+ else
+ mkutils.copy(path, output_file)
+ end
+end
+
+-- filters support only html formats
+function M.test(format)
+ current_format = format
+ if format == "odt" then return false end
+ return true
+end
+
+function M.modify_build(make)
+ local ext_settings = get_filter_settings "copy_images" or {}
+ local img_dir = ext_settings.img_dir or ""
+ local img_extensions = ext_settings.extensions or {"jpg", "png", "jpeg", "svg"}
+ local process = domfilter({
+ function(dom, par)
+ for _, img in ipairs(dom:query_selector("img")) do
+ local src = img:get_attribute("src")
+ if src and not mkutils.is_url(src) then
+ -- remove path specification
+ src = src:match("([^/]+)$")
+ if img_dir ~= "" then
+ src = img_dir .. "/" .. src
+ src = src:gsub("%/+", "/")
+ end
+ img:set_attribute("src", src)
+ end
+ end
+ return dom
+ end
+ }, "copy_images")
+
+ -- add matcher for all image extensions
+ for _, ext in ipairs(img_extensions) do
+ make:match(ext .. "$", function(path, parameters)
+ image_copy(path, parameters, img_dir)
+ -- prevent further processing of the image
+ return false
+ end)
+ end
+
+ make:match("html$", process, {img_dir = img_dir})
+ return make
+end
+
+return M
diff --git a/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua b/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
index 53da32c3be..94183c7dbf 100644
--- a/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
+++ b/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
@@ -177,7 +177,7 @@ local function get_dvi_pages(arg)
f:close()
local dvi_pages = dvireader.get_pages(content)
-- we must find page numbers and output name sfor the generated images
- local lg = mkutils.parse_lg(arg.input ..".lg")
+ local lg = mkutils.parse_lg(arg.input ..".lg", arg.builddir)
for _, name in ipairs(lg.images) do
local page = tonumber(name.page)
local hash = dvi_pages[page]
diff --git a/support/make4ht/extensions/make4ht-ext-latexmk_build.lua b/support/make4ht/extensions/make4ht-ext-latexmk_build.lua
index b9ed94b0dc..b93f458d62 100644
--- a/support/make4ht/extensions/make4ht-ext-latexmk_build.lua
+++ b/support/make4ht/extensions/make4ht-ext-latexmk_build.lua
@@ -16,7 +16,7 @@ function M.modify_build(make)
-- tex4ht command overwrites content that was set by LaTeX with it's own stuff
local tmp_file
make:add("save_tmp", function(par)
- local f = io.open(par.input .. ".tmp", "r")
+ local f = io.open(mkutils.file_in_builddir(par.input .. ".tmp", par), "r")
if f then
tmp_file = f:read("*all")
f:close()
@@ -25,7 +25,7 @@ function M.modify_build(make)
end)
make:add("load_tmp", function(par)
if tmp_file then
- local f = io.open(par.input .. ".tmp", "w")
+ local f = io.open(mkutils.file_in_builddir(par.input .. ".tmp", par), "w")
if f then
f:write(tmp_file)
end
diff --git a/support/make4ht/extensions/make4ht-ext-staticsite.lua b/support/make4ht/extensions/make4ht-ext-staticsite.lua
index b9272203a5..dd293b6a23 100644
--- a/support/make4ht/extensions/make4ht-ext-staticsite.lua
+++ b/support/make4ht/extensions/make4ht-ext-staticsite.lua
@@ -67,7 +67,7 @@ local function insert_filter(make, pattern, fn)
local insert_executed = false
table.insert(make.matches, 1, {
pattern=pattern,
- params = {},
+ params = make.params or {},
command = function()
if not insert_executed then
fn()
@@ -96,12 +96,17 @@ end
local function copy_files(filename, par)
local function prepare_path(dir, subdir)
- local path = dir .. "/" .. subdir .. "/" .. filename
+ local f = filename
+ if par.builddir then
+ f = f:gsub("^" .. par.builddir .. "/", "")
+ end
+ local path = dir .. "/" .. subdir .. "/" .. f
return path:gsub("//", "/")
end
-- get extension settings
local site_settings = get_filter_settings "staticsite"
- local site_root = site_settings.site_root or "./"
+ local site_root = site_settings.site_root or par.outdir
+ if site_root == "" then site_root = "./" end
local map = site_settings.map or {}
-- default path without subdir, will be used if the file is not matched
-- by any pattern in the map
@@ -150,8 +155,10 @@ function M.modify_build(make)
-- match.params.outdir = outdir
-- print(match.pattern, match.params.outdir)
-- end
- make:match("html?$", process)
- make:match(".*", copy_files, {slug=slug})
+ local params = make.params
+ params.slug = slug
+ make:match("html?$", process, params)
+ make:match(".*", copy_files, params)
end)
return make
diff --git a/support/make4ht/filters/make4ht-domfilter.lua b/support/make4ht/filters/make4ht-domfilter.lua
index f6df769d60..68dd5a488c 100644
--- a/support/make4ht/filters/make4ht-domfilter.lua
+++ b/support/make4ht/filters/make4ht-domfilter.lua
@@ -37,10 +37,13 @@ local function filter(filters, name)
end
local input = filter_lib.load_input_file(filename)
if not input then return nil, "Cannot load the input file" end
+ -- in pure XML, we need to ignore void_elements provided by LuaXML, because these can exist only in HTML
+ local no_void_elements = {docbook = {}, jats = {}, odt = {}, tei = {} }
+ local void_elements = no_void_elements[parameters.output_format]
-- we need to use pcall, because XML error would break the whole build process
-- domobject will be error object if DOM parsing failed
local status, domobject = pcall(function()
- return dom.parse(input)
+ return dom.parse(input, void_elements)
end)
if not status then
log:warning("DOM parsing of " .. filename .. " failed:")
diff --git a/support/make4ht/formats/make4ht-jats.lua b/support/make4ht/formats/make4ht-jats.lua
index 41eabf8744..09b9bbbd8e 100644
--- a/support/make4ht/formats/make4ht-jats.lua
+++ b/support/make4ht/formats/make4ht-jats.lua
@@ -32,8 +32,8 @@ end
local function process_moves()
if article_meta then
if elements_to_move_to_title["article-title"]
- and #article_meta:query_selector("title_group") == 0 then -- don't move anything if user added title_group from a config file
- local title_group = article_meta:create_element("title_group")
+ and #article_meta:query_selector("title-group") == 0 then -- don't move anything if user added title-group from a config file
+ local title_group = article_meta:create_element("title-group")
for _, name in ipairs{ "article-title", "subtitle" } do
local v = elements_to_move_to_title[name]
if v then
@@ -41,7 +41,7 @@ local function process_moves()
v:remove_node()
end
end
- article_meta:add_child_node(title_group)
+ article_meta:add_child_node(title_group, 1)
end
if #elements_to_move_to_contribs > 0 then
local contrib_group = article_meta:create_element("contrib-group")
diff --git a/support/make4ht/formats/make4ht-odt.lua b/support/make4ht/formats/make4ht-odt.lua
index 7511ed481d..3479613c9d 100644
--- a/support/make4ht/formats/make4ht-odt.lua
+++ b/support/make4ht/formats/make4ht-odt.lua
@@ -169,7 +169,7 @@ local lg_fonts_processed=false
local patched_lg_fonts = {}
local function fix_lgfile_fonts(ignored_name, params)
-- this function is called from file match. we must use the name of the .lg file
- local filename = params.input .. ".lg"
+ local filename = mkutils.file_in_builddir(params.input .. ".lg", params)
if not lg_fonts_processed then
local lines = {}
-- default font_size
@@ -209,7 +209,8 @@ end
local move_matches = xtpipeslib.move_matches
local function insert_lgfile_fonts(make)
- local first_file = make.params.input .. ".4oo"
+ local params = make.params
+ local first_file = mkutils.file_in_builddir(params.input .. ".4oo", params)
-- find the last file and escape it so it can be used
-- in filename match
make:match(first_file, fix_lgfile_fonts)
@@ -310,7 +311,8 @@ function M.modify_build(make)
-- odt packing will be done here
make:match(lastfile, function(filename, par)
local groups = prepare_output_files(make.lgfile.files)
- local basename = groups.odt[1]
+ -- we must remove any path from the basename
+ local basename = groups.odt[1]:match("([^/]+)$")
local odtname = basename .. ".odt"
local odt,msg = Odtfile.new(odtname)
if not odt then
diff --git a/support/make4ht/make4ht b/support/make4ht/make4ht
index f635895677..73a1978e5a 100755
--- a/support/make4ht/make4ht
+++ b/support/make4ht/make4ht
@@ -29,7 +29,7 @@ make4ht [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"]
-- set version number. the template should be replaced by the
-- actual version number by the build script
-local version = "v0.3m"
+local version = "v0.4"
mkparams.version_number = version
local args = mkparams.get_args()
@@ -39,6 +39,11 @@ local parameters = mkparams.process_args(args)
log:status("Conversion started")
log:status("Input file: " .. parameters.tex_file)
+
+if parameters.builddir and parameters.builddir ~= "" then
+ mkutils.make_path(parameters.builddir)
+end
+
local mode = parameters.mode
local build_file = parameters.build_file
@@ -127,9 +132,10 @@ make:match(".*",function(filename,par)
log:info("No output directory")
return true
end
- log:info("outdir: "..outdir)
- local outfilename = outdir .. filename
- mkutils.copy(filename,outfilename)
+ log:info("outdir: "..outdir)
+ local outfilename = filename:gsub("^" .. (par.builddir or ""), "")
+ outfilename = outdir .. outfilename
+ mkutils.copy(filename,outfilename)
return true
end)
diff --git a/support/make4ht/make4ht-doc.pdf b/support/make4ht/make4ht-doc.pdf
index 207f7135a8..7eacc7bd95 100644
--- a/support/make4ht/make4ht-doc.pdf
+++ b/support/make4ht/make4ht-doc.pdf
Binary files differ
diff --git a/support/make4ht/make4ht-errorlogparser.lua b/support/make4ht/make4ht-errorlogparser.lua
index e536370ac9..1d16c97650 100644
--- a/support/make4ht/make4ht-errorlogparser.lua
+++ b/support/make4ht/make4ht-errorlogparser.lua
@@ -81,6 +81,28 @@ local function get_errors(chunks, errors)
return errors
end
+function m.get_missing_4ht_files(log)
+ local used_files = {}
+ local used_4ht_files = {}
+ local missing_4ht_files = {}
+ local pkg_names = {sty=true, cls=true}
+ for filename, ext in log:gmatch("[^%s]-([^%/^%\\^%.%s]+)%.([%w][%w]+)") do
+ -- break ak
+ if ext == "aux" then break end
+ if pkg_names[ext] then
+ used_files[filename .. "." .. ext] = true
+ elseif ext == "4ht" then
+ used_4ht_files[filename] = true
+ end
+ end
+ for filename, _ in pairs(used_files) do
+ if not used_4ht_files[mkutils.remove_extension(filename)] then
+ table.insert(missing_4ht_files, filename)
+ end
+ end
+ return missing_4ht_files
+end
+
function m.parse(log)
local chunks, newtext = get_chunks(log)
diff --git a/support/make4ht/make4ht-htlatex.lua b/support/make4ht/make4ht-htlatex.lua
index 033b25b632..4975e947e6 100644
--- a/support/make4ht/make4ht-htlatex.lua
+++ b/support/make4ht/make4ht-htlatex.lua
@@ -5,7 +5,7 @@ local error_logparser = require("make4ht-errorlogparser")
local Make = Make or {}
-- this function reads the LaTeX log file and tries to detect fatal errors in the compilation
local function testlogfile(par)
- local logfile = par.input .. ".log"
+ local logfile = mkutils.file_in_builddir(par.input .. ".log", par)
local f = io.open(logfile,"r")
if not f then
log:warning("Make4ht: cannot open log file "..logfile)
@@ -29,6 +29,9 @@ local function testlogfile(par)
end
end
end
+ -- info about packages with no corresponding .4ht files
+ local missing_4ht = error_logparser.get_missing_4ht_files(content)
+ for _, filename in ipairs(missing_4ht) do log:info("Unsupported file: " .. filename) end
-- test for fatal errors
if text:match("No pages of output") or text:match("TeX capacity exceeded, sorry") or text:match("That makes 100 errors") or text:match("Emergency stop") then return 1 end
return 0
@@ -40,18 +43,17 @@ Make.testlogfile = testlogfile
--env.Make:add("htlatex", "${htlatex} ${latex_par} '\\\makeatletter\\def\\HCode{\\futurelet\\HCode\\HChar}\\def\\HChar{\\ifx\"\\HCode\\def\\HCode\"##1\"{\\Link##1}\\expandafter\\HCode\\else\\expandafter\\Link\\fi}\\def\\Link#1.a.b.c.{\\g@addto@macro\\@documentclasshook{\\RequirePackage[#1,html]{tex4ht}\\let\\HCode\\documentstyle\\def\\documentstyle{\\let\\documentstyle\\HCode\\expandafter\\def\\csname tex4ht\\endcsname{#1,html}\\def\\HCode####1{\\documentstyle[tex4ht,}\\@ifnextchar[{\\HCode}{\\documentstyle[tex4ht]}}}\\makeatother\\HCode '${config}${tex4ht_sty_par}'.a.b.c.\\input ' ${input}")
-- template for calling LaTeX with tex4ht loaded
-Make.latex_command = "${htlatex} --interaction=${interaction} ${latex_par} '\\makeatletter"..
+Make.latex_command = "${htlatex} --interaction=${interaction} ${build_dir_arg} ${latex_par} '\\makeatletter"..
"\\def\\HCode{\\futurelet\\HCode\\HChar}\\def\\HChar{\\ifx\"\\HCode"..
"\\def\\HCode\"##1\"{\\Link##1}\\expandafter\\HCode\\else"..
-"\\expandafter\\Link\\fi}\\def\\Link#1.a.b.c.{\\AddToHook"..
-"{class/before}{\\RequirePackage[#1,html]{tex4ht}${packages}}"..
+"\\expandafter\\Link\\fi}\\def\\Link#1.a.b.c.{"..
"\\let\\HCode\\documentstyle\\def\\documentstyle{\\let\\documentstyle"..
"\\HCode\\expandafter\\def\\csname tex4ht\\endcsname{#1,html}\\def"..
"\\HCode####1{\\documentstyle[tex4ht,}\\@ifnextchar[{\\HCode}{"..
-"\\documentstyle[tex4ht]}}}\\makeatother\\HCode ${tex4ht_sty_par}.a.b.c."..
+"\\documentstyle[tex4ht]}}\\RequirePackage[#1,html]{tex4ht}${packages}}\\makeatother\\HCode ${tex4ht_sty_par}.a.b.c."..
"\\input \"\\detokenize{${tex_file}}\"'"
-Make.plain_command = '${htlatex} --interaction=${interaction} ${latex_par}' ..
+Make.plain_command = '${htlatex} --interaction=${interaction} ${build_dir_arg} ${latex_par}' ..
"'\\def\\Link#1.a.b.c.{\\expandafter\\def\\csname tex4ht\\endcsname{\\expandafter\\def\\csname tex4ht\\endcsname{#1,html}\\input tex4ht.sty }}" ..
"\\def\\HCode{\\futurelet\\HCode\\HChar}\\def\\HChar{\\ifx\"\\HCode\\def\\HCode\"##1\"{\\Link##1}\\expandafter\\HCode\\else\\expandafter\\Link\\fi}" ..
"\\HCode ${tex4ht_sty_par}.a.b.c.\\input \"\\detokenize{${tex_file}}\"'"
@@ -68,7 +70,11 @@ function m.htlatex(par, latex_command)
devnull = " > nul 2>&1"
end
par.interaction = par.interaction or "batchmode"
- -- remove all terminal output from the batchmode
+ if par.builddir~="" then
+ par.build_dir_arg = "--output-directory=${builddir}" % par
+ else
+ par.build_dir_arg = ""
+ end
if par.interaction == "batchmode" then
command = command .. devnull
end
diff --git a/support/make4ht/make4ht-indexing.lua b/support/make4ht/make4ht-indexing.lua
index 746c062cb3..d5c0d07718 100644
--- a/support/make4ht/make4ht-indexing.lua
+++ b/support/make4ht/make4ht-indexing.lua
@@ -80,7 +80,7 @@ local parse_idx = function(content)
elseif line:match("^\\indexentry") then
-- replace the page number with the current
-- index entry number
- local result = line:gsub("{[0-9]+}$", "{"..current_entry .."}")
+ local result = line:gsub("%b{}$", "{"..current_entry .."}")
buffer[#buffer+1] = get_utf8(result)
else
buffer[#buffer+1] = line
@@ -150,7 +150,7 @@ local get_idxname = function(par)
end
local prepare_tmp_idx = function(par)
- par.idxfile = get_idxname(par)
+ par.idxfile = mkutils.file_in_builddir(get_idxname(par), par)
if not par.idxfile or not mkutils.file_exists(par.idxfile) then return nil, "Cannot load idx file " .. (par.idxfile or "''") end
-- construct the .ind name, based on the .idx name
par.indfile = par.indfile or par.idxfile:gsub("idx$", "ind")
diff --git a/support/make4ht/make4ht-lib.lua b/support/make4ht/make4ht-lib.lua
index 91418d18b5..0e9715a39d 100644
--- a/support/make4ht/make4ht-lib.lua
+++ b/support/make4ht/make4ht-lib.lua
@@ -194,9 +194,12 @@ Make.run = function(self)
end
end
end
- local lgfile = params.input and params.input .. ".lg" or nil
+ local lgfile = params.input and params.input .. ".lg" or nil
+ if params.builddir~="" then
+ lgfile = params.builddir .. "/" .. lgfile
+ end
if lgfile then
- self.lgfile = self.lgfile or mkutils.parse_lg(lgfile)
+ self.lgfile = self.lgfile or mkutils.parse_lg(lgfile, params.builddir)
local lg = self.lgfile
-- First convert images from lg files
self:image_convert(lg["images"])
diff --git a/support/make4ht/mkparams.lua b/support/make4ht/mkparams.lua
index ed766f9770..10ddd04744 100644
--- a/support/make4ht/mkparams.lua
+++ b/support/make4ht/mkparams.lua
@@ -21,6 +21,7 @@ Available options:
possible values: tex4ht or lua4ht
-c,--config (default xhtml) Custom config file
-d,--output-dir (default nil) Output directory
+ -B,--build-dir (default nil) Build directory
-e,--build-file (default nil) If build file is different than `filename`.mk4
-f,--format (default html5) Output file format
-h,--help Display this message
@@ -191,12 +192,20 @@ local function process_args(args)
local outdir = ""
local packages = ""
- if args["output-dir"] ~= "nil" then
+ if args["output-dir"] ~= "nil" then
outdir = args["output-dir"] or ""
outdir = outdir:gsub('\\','/')
outdir = outdir:gsub('/$','')
end
+ local builddir = ""
+
+ if args["build-dir"] ~= "nil" then
+ builddir = args["build-dir"] or ""
+ builddir = builddir:gsub('\\','/')
+ builddir = builddir:gsub('/$','')
+ end
+
-- make4ht now requires UTF-8 output, because of DOM filters
-- numeric entites are expanded to Unicode characters. These
-- characters would be displayed incorrectly in 8 bit encodings.
@@ -274,7 +283,7 @@ local function process_args(args)
local parameters = {
htlatex = compiler
,input=input
- ,tex_file=tex_file
+ ,tex_file=tex_file
,packages=packages
,latex_par=table.concat(latex_params," ")
--,config=ebookutils.remove_extension(args.config)
@@ -291,6 +300,7 @@ local function process_args(args)
--,t4ht_dir_format=t4ht_dir_format
}
if outdir then parameters.outdir = outdir end
+ if builddir then parameters.builddir = builddir end
log:info("Output dir: "..outdir)
log:info("Compiler: "..compiler)
log:info("Latex options: ".. table.concat(latex_params," "))
diff --git a/support/make4ht/mkutils.lua b/support/make4ht/mkutils.lua
index f7636b9d2a..ec5158d9d2 100644
--- a/support/make4ht/mkutils.lua
+++ b/support/make4ht/mkutils.lua
@@ -25,6 +25,10 @@ getmetatable("").__add = addProperty
--print( "${name} is ${value}" % {name = "foo", value = "bar"} )
-- Outputs "foo is bar"
+function is_url(path)
+ return path:match("^%a+://")
+end
+
-- merge two tables recursively
function merge(t1, t2)
@@ -81,8 +85,9 @@ end
-- searching for converted images
-function parse_lg(filename)
+function parse_lg(filename, builddir)
log:info("Parse LG")
+ local dir = builddir~="" and builddir .. "/" or ""
local outputimages,outputfiles,status={},{},nil
local fonts, used_fonts = {},{}
if not file_exists(filename) then
@@ -95,14 +100,15 @@ function parse_lg(filename)
line:gsub("needs %-%-%- (.+)%[([0-9]+)%] ==> (.*) %-%-%-",
function(file,page,output)
local rec = {
- source = file,
+ source=file,
page=page,
- output = output
+ output=dir..output
}
table.insert(outputimages,rec)
end
)
- line:gsub("File: (.*)", function(k)
+ line:gsub("File: (.*)", function(k)
+ k = dir .. k
if not usedfiles[k] then
table.insert(outputfiles,k)
usedfiles[k] = true
@@ -133,6 +139,10 @@ local cp_func = os.type == "unix" and "cp" or "copy"
-- in reality it isn't.
-- local cp_func = os.type == "unix" and "mv" or "move"
function cp(src,dest)
+ if is_url(src) then
+ log.info(src .. " is a URL, will leave as is")
+ return
+ end
if not file_exists(src) then
-- try to find file using kpse library if it cannot be found
src = kpse.find_file(src) or src
@@ -212,14 +222,33 @@ function mkdirectories(dirs)
if type(dirs) ~="table" then
return false, "mkdirectories: dirs is not table"
end
+ local path = ""
for _,d in ipairs(dirs) do
- local stat,msg = lfs.mkdir(d)
+ path = path .. d .. "/"
+ local stat,msg = lfs.mkdir(path)
if not stat then return false, "makedirectories error: "..msg end
- lfs.chdir(d)
end
return true
end
+function make_path(path)
+ -- we must create the build dir if it doesn't exist
+ local cwd = lfs.currentdir()
+ -- add dummy /foo dir. it won't be created, but without that, the top-level dir wouldn't be created
+ local parts = mkutils.prepare_path(path .. "/foo")
+ local to_create = mkutils.find_directories(parts)
+ mkutils.mkdirectories(to_create)
+ -- change back to the original dir
+ lfs.chdir(cwd)
+end
+
+function file_in_builddir(filename, par)
+ if par.builddir and par.builddir ~= "" then
+ return par.builddir .. "/" .. filename
+ end
+ return filename
+end
+
function copy_filter(src,dest, filter)
local src_f=io.open(src,"rb")
local dst_f=io.open(dest,"w")
@@ -379,7 +408,7 @@ env.Make:add("latexmk", function(par)
par.expanded = command % par
-- quotes in latex_command must be escaped, they cause Latexmk error
par.expanded = par.expanded:gsub('"', '\\"')
- local newcommand = 'latexmk -pdf- -ps- -auxdir=. -outdir=. -latex="${expanded}" -dvi -jobname=${input} ${tex_file}' % par
+ local newcommand = 'latexmk -pdf- -ps- -auxdir=${builddir} -outdir=${builddir} -latex="${expanded}" -dvi -jobname=${input} ${tex_file}' % par
log:info("LaTeX call: " .. newcommand)
os.execute(newcommand)
return Make.testlogfile(par)
@@ -392,7 +421,7 @@ env.Make:add("tex4ht",function(par)
-- detect if svg output is used
-- if yes, we need to pass the -g.svg option to tex4ht command
-- to support svg images for character pictures
- local logfile = par.input .. ".log"
+ local logfile = mkutils.file_in_builddir(par.input .. ".log", par)
if file_exists(logfile) then
for line in io.lines(logfile) do
local options = line:match("TeX4ht package options:(.+)")
@@ -405,18 +434,35 @@ env.Make:add("tex4ht",function(par)
end
end
end
+ local cwd = lfs.currentdir()
+ if par.builddir~="" then
+ lfs.chdir(par.builddir)
+ end
local command = "tex4ht ${tex4ht_par} \"${input}.${dvi}\"" % par
log:info("executing: " .. command)
- return execute(command)
+ local status, output = execute(command)
+ lfs.chdir(cwd)
+ return status, output
end
, nil, 1)
-env.Make:add("t4ht","t4ht ${t4ht_par} \"${input}.${ext}\"",{ext="dvi"},1)
+env.Make:add("t4ht", function(par)
+ par.ext = "dvi"
+ local cwd = lfs.currentdir()
+ if par.builddir ~= "" then
+ lfs.chdir(par.builddir)
+ end
+ local command = "t4ht ${t4ht_par} \"${input}.${ext}\"" % par
+ log:info("executing: " .. command)
+ execute(command)
+ lfs.chdir(cwd)
+end
+)
env.Make:add("clean", function(par)
-- remove all functions that process produced files
-- we will provide only one function, that remove all of them
Make.matches = {}
- local main_name = par.input
+ local main_name = mkutils.file_in_builddir( par.input, par)
local remove_file = function(filename)
if file_exists(filename) then
log:info("removing file: " .. filename)
@@ -424,7 +470,8 @@ env.Make:add("clean", function(par)
end
end
-- try to find if the last converted file was in the ODT format
- local lg_file = parse_lg(main_name .. ".lg")
+ local lg_name = main_name .. ".lg"
+ local lg_file = parse_lg(lg_name, par.builddir)
local is_odt = false
if lg_file and lg_file.files then
for _, x in ipairs(lg_file.files) do
@@ -442,7 +489,7 @@ env.Make:add("clean", function(par)
end
Make:match("tmp$", function()
-- remove temporary and auxilary files
- for _,ext in ipairs {"aux", "xref", "tmp", "4tc", "4ct", "idv", "lg","dvi", "log", "ncx"} do
+ for _,ext in ipairs {"aux", "xref", "tmp", "4tc", "4ct", "idv", "lg","dvi", "log", "ncx", "idx", "ind"} do
remove_file(main_name .. "." .. ext)
end
end)
@@ -592,7 +639,13 @@ function load_extension(name,format)
local is_extension_file = find_lua_file(extension_library)
-- don't try to load the extension if it doesn't exist
if not is_extension_file then return nil, "cannot fint extension " .. name end
- local extension = require("make4ht.extensions.make4ht-ext-".. name)
+ local extension = nil
+ local local_extension_path = package.searchpath(extension_library, package.path)
+ if local_extension_path then
+ extension = dofile(local_extension_path)
+ else
+ extension = require("make4ht.extensions.make4ht-ext-".. name)
+ end
-- extensions can test if the current output format is supported
local test = extension.test
if test then
diff --git a/support/make4ht/readme.tex b/support/make4ht/readme.tex
index 98a0712899..9cff4cbeea 100644
--- a/support/make4ht/readme.tex
+++ b/support/make4ht/readme.tex
@@ -45,6 +45,7 @@ make4ht [options] filename ["tex4ht.sty op." "tex4ht op."
possible values: tex4ht or lua4ht
-c,--config (default xhtml) Custom config file
-d,--output-dir (default "") Output directory
+-B,--build-dir (default nil) Build directory
-e,--build-file (default nil) If the build filename is different
than `filename`.mk4
-f,--format (default nil) Output file format
@@ -274,6 +275,17 @@ correct destinations.
$ make4ht -d outputdir filename.tex
\end{verbatim}
+\texttt{make4ht} can also output temporary files to a build directory,
+thanks to the \texttt{-\/-build-dir} (or \texttt{-B}) option. The
+following command with put \texttt{.aux}, \texttt{.4tc} and other
+auxiliary files to the \texttt{build} dir, and the generated
+\texttt{.html} and \texttt{.css} files to the \texttt{outputdir}
+directory.
+
+\begin{verbatim}
+$ make4ht -B build -d outputdir filename.tex
+\end{verbatim}
+
\hypertarget{image-conversion-and-postprocessing-of-the-generated-files}{%
\subsection{Image conversion and postprocessing of the generated
files}\label{image-conversion-and-postprocessing-of-the-generated-files}}
@@ -332,7 +344,15 @@ The extensions can be enabled or disabled by appending
\texttt{+EXTENSION} or \texttt{-EXTENSION} after the output format name:
\begin{verbatim}
- $ make4ht -uf html5+tidy filename.tex
+ $ make4ht -f html5+tidy filename.tex
+\end{verbatim}
+
+In \texttt{xhtml} and \texttt{html5} output formats, the
+\texttt{common\_domfilters} extension is triggered automatically, but it
+can still be disabled using:
+
+\begin{verbatim}
+ $ make4ht -f html5-common_domfilters filename.tex
\end{verbatim}
Available extensions:
@@ -342,9 +362,13 @@ Available extensions:
clean the output HTML files using filters.
\item[common\_domfilters]
clean the HTML file using DOM filters. It is more powerful than
-\texttt{common\_filters}. Used DOM filters are \texttt{fixinlines},
-\texttt{idcolons}, \texttt{joincharacters}, \texttt{sectionid} and
-\texttt{tablerows}.
+\texttt{common\_filters}. It used following DOM filters:
+\texttt{fixinlines}, \texttt{idcolons}, \texttt{joincharacters},
+\texttt{mathmlfixes}, \texttt{tablerows},\texttt{booktabs},
+\texttt{sectionid} and\texttt{itemparagraphs}
+\item[copy\_images]
+Copies the images to the output directory. This is useful if the
+original images are stored in directories above the document directory.
\item[detect\_engine]
detect engine and format necessary for the document compilation from the
magic comments supported by \LaTeX~editors such as TeXShop or TeXWorks.
@@ -1097,6 +1121,26 @@ filter_settings "collapsetoc" {
}
\end{verbatim}
+\hypertarget{the-copy_images-extension}{%
+\subsection{\texorpdfstring{The \texttt{copy\_images}
+extension}{The copy\_images extension}}\label{the-copy_images-extension}}
+
+\begin{description}
+\item[extensions]
+table with list of image extensions that should be processed.
+\item[img\_dir]
+name of the output directory where images should be stored
+\end{description}
+
+Default values:
+
+\begin{verbatim}
+ filter_settings "copy_images" {
+ extensions = {"png", "jpg", "jpeg", "svg"},
+ img_dir = ""
+ }
+\end{verbatim}
+
\hypertarget{the-fixinlines-dom-filter}{%
\subsection{\texorpdfstring{The \texttt{fixinlines} dom
filter}{The fixinlines dom filter}}\label{the-fixinlines-dom-filter}}
diff --git a/support/tex4ebook/README b/support/tex4ebook/README
index 95c60088ee..00f72d46b1 100644
--- a/support/tex4ebook/README
+++ b/support/tex4ebook/README
@@ -46,7 +46,7 @@ But it is optional. You shouldn't need to modify your \TeX\ files
## Available commands
-- `\coverimage[<graphicx options>]{coverimage.name}` - include cover image to
+- `\coverimage[<graphicx options>]{coverimage.name}` -- include cover image to
the document. You can pass the same options as to `\includegraphics` command
in the optional argument.
@@ -58,6 +58,8 @@ For example:
...
\pagestyle{headings}
+- `\epubpage` -- add page break to the document.
+
# Command line options
`-a,--loglevel`
diff --git a/support/tex4ebook/changelog.tex b/support/tex4ebook/changelog.tex
index 0cfaaa676c..ca4ff40585 100644
--- a/support/tex4ebook/changelog.tex
+++ b/support/tex4ebook/changelog.tex
@@ -3,6 +3,63 @@
\begin{itemize}
\item
+ 2024/02/23
+
+ \begin{itemize}
+ \tightlist
+ \item
+ version \texttt{0.4} released.
+ \end{itemize}
+\item
+ 2023/10/30
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added the \texttt{\textbackslash{}epubpage} command
+ \end{itemize}
+\item
+ 2023/10/17
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added the \texttt{-\/-build-dir} command line option.
+ \end{itemize}
+\item
+ 2023/10/15
+
+ \begin{itemize}
+ \tightlist
+ \item
+ don't set PNG as image format explicitly.
+ \end{itemize}
+\item
+ 2023/06/02
+
+ \begin{itemize}
+ \tightlist
+ \item
+ prevent fatal errors in the \texttt{zip} command executable
+ detection.
+ \end{itemize}
+\item
+ 2023/05/29
+
+ \begin{itemize}
+ \tightlist
+ \item
+ save author and date globally.
+ \end{itemize}
+\item
+ 2023/05/23
+
+ \begin{itemize}
+ \tightlist
+ \item
+ removed spurious numbers from TOC in Epub 3.
+ \end{itemize}
+\item
2023/03/17
\begin{itemize}
diff --git a/support/tex4ebook/readme.tex b/support/tex4ebook/readme.tex
index e144238178..1b3d7d61f6 100644
--- a/support/tex4ebook/readme.tex
+++ b/support/tex4ebook/readme.tex
@@ -54,7 +54,7 @@ But it is optional. You shouldn't need to modify your \TeX~files
\tightlist
\item
\texttt{\textbackslash{}coverimage{[}\textless{}graphicx\ options\textgreater{}{]}\{coverimage.name\}}
- - include cover image to the document. You can pass the same options
+ -- include cover image to the document. You can pass the same options
as to \texttt{\textbackslash{}includegraphics} command in the optional
argument.
\end{itemize}
@@ -69,6 +69,12 @@ For example:
\pagestyle{headings}
\end{verbatim}
+\begin{itemize}
+\tightlist
+\item
+ \texttt{\textbackslash{}epubpage} -- add page break to the document.
+\end{itemize}
+
\hypertarget{command-line-options}{%
\section{Command line options}\label{command-line-options}}
diff --git a/support/tex4ebook/tex4ebook b/support/tex4ebook/tex4ebook
index a88eca9fae..ac6a077d04 100755
--- a/support/tex4ebook/tex4ebook
+++ b/support/tex4ebook/tex4ebook
@@ -37,6 +37,7 @@ tex4ebook [switches] filename ["tex4ht.sty op."] ["tex4ht op."] ["t4ht op"] ["la
possible values: debug, info, status, warning, error, fatal
-c,--config (default xhtml) Custom config file
-d,--output-dir (default nil) Output directory
+ -B,--build-dir (default nil) Build directory
-e,--build-file (default nil) If build file is different than `filename`.mk4
-f,--format (default epub) Output format. Supported values: epub, epub3, mobi
-h,--help Display help message
@@ -67,7 +68,7 @@ else
end
if args.version then
- print "tex4ebook v0.3j"
+ print "tex4ebook v0.4"
return
end
@@ -125,6 +126,11 @@ local input = params.input
log:status("Conversion started")
log:status("Input file: ".. params.tex_file)
+if params.builddir ~= "" then
+ mkutils.make_path(params.builddir)
+end
+
+
local output_format = params.output_format
-- use epub as default output_format
diff --git a/support/tex4ebook/tex4ebook-doc.pdf b/support/tex4ebook/tex4ebook-doc.pdf
index a7ae003423..2139fd5911 100644
--- a/support/tex4ebook/tex4ebook-doc.pdf
+++ b/support/tex4ebook/tex4ebook-doc.pdf
Binary files differ
diff --git a/support/tex4ebook/tex4ebook-epub3.4ht b/support/tex4ebook/tex4ebook-epub3.4ht
index 0e1bcd85db..a470e053d5 100644
--- a/support/tex4ebook/tex4ebook-epub3.4ht
+++ b/support/tex4ebook/tex4ebook-epub3.4ht
@@ -25,7 +25,7 @@
}{\b:NavMap}{}{}{}
%%%%%%%%%%%
\newcount\:toccount
-\Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\global\advance\:toccount by1\HCode{<nav id="toc\the\:toccount" \ifnum\:toccount<2 epub:type="toc"\fi>\Hnewline<ol>}%
+\Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\global\advance\:toccount by1\HCode{<nav id="toc\the\:toccount" class="toc" \ifnum\:toccount<2 epub:type="toc"\fi>\Hnewline<ol>}%
\opf:registerfilename{\FileName}
\ifnum\:toccount<2 \opf:add:property{nav}\fi
}{\usetoclevels{part,appendix,chapter,section,subsection,subsubsection}%
@@ -36,7 +36,7 @@
\booltrue{tocnoempty}
\HCode{<li>}}{\HCode{<ol>\Hnewline}}{\ }{\Tg</ol>\Tg</li>}
% Disable numbering of the TOC by the reading system, numbers are added by tex4ht
-\Css{nav\#toc ol{list-style: none;}}
+\Css{nav.toc ol{list-style: none;}}
%%%% End toc nav configuration
\def\CoverMetadata#1{%
\special{t4ht+@File: #1}%
diff --git a/support/tex4ebook/tex4ebook-exec_epub.lua b/support/tex4ebook/tex4ebook-exec_epub.lua
index 539e9b19ba..4318067148 100644
--- a/support/tex4ebook/tex4ebook-exec_epub.lua
+++ b/support/tex4ebook/tex4ebook-exec_epub.lua
@@ -52,7 +52,7 @@ function prepare(params)
end
lfs.chdir(current)
end
- basedir = params.input.."-".. params.format
+ basedir = ebookutils.file_in_builddir(params.input.."-".. params.format, params)
outputdir= basedir.."/"..outputdir_name
deletedir(basedir)
makedir(outputdir)
@@ -150,12 +150,20 @@ function remove_empty_guide(content)
return content:gsub("<guide>%s*</guide>","")
end
+local function remove_builddir(filename)
+ -- make4ht adds the build dir to all output files,
+ -- but we don't want them there, because it is appended to the outdir
+ local builddir = Make.params.builddir
+ return filename:gsub("^" .. builddir .. "/", "")
+end
+
function make_opf()
-- Join files content.opf and content-part2.opf
-- make item record for every converted image
local lg_item = function(item)
+ local item = remove_builddir(item)
-- Find mimetype and make item tag for each converted file in the lg file
local fname,ext = item:match("([^%/^%.]*)%.([%a%d]*)$")
if not ext then return nil end
@@ -192,8 +200,8 @@ function make_opf()
tidyconf = kpse.find_file("tex4ebook-tidyconf.conf")
end
--local opf_first_part = outputdir .. "/content.opf"
- local opf_first_part = "content.opf"
- local opf_second_part = "content-part2.opf"
+ local opf_first_part = ebookutils.file_in_builddir("content.opf", Make.params)
+ local opf_second_part = ebookutils.file_in_builddir("content-part2.opf", Make.params)
--local opf_second_part = outputdir .. "/content-part2.opf"
if
ebookutils.file_exists(opf_first_part) and ebookutils.file_exists(opf_second_part)
@@ -242,8 +250,8 @@ function make_opf()
end
end
if not used_ids[id] then
- ebookutils.copy(k, outputdir .. "/"..k)
- if not all_used_files[k] then
+ ebookutils.copy(k, outputdir .. "/".. remove_builddir(k))
+ if not all_used_files[remove_builddir(k)] then
table.insert(opf_complete,item)
if allow_in_spine[ext] then
table.insert(outside_spine,id)
@@ -259,7 +267,7 @@ function make_opf()
-- process the images only if they weren't registered in lg_file["files"]
-- they would be processed twice otherwise
if not used_files[f] and not used_ids[id] then
- ebookutils.copy(f, outputdir .. "/"..f)
+ ebookutils.copy(f, outputdir .. "/".. remove_builddir(f))
table.insert(opf_complete,p)
end
used_ids[id] = true
@@ -282,7 +290,7 @@ function make_opf()
h_first:close()
os.remove(opf_second_part)
--ebookutils.copy(outputfilename ..".css",outputdir.."/")
- ebookutils.copy(opf_first_part,outputdir.."/"..opf_first_part)
+ ebookutils.copy(opf_first_part,outputdir.."/".. remove_builddir(opf_first_part))
--for c,v in pairs(lg_file["fonts"]) do
-- print(c, table.concat(v,", "))
--end
@@ -292,7 +300,9 @@ function make_opf()
end
end
local function find_zip()
- if assert(io.popen("zip -v","r"):close()) then
+ local zip_handle = assert(io.popen("zip -v","r"))
+ if zip_handle then
+ zip_handle:close()
return "zip"
elseif assert(io.popen("miktex-zip -v","r"):close()) then
return "miktex-zip"
@@ -322,8 +332,7 @@ function pack_container()
log:info("Tidy ncx "..
os.execute("tidy -xml -i -q -utf8 -m " .. ncxfilename))
log:info("Tidy opf "..
- os.execute("tidy -xml -i -q -utf8 -m " ..
- outputdir .. "/" .. "content.opf"))
+ os.execute("tidy -xml -i -q -utf8 -m " .. ebookutils.file_in_builddir("content.opf", Make.params)))
end
local zip = find_zip()
-- we need to remove the epub file if it exists already, because it may contain files which aren't used anymore
diff --git a/support/tex4ebook/tex4ebook.4ht b/support/tex4ebook/tex4ebook.4ht
index ce1cc86274..ade8f13ea2 100644
--- a/support/tex4ebook/tex4ebook.4ht
+++ b/support/tex4ebook/tex4ebook.4ht
@@ -146,6 +146,13 @@ href="#1" media-type="\a:CoverMimeType" />}}
\b:CoverImage%
}
+\renewcommand\epubpage{\a:epubpage}
+\NewConfigure{epubpage}{1}
+\Configure{epubpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}
+\Css{.newpage{page-break-before:always;}}
+
+
+
\NewConfigure{CoverMimeType}{1}
\Configure{CoverMimeType}{image/png}
@@ -190,13 +197,9 @@ href="#1" media-type="\a:CoverMimeType" />}}
% add explicit table of contents to OPF
\let\old:toc\a:tableofcontents
\def\a:tableofcontents{\old:toc\OpfRegisterFile}
-% Support for SVG isn't ready
-%\Configure{Picture}{.svg}
-\Configure{Picture}{.png}
\Configure{()}{$}{$}
\fi
\:CheckOption{kindle} \if:Option
-\Configure{Picture}{.png}
\fi
%%
diff --git a/support/tex4ebook/tex4ebook.sty b/support/tex4ebook/tex4ebook.sty
index 3ce94dd203..0470d9114a 100644
--- a/support/tex4ebook/tex4ebook.sty
+++ b/support/tex4ebook/tex4ebook.sty
@@ -1,6 +1,6 @@
% Package tex4ebook. Author Michal Hoftich <michal.h21@gmail.com>
% This package is subject of LPPL license, version 1.3
-\ProvidesPackage{tex4ebook}[2016/03/31 version 0.1d]
+\ProvidesPackage{tex4ebook}[2024-02-23 version v0.4]
\RequirePackage{etoolbox}
\RequirePackage{kvoptions}
\RequirePackage{graphicx}
@@ -144,12 +144,12 @@
\let\tf@orig@author\author
\newcommand\tf@author[1]{%
\tf@orig@author{#1}%
- \def\Author{#1}%
+ \gdef\Author{#1}%
}
\newcommand\tf@optauthor[2][]{%
\tf@orig@author[#1]{#2}%
- \def\Author{#2}%
+ \gdef\Author{#2}%
}
% support optiona argument for \author as well
@@ -162,7 +162,7 @@
\let\origdate\date
\renewcommand\date[1]{%
\origdate{#1}%
- \let\Date\@date%
+ \global\let\Date\@date%
}
%}
@@ -177,3 +177,7 @@
}
\newcommand\coverimage[2][]{\includegraphics[#1]{#2}}
+
+\newcommand\epubpage{\clearpage}
+
+\endinput