| 1 |
% mhchem.4ht (2024-03-01-14:08), generated from tex4ht-4ht.tex |
| 2 |
% Copyright 2024 TeX Users Group |
| 3 |
% Copyright 2015-2021 Martin Hensel |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either |
| 7 |
% version 1.3c of this license or (at your option) any |
| 8 |
% later version. The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3c or later is part of all distributions |
| 11 |
% of LaTeX version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status "maintained". |
| 14 |
% |
| 15 |
% The Current Maintainer of this work |
| 16 |
% is the TeX4ht Project <http://tug.org/tex4ht>. |
| 17 |
% |
| 18 |
% If you modify this program, changing the |
| 19 |
% version identification would be appreciated. |
| 20 |
\immediate\write-1{version 2024-03-01-14:08} |
| 21 |
|
| 22 |
\ExplSyntaxOn |
| 23 |
% basic mhchem containers |
| 24 |
\NewConfigure{mhchemce}{2} |
| 25 |
\NewConfigure{mhchemcf}{2} |
| 26 |
|
| 27 |
\pend:def\__mhchem_output_begin_ce:{\a:mhchemce} |
| 28 |
\append:def\__mhchem_output_end_ce:{\b:mhchemce} |
| 29 |
\pend:def\__mhchem_output_begin_cf:{\a:mhchemcf} |
| 30 |
\append:def\__mhchem_output_end_cf:{\b:mhchemcf} |
| 31 |
|
| 32 |
% alternative version of coreFivd |
| 33 |
|
| 34 |
\NewConfigure{mhchemisotope}{3} |
| 35 |
|
| 36 |
\NewConfigure{mhchemsub}{2} |
| 37 |
|
| 38 |
\NewConfigure{mhchemsup}{2} |
| 39 |
|
| 40 |
\NewConfigure{mhchemsupsub}{3} |
| 41 |
|
| 42 |
\cs_set_protected:Npn \__mhchem_output_coreFivefourht:nnnnnnn #1#2#3#4#5#6#7 |
| 43 |
{ |
| 44 |
\bool_if:nT |
| 45 |
{ \tl_if_empty_p:n {#7} && ! \tl_if_empty_p:n {#5} } |
| 46 |
{ \bool_set_true:N \l__mhchem_option_superscriptsStacked_bool } |
| 47 |
|
| 48 |
\tl_if_empty:nF {#1#2} |
| 49 |
{ |
| 50 |
\a:mhchemisotope |
| 51 |
\__mhchem_output_withFont:n { #1 } |
| 52 |
\b:mhchemisotope |
| 53 |
\__mhchem_output_withFont:n { #2 } |
| 54 |
\c:mhchemisotope |
| 55 |
} |
| 56 |
\__mhchem_output_withFont:n { #3 } |
| 57 |
\bool_if:NTF \l__mhchem_option_superscriptsStacked_bool |
| 58 |
{ |
| 59 |
\tl_if_empty:nTF {#4#5#7} |
| 60 |
{ |
| 61 |
\tl_if_empty:nF {#6} |
| 62 |
{ |
| 63 |
\a:mhchemsub |
| 64 |
\__mhchem_output_withFont:n { #6 } |
| 65 |
\b:mhchemsub |
| 66 |
} |
| 67 |
} |
| 68 |
{ |
| 69 |
\tl_if_empty:nTF {#6} |
| 70 |
{ |
| 71 |
\a:mhchemsup |
| 72 |
\__mhchem_output_withFont:n { #4#5#7 } |
| 73 |
\b:mhchemsup |
| 74 |
} |
| 75 |
{ |
| 76 |
\a:mhchemsupsub |
| 77 |
\__mhchem_output_withFont:n { #4#5#7 } |
| 78 |
\c:mhchemsupsub |
| 79 |
\__mhchem_output_withFont:n { #6 } |
| 80 |
\b:mhchemsupsub |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
{ |
| 85 |
\tl_if_empty:nF {#4} |
| 86 |
{ |
| 87 |
\a:mhchemsup |
| 88 |
\__mhchem_output_withFont:n { #4 } |
| 89 |
\b:mhchemsup |
| 90 |
} |
| 91 |
\tl_if_empty:nF {#6} |
| 92 |
{ |
| 93 |
\a:mhchemsub |
| 94 |
\__mhchem_output_withFont:n { #6 } |
| 95 |
\b:mhchemsub |
| 96 |
} |
| 97 |
\tl_if_empty:nF {#5#7} |
| 98 |
{ |
| 99 |
\a:mhchemsup |
| 100 |
\__mhchem_output_withFont:n { #5#7 } |
| 101 |
\b:mhchemsup |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
% replace original coreFive with our alternative version. it will work in picture math |
| 107 |
\HLet\__mhchem_output_coreFive:nnnnnnn\__mhchem_output_coreFivefourht:nnnnnnn |
| 108 |
|
| 109 |
\cs_set_protected:Npn \__mhchem_output_withFontfourht:n #1 %. output #1 as math or text |
| 110 |
{ |
| 111 |
\bool_if:NTF \l__mhchem_output_isMathMode_bool |
| 112 |
{ \begingroup\mathrm {#1}\endgroup } |
| 113 |
{ \begingroup\text {#1}\endgroup } |
| 114 |
} |
| 115 |
|
| 116 |
\HLet\__mhchem_output_withFont:n\__mhchem_output_withFontfourht:n |
| 117 |
|
| 118 |
\NewConfigure{mhchemoperator}{2} |
| 119 |
|
| 120 |
\def\:tempa#1#2{% |
| 121 |
\cs_set_protected:Npn\:tempb:{#2}% |
| 122 |
\HLet#1\:tempb:% |
| 123 |
} |
| 124 |
|
| 125 |
\:tempa \__mhchem_output_skipAfterAmount: {\HCode { ~ } } % space for copy & paste |
| 126 |
\:tempa \__mhchem_output_skipBeforeStateOfAggregation: {} |
| 127 |
\:tempa \__mhchem_output_minus: {\HCode{&\#x2212;}} % minus |
| 128 |
\:tempa \__mhchem_output_operatorPlus:{ \HCode {\a:mhchemoperator + \b:mhchemoperator }} |
| 129 |
\:tempa \__mhchem_output_operatorMinus:{ \HCode {\a:mhchemoperator&\#x2212; \b:mhchemoperator }} % minus |
| 130 |
\:tempa \__mhchem_output_operatorEquals:{ \HCode {\a:mhchemoperator = \b:mhchemoperator }} |
| 131 |
\:tempa \__mhchem_output_operatorPlusMinus:{\HCode {\a:mhchemoperator &\#xB1; \b:mhchemoperator }} % plusmn |
| 132 |
\:tempa \__mhchem_output_electronDot: { \HCode {&\#x2022;} } % bull |
| 133 |
\:tempa \__mhchem_output_additionCompound: { \HCode {&\#xB7;} } % middot |
| 134 |
\:tempa \__mhchem_output_excited: { \HCode { &\#x2731; } } |
| 135 |
\:tempa \__mhchem_output_commaDecimal: { , } |
| 136 |
\:tempa \__mhchem_output_commaEnumeration: {,\HCode {&\#x2009;} } % thinsp |
| 137 |
\:tempa \__mhchem_output_commaEnumerationSmall: {,\HCode{&\#x2009;} } % thinsp |
| 138 |
|
| 139 |
\:tempa \__mhchem_output_bond_single: { \HCode { \a:mhchemoperator&\#x2212;\b:mhchemoperator}} |
| 140 |
\:tempa \__mhchem_output_bond_double: { \HCode { \a:mhchemoperator=\b:mhchemoperator}} |
| 141 |
\:tempa \__mhchem_output_bond_triple: { \HCode { \a:mhchemoperator&\#x2261;\b:mhchemoperator}} |
| 142 |
|
| 143 |
% todo: add MathML support for these |
| 144 |
\:tempa \__mhchem_output_bond_half:{\a:mhchembondhalf} |
| 145 |
\:tempa \__mhchem_output_bond_oneAndHalf:{\a:mhchembondoneandhalf} |
| 146 |
\:tempa \__mhchem_output_bond_twoAndHalf:{\a:mhchembondtwoandhalf} |
| 147 |
\:tempa \__mhchem_output_bond_twoAndHalff:{\a:mhchembondtwoandhalff} |
| 148 |
|
| 149 |
\:tempa \__mhchem_output_bond_dotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;} } % ··· |
| 150 |
\:tempa \__mhchem_output_bond_dotdotdotdot: { \HCode { &\#xB7;&\#xB7;&\#xB7;&\#xB7;} } % ···· |
| 151 |
\:tempa \__mhchem_output_bond_rightArrow: { \HCode {\a:mhchemoperator &\#x2192;\b:mhchemoperator } } |
| 152 |
\:tempa \__mhchem_output_bond_leftArrow: {\HCode {\a:mhchemoperator &\#x2190;\b:mhchemoperator }} |
| 153 |
|
| 154 |
|
| 155 |
\NewConfigure{mhchembondhalf}{1} |
| 156 |
\NewConfigure{mhchembondoneandhalf}{1} |
| 157 |
\NewConfigure{mhchembondtwoandhalf}{1} |
| 158 |
\NewConfigure{mhchembondtwoandhalff}{1} |
| 159 |
|
| 160 |
|
| 161 |
\NewConfigure{mhchemarrow}{2} |
| 162 |
\NewConfigure{mhchemarrowabove}{2} |
| 163 |
|
| 164 |
\NewConfigure{mhchemarrowyields}{1} |
| 165 |
\NewConfigure{mhchemarrowyieldsLeft}{1} |
| 166 |
\NewConfigure{mhchemarrowyieldsLeftRight}{1} |
| 167 |
\NewConfigure{mhchemarrowmesomerism}{1} |
| 168 |
\NewConfigure{mhchemarrowequilibrium}{1} |
| 169 |
\NewConfigure{mhchemarrowequilibriumRight}{1} |
| 170 |
\NewConfigure{mhchemarrowequilibriumLeft}{1} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
\cs_set_protected:Npn \__mhchem_arrow_deployfourht:nnnnn #1#2#3#4#5 |
| 176 |
{ |
| 177 |
\a:mhchemarrow |
| 178 |
\tl_if_empty:nF {#3#5} |
| 179 |
{ |
| 180 |
\a:mhchemarrowabove |
| 181 |
\str_case:nnF {#2} |
| 182 |
{ |
| 183 |
{ } { \ce { #3 } } |
| 184 |
{ M } { \ensuremath { #3 } } |
| 185 |
{ T } { \text { #3 } } |
| 186 |
{ C } { \ce { #3 } } |
| 187 |
} |
| 188 |
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} } |
| 189 |
\b:mhchemarrowabove |
| 190 |
} |
| 191 |
\str_case:nnF {#1} |
| 192 |
{ |
| 193 |
{ yields } {\a:mhchemarrowyields } |
| 194 |
{ yieldsLeft } {\a:mhchemarrowyieldsLeft } |
| 195 |
{ yieldsLeftRight } {\a:mhchemarrowyieldsLeftRight } % todo: improve |
| 196 |
{ esomerism } {\a:mhchemarrowesomerism } % todo: improve |
| 197 |
{ equilibrium } {\a:mhchemarrowequilibrium } % todo: improve |
| 198 |
{ equilibriumRight } {\a:mhchemarrowequilibriumRight } % todo: improve |
| 199 |
{ equilibriumLeft } {\a:mhchemarrowequilibriumLeft } % todo: improve |
| 200 |
} |
| 201 |
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#1} } |
| 202 |
\tl_if_empty:nF {#3#5} |
| 203 |
{ |
| 204 |
\a:mhchemarrowabove |
| 205 |
\str_case:nnF {#2} |
| 206 |
{ |
| 207 |
{ } { \ce { #5 } } |
| 208 |
{ M } { \ensuremath { #5 } } |
| 209 |
{ T } { \text { #5 } } |
| 210 |
{ C } { \ce { #5 } } |
| 211 |
} |
| 212 |
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} } |
| 213 |
\b:mhchemarrowabove |
| 214 |
} |
| 215 |
\b:mhchemarrow |
| 216 |
} |
| 217 |
|
| 218 |
\HLet\__mhchem_arrow_deploy:nnnnn\__mhchem_arrow_deployfourht:nnnnn |
| 219 |
|
| 220 |
\ExplSyntaxOff |
| 221 |
|
| 222 |
|
| 223 |
% Additional configurations for MathML |
| 224 |
|
| 225 |
% print mathml command or html, depending on if we are inside mathml or not |
| 226 |
\newcommand\:mhmathmlorhtml[2]{\ifmathml\a:mathml #1\else #2\fi} |
| 227 |
\newcommand\:mhonlyinmathml[1]{\ifmathml #1\fi} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
\Hinput{mhchem} |
| 233 |
\endinput |
| 234 |
|