You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tex-compiler/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty

213 lines
6.4 KiB

%%
%% This is file `lwarp-chemformula.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lwarp.dtx (with options: `chemformula')
%% This is a generated file.
%% Copyright 2016-2020 Brian Dunn
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
\LWR@ProvidesPackagePass{chemformula}[2019/10/13]
\ExplSyntaxOn
\RenewDocumentCommand \ch { O{}m }
{%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}% lwarp
{
\chemformula_ch:nn {#1} {#2}% original
}
{
\begingroup%
\boolfalse{mathjax}%
\LWR@subsingledollar*{% lwarp
\textbackslash{}ch\{\LWR@HTMLsanitize{#2}\}% alt text
}{%
\protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}% add'l hashing
}%
{%
\chemformula_ch:nn {#1} {#2}% original
}%
\endgroup%
}
}
\@ifpackagelater{chemformula}{2019/10/13}{
\cs_gset_protected:Npn \chemformula_chcpd:nn #1#2
{
\begingroup%
\boolfalse{mathjax}%
\LWR@subsingledollar*{% lwarp
\textbackslash{}chcpd\{\LWR@HTMLsanitize{#2}\}%
}{%
\protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
}{% original
\group_begin:
\tl_if_blank:nF {#2}
{
\keys_set:nn {chemformula} {#1}
\__chemformula_save_catcodes:
\__chemformula_sanitize:Nn
\l__chemformula_chemformula_tmpa_tl
{#2}
\__chemformula_input_compound_no_check:NV
\l__chemformula_compound_tl
\l__chemformula_chemformula_tmpa_tl
\__chemformula_prepare_output:NV
\l__chemformula_compound_tl
\l__chemformula_catcodes_tl
\chemformula_write:V \l__chemformula_compound_tl
}
\group_end:
}
\endgroup
}
}% later than 2019/10/13
{% earlier than 2019/10/13
\cs_gset_protected:Npn \chemformula_chcpd:nn #1#2
{
\begingroup%
\boolfalse{mathjax}%
\LWR@subsingledollar*{% lwarp
\textbackslash{}chcpd\{\LWR@HTMLsanitize{#2}\}%
}{%
\protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
}{% original
\group_begin:
\tl_if_blank:nF {#2}
{
\keys_set:nn {chemformula} {#1}
\__chemformula_save_catcodes:
\__chemformula_sanitize:Nn
\l__chemformula_chemformula_tmpa_tl
{#2}
\__chemformula_input_compound_no_check:NV
\l__chemformula_compound_tl
\l__chemformula_chemformula_tmpa_tl
\__chemformula_prepare_output:N \l__chemformula_compound_tl
\chemformula_write:V \l__chemformula_compound_tl
}
\group_end:
}
\endgroup
}
}% earlier than 2019/10/13
\RenewDocumentCommand \charrow { mO{}O{} }
{
\begin{lateximage}[-chemformula- charrow]
\group_begin:
\__chemformula_draw_arrow:nnn {#1} {#2} {#3}
\group_end:
\end{lateximage}
}
\RenewDocumentCommand \chname { R(){}R(){} }
{
\begin{lateximage}*[%
\textbackslash{}chname(\LWR@HTMLsanitize{#1})(\LWR@HTMLsanitize{#2})
]*%
\chemformula_chwritebelow:nn {#1} {#2}
\end{lateximage}
}
\RenewDocumentCommand \chlewis { O{}mm }
{
\begingroup%
\boolfalse{mathjax}%
\LWR@subsingledollar*{\textbackslash{}chlewis\{#2\}\{#3\}}%
{
\protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
}{
\chemformula_lewis:nnn {#1} {#2} {#3}
}
\endgroup%
}
\bool_new:N \l__chemformula_first_last_LWRdollar_bool
\cs_gset_protected:Npn \__chemformula_input_escape_math:n #1
{
\__chemformula_first_last_math:n {#1}
\bool_if:NT \l__chemformula_first_last_dollar_bool
{
\bool_set_true:N \l__chemformula_first_last_math_bool
\__chemformula_read_escape_dollar:w #1 \q_nil
}
\bool_if:NT \l__chemformula_first_last_mathbraces_bool
{
\bool_set_true:N \l__chemformula_first_last_math_bool
\__chemformula_read_escape_mathbraces:w #1 \q_nil
}
\bool_if:NT \l__chemformula_first_last_LWRdollar_bool% lwarp
{
\bool_set_true:N \l__chemformula_first_last_math_bool% lwarp
\__chemformula_read_escape_LWRdollar:w #1 \q_nil% lwarp
}
}
\begingroup
\catcode`\$=\active
\cs_new_protected:Npn \__chemformula_read_escape_LWRdollar:w $#1$ \q_nil
{
\__chemformula_read_escape_math:n {#1}
}
\endgroup
\cs_new_protected:Npn \__chemformula_bool_cs_set_if_first_last:NnNN #1#2#3#4
{
\int_zero:N \l__chemformula_tmpa_int
\int_zero:N \l__chemformula_tmpb_int
\int_set:Nn \l__chemformula_tmpa_int { \tl_count:n {#2} }
\tl_map_inline:nn {#2}
{
\int_incr:N \l__chemformula_tmpb_int
\int_compare:nT { \l__chemformula_tmpb_int = 1 }
{
\ifdefstrequal{##1}{#3}% lwarp
{
\bool_set_true:N #1
}% lwarp
{}
}
\int_compare:nT { \l__chemformula_tmpb_int = \l__chemformula_tmpa_int }
{
\ifdefstrequal{##1}{#4}
{}
{
\bool_set_false:N #1
}
}
}
}
\cs_gset_protected:Npn \__chemformula_first_last_math:n #1
{
\bool_set_false:N \l__chemformula_first_last_math_bool
\bool_set_false:N \l__chemformula_first_last_dollar_bool
\bool_set_false:N \l__chemformula_first_last_LWRdollar_bool% lwarp
\bool_set_false:N \l__chemformula_first_last_mathbraces_bool
\__chemformula_bool_set_if_first_last:Nnnn
\l__chemformula_first_last_dollar_bool
{#1}
{ $ } { $ }
\bool_if:NF \l__chemformula_first_last_dollar_bool
{
\__chemformula_bool_set_if_first_last:Nnnn
\l__chemformula_first_last_mathbraces_bool
{#1}
{ \( } { \) }
\bool_if:NF \l__chemformula_first_last_mathbraces_bool% lwarp
{
\__chemformula_bool_cs_set_if_first_last:NnNN
\l__chemformula_first_last_LWRdollar_bool
{#1}
{ \LWR@newsingledollar } { \LWR@newsingledollar }
}% lwarp
}
}
\ExplSyntaxOff
\endinput
%%
%% End of file `lwarp-chemformula.sty'.