summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chemmacros
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-14 21:15:41 +0000
committerKarl Berry <karl@freefriends.org>2017-06-14 21:15:41 +0000
commit92cc524b166cd7781eff8c663c6188a7f953d92b (patch)
tree11d9148bd4d4d2c947eb8470008a9d918bee17e2 /Master/texmf-dist/tex/latex/chemmacros
parent3cf6d48c1314bf02ff5de86d3c64ce69a0497958 (diff)
chemmacros (14jun17)
git-svn-id: svn://tug.org/texlive/trunk@44596 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.acid-base.code.tex4
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex2
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.lang.code.tex6
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex65
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex2
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.phases.code.tex4
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex12
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex2
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex2
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.spectroscopy.code.tex18
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.thermodynamics.code.tex2
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty140
12 files changed, 165 insertions, 94 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.acid-base.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.acid-base.code.tex
index 4ba72d344ae..fb998832c9a 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.acid-base.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.acid-base.code.tex
@@ -66,7 +66,7 @@
\tl_set:cn
{l__chemmacros_#2_tl}
{ \chemmacros_translate:n {#2} }
- \chemmacros_if_compatibility:nnTF {>} {5.6}
+ \chemmacros_if_compatibility:nnTF {>=} {5.7}
{ \chemmacros_declare_translation:nnn {#2} {fallback} {#3} }
{ \DeclareTranslationFallback {#2} {#3} }
\cs_set_protected:Npn #1
@@ -139,7 +139,7 @@
}
% --------------------------------------------------------------------------
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\DeclareTranslation {English} {K-acid} {\mathrm{a}}
\DeclareTranslation {German} {K-acid} {\mathrm{s}}
\DeclareTranslation {Dutch} {K-acid} {\mathrm{z}}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
index a1d3ac24048..9f54d9317f7 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex
@@ -196,7 +196,7 @@
\EndChemCompatibility
% --------------------------------------------------------------------------
-\ChemCompatibilityTo{5.0}
+\ChemCompatibilityTo{5.1}
\chemmacros_set_formula_method:n {chemformula}
\EndChemCompatibility
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.lang.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.lang.code.tex
index a087398981e..b9dea089d24 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.lang.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.lang.code.tex
@@ -48,7 +48,7 @@
\tl_new:N \l__chemmacros_current_language_tl
\tl_const:Nx \c__chemmacros_keyword_prefix_tl
- { \chemmacros_if_compatibility:nnT {>} {5.6} {chem-keyword-} }
+ { \chemmacros_if_compatibility:nnT {>=} {5.7} {chem-keyword-} }
\prop_new:N \g_chemmacros_translations_prop
@@ -80,7 +80,7 @@
language .initial:n = auto
}
-\ChemCompatibilityTo{5.2}
+\ChemCompatibilityTo{5.3}
\chemmacros_define_global_keys:n
{
german .meta:n = { language = german } ,
@@ -102,7 +102,6 @@
}
% --------------------------------------------------------------------------
-% \ChemCompatibilityFrom{5.6}
\cs_new_protected:Npn \__chemmacros_declare_translation:nw #1#2=#3\q_stop
{
\tl_set:Nx \l__chemmacros_tmpa_tl { \tl_trim_spaces:n {#2} }
@@ -144,7 +143,6 @@
\NewDocumentCommand \DeclareChemTranslation {mmm}
{ \chemmacros_declare_translation:nnn {#1} {#2} {#3} }
\@onlypreamble \DeclareChemTranslation
-% \EndChemCompatibility
\cs_new:Npn \__chemmacros_parse_translate_list_entry:nnn #1#2#3 {}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex
index 037f863190b..5a347b66e9d 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex
@@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\ChemModule{nomenclature}{2017/07/10 chemical names}
+\ChemModule{nomenclature}{2017/06/11 chemical names}
\RequirePackage{scrlfile}
@@ -141,7 +141,7 @@
\chemmacros_make_iupac:
}
-\ChemCompatibilityTo{5.1}
+\ChemCompatibilityTo{5.2}
\cs_new_protected:Npn \chemmacros_make_iupac:
{
\bool_if:NT \l__chemmacros_in_document_bool
@@ -242,7 +242,7 @@
\chemmacros_define_keys:nn {nomenclature}
{ cip-kern .dim_set:N = \l__chemmacros_cip_kern_dim }
-\ChemCompatibilityTo{5.1}
+\ChemCompatibilityTo{5.2}
\cs_new_protected:Npn \chemmacros_cip:n #1
{ \textit{#1} \tex_kern:D \l__chemmacros_cip_kern_dim }
@@ -250,7 +250,7 @@
{ \chemmacros_cip:n {#1} }
\EndChemCompatibility
-\ChemCompatibilityBetween{5.2}{5.7}
+\ChemCompatibilityBetween{5.2}{5.8}
\cs_new_protected:Npn \chemmacros_cip:n #1
{
\int_zero:N \l__chemmacros_tmpa_int
@@ -434,7 +434,7 @@
% #1: pre break
% #2: post break
% #3: no break
-\ChemCompatibilityTo{5.0}
+\ChemCompatibilityTo{5.1}
\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3
{
\chemmacros_nobreak:
@@ -443,12 +443,12 @@
}
\EndChemCompatibility
-\ChemCompatibilityFrom{5.1}
+\ChemCompatibilityBetween{5.1}{5.8}
\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3
{
\mode_if_math:TF
{#3}
- {
+ {
\chemmacros_nobreak:
\tex_discretionary:D {#1} {#2} {#3}
\chemmacros_allow_hyphens:
@@ -456,6 +456,22 @@
}
\EndChemCompatibility
+\ChemCompatibilityFrom{5.8a}
+\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3
+ {
+ \mode_if_math:TF
+ {#3}
+ {
+ \peek_meaning:NTF \group_end:
+ {#3}
+ {
+ \chemmacros_nobreak:
+ \tex_discretionary:D {#1} {#2} {#3}
+ \chemmacros_allow_hyphens:
+ }
+ }
+ }
+\EndChemCompatibility
\dim_new:N \l__chemmacros_iupac_hyphen_pre_dim
\dim_set:Nn \l__chemmacros_iupac_hyphen_pre_dim { .01em }
@@ -463,15 +479,17 @@
\dim_set:Nn \l__chemmacros_iupac_hyphen_post_dim { -.03em }
\dim_new:N \l__chemmacros_iupac_break_dim
\dim_set:Nn \l__chemmacros_iupac_break_dim { .03em }
+\skip_new:N \l__chemmacros_iupac_break_skip
+\skip_set:Nn \l__chemmacros_iupac_break_skip { .03em plus .07em }
\chemmacros_define_keys:nn {nomenclature}
{
hyphen-pre-space .dim_set:N = \l__chemmacros_iupac_hyphen_pre_dim ,
hyphen-post-space .dim_set:N = \l__chemmacros_iupac_hyphen_post_dim ,
- break-space .dim_set:N = \l__chemmacros_iupac_break_dim
+ break-space .skip_set:N = \l__chemmacros_iupac_break_skip
}
-\ChemCompatibilityTo{5.1}
+\ChemCompatibilityTo{5.2}
\cs_new_protected:Npn \chemmacros_break_point_hyphen:
{
\__chemmacros_break_point_insert:nnn
@@ -483,18 +501,6 @@
\tex_kern:D \l__chemmacros_iupac_hyphen_post_dim
}
}
-
-\cs_new_protected:Npn \chemmacros_break_point:
- {
- \__chemmacros_break_point_insert:nnn
- {-}
- { }
- {
- \mode_if_math:TF
- { | }
- { \tex_kern:D \l__chemmacros_iupac_break_dim }
- }
- }
\EndChemCompatibility
\ChemCompatibilityFrom{5.2}
@@ -509,6 +515,7 @@
\tex_kern:D \l__chemmacros_iupac_hyphen_post_dim
}
}
+\EndChemCompatibility
\cs_new_protected:Npn \chemmacros_break_point:
{
@@ -521,7 +528,6 @@
{ \tex_kern:D \l__chemmacros_iupac_break_dim }
}
}
-\EndChemCompatibility
\cs_new_protected:Npn \chemmacros_break_point_opening_paren:
{ \__chemmacros_break_point_insert:nnn { - } { ( } { ( } }
@@ -584,10 +590,13 @@
\cs_new_protected:Npn \chemmacros_make_shorthands:
{
- \chemmacros_if_document:T
+ \chemmacros_if_compatibility:nnT {>=} {5.2}
{
- \chemmacros_for_all_iupac_shorthands_do:n
- { \prop_item:Nn \l__chemmacros_iupac_shorthands_prop {##1} }
+ \chemmacros_if_document:T
+ {
+ \chemmacros_for_all_iupac_shorthands_do:n
+ { \prop_item:Nn \l__chemmacros_iupac_shorthands_prop {##1} }
+ }
}
}
@@ -653,7 +662,7 @@
\cs_new_protected:Npn \chemmacros_iupac:n #1 { \chemmacros_iupac:nn {} {#1} }
-\ChemCompatibilityTo{5.2}
+\ChemCompatibilityTo{5.3}
% Thanks to Joseph Wright and Enrico Gregorio for the help on the curious
% redefinition of \- and the end of the compilation
% see http://tex.stackexchange.com/q/42405/5049 for reference
@@ -745,7 +754,7 @@
\NewChemMacroset {Latin} {mm}
{ \chemmacros_define_latin:Nn #1 {#2} }
-\ChemCompatibilityTo{5.6}
+\ChemCompatibilityTo{5.7}
\chemmacros_define_keys:nn {nomenclature}
{
latin-format .tl_set:N = \l__chemmacros_latin_format_tl ,
@@ -886,3 +895,5 @@
2017/04/17 - fix erroneous definition of \chemmacros_allow_hyphens:
- new options `cip-inner-format', `cip-outer-format' and
`cip-number-format'
+2017/06/11 - change behaviour of \__chemmacros_break_point_insert:nnn so
+ it does nothing as last token in \iupac
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
index 82473a53325..44cde878408 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.particles.code.tex
@@ -130,7 +130,7 @@
\NewChemNucleophile \Nuc {Nu}
\NewChemNucleophile \ba {ba}
-\ChemCompatibilityTo{5.2}
+\ChemCompatibilityTo{5.3}
\DeclareChemDeprecated \Hto \Oxo
\DeclareChemDeprecated \Nu \Nuc
\EndChemCompatibility
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.phases.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.phases.code.tex
index 2a5069f5bbb..5f2bcc1dcda 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.phases.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.phases.code.tex
@@ -44,7 +44,7 @@
\NewChemMacroset {Phase} {mm}
{ \chemmacros_define_phase:Nn #1 {#2} }
-\ChemCompatibilityTo{5.6}
+\ChemCompatibilityTo{5.7}
\cs_new_protected:Npn \chemmacros_define_phase:Nn #1#2
{
\tl_set:Nx \l__chemmacros_tmpa_tl { phase-\chemmacros_remove_backslash:N #1 }
@@ -98,7 +98,7 @@
\NewChemPhase \aq {aq}
% --------------------------------------------------------------------------
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\DeclareTranslation {English} {phase-sld} {s}
\DeclareTranslation {German} {phase-sld} {f}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
index 7dde472d7a6..35be8b3e905 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex
@@ -91,7 +91,7 @@
{ \l__chemmacros_reaction_heading_tl {#1} }
\cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V }
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\tl_set:Nn \l__chemmacros_reaction_lorname_tl
{ \chemmacros_translate:n {reaction} }
\EndChemCompatibility
@@ -139,7 +139,7 @@
\@starttoc {lor}
}
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\cs_new_protected:Npn \l@reaction #1#2
{ \@dottedtocline {1} {1.5em} {2.3em} {#1} {#2} }
\EndChemCompatibility
@@ -204,7 +204,7 @@
\EndChemCompatibility
% create new tagform
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\newtagform {reaction} {\{} {\}}
\EndChemCompatibility
\ChemCompatibilityFrom{5.6}
@@ -216,7 +216,7 @@
\newcounter {chemmacros_save_reaction}
\newcounter {reaction}
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\cs_new_protected:Npn \__chemmacros_begin_reaction:
{
% create individual names for `hyperref':
@@ -291,7 +291,7 @@
}
\cs_generate_variant:Nn \chemmacros_declare_reaction_env:nnnn {nnnV}
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\cs_new_protected:Npn \chemmacros_reaction_read:nnw #1#2#3 \end
{
\begin{#1}#2
@@ -348,7 +348,7 @@
\NewChemReaction {reactions*} {align*}
% --------------------------------------------------------------------------
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\DeclareTranslationFallback {list-of-reactions} {List~ of~ Reactions}
\DeclareTranslation {English} {list-of-reactions} {List~ of~ Reactions}
\DeclareTranslation {German} {list-of-reactions} {Reaktionsverzeichnis}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex
index 8d9918e498a..9e95b9b076a 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex
@@ -82,7 +82,7 @@
\group_end:
}
-\ChemCompatibilityTo{5.3}
+\ChemCompatibilityTo{5.4}
\cs_new_protected:Npn \__chemmacros_ox_sign:n #1
{
\bool_if:nT
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
index 8a3ed06c620..1a07bd1c500 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.scheme.code.tex
@@ -247,7 +247,7 @@
}
% --------------------------------------------------------------------------
-\ChemCompatibilityTo{5.5}
+\ChemCompatibilityTo{5.6}
\DeclareTranslationFallback {scheme-name} {Scheme}
\DeclareTranslation {English} {scheme-name} {Scheme}
\DeclareTranslation {German} {scheme-name} {Schema}
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.spectroscopy.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.spectroscopy.code.tex
index 8ba4c066cc6..30223fc583f 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.spectroscopy.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.spectroscopy.code.tex
@@ -120,7 +120,7 @@
\tl_set:Nn \l__chemmacros_nmr_element_default_tl {#2}
}
-\ChemCompatibilityTo{5.7}
+\ChemCompatibilityTo{5.8}
\cs_new_protected:Npn \__chemmacros_nmr_base:nn #1#2
{
\tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
@@ -363,11 +363,11 @@
\NewDocumentCommand \chemmacros_data:w { smo }
{
\bool_if:NT \l__chemmacros_nmr_list_bool { \item }
- {
- \tl_use:N \l__chemmacros_nmr_format_tl #2
- \IfNoValueF {#3} { ~ ( #3 ) }
- \IfBooleanT {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } }
- }
+ {
+ \tl_use:N \l__chemmacros_nmr_format_tl #2
+ \IfNoValueF {#3} { ~ ( #3 ) }
+ \IfBooleanT {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } }
+ }
\IfBooleanF {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } }
}
@@ -448,7 +448,11 @@
\tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
{
\c_math_subscript_token
- { \chemmacros_chemformula:n {#2} }
+ {
+ \l__chemmacros_nmr_coupling_nuclei_pre_tl
+ \chemmacros_chemformula:n {#2}
+ \l__chemmacros_nmr_coupling_nuclei_post_tl
+ }
}
}
{
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.thermodynamics.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.thermodynamics.code.tex
index 3d97ecbb6cb..cf49fd0695b 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.thermodynamics.code.tex
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.thermodynamics.code.tex
@@ -137,7 +137,7 @@
\NewChemState \entropy { symbol = S , unit = \joule\per\kelvin\per\mole , pre = }
\NewChemState \gibbs { symbol = G , unit = \kilo\joule\per\mole }
-\ChemCompatibilityTo{5.2}
+\ChemCompatibilityTo{5.3}
\DeclareChemDeprecated \State \state
\DeclareChemDeprecated \Enthalpy \enthalpy
\DeclareChemDeprecated \Entropy \entropy
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
index a2a94addd3e..03d7b33bd91 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
@@ -31,10 +31,10 @@
% --------------------------------------------------------------------------
% package information:
-\tl_const:Nn \c_chemmacros_date_tl {2017/04/24}
+\tl_const:Nn \c_chemmacros_date_tl {2017/06/13}
\tl_const:Nn \c_chemmacros_version_major_number_tl {5}
\tl_const:Nn \c_chemmacros_version_minor_number_tl {8}
-\tl_const:Nn \c_chemmacros_version_subrelease_tl {}
+\tl_const:Nn \c_chemmacros_version_subrelease_tl {a}
\tl_const:Nx \c_chemmacros_version_number_tl
{
\c_chemmacros_version_major_number_tl .
@@ -56,8 +56,8 @@
% --------------------------------------------------------------------------
% set compatibility
-\fp_new:N \l__chemmacros_compatibility_version_fp
-\fp_set:Nn \l__chemmacros_compatibility_version_fp {\c_chemmacros_version_number_tl}
+\tl_new:N \l__chemmacros_compatibility_version_tl
+\tl_set_eq:NN \l__chemmacros_compatibility_version_tl \c_chemmacros_version_tl
\keys_define:nn {chemmacros/compatibility}
{
@@ -68,10 +68,11 @@
{latest} {}
}
{
- \fp_set:Nn \l__chemmacros_compatibility_version_fp
- { \c_chemmacros_version_number_tl }
+ \tl_set_eq:NN
+ \l__chemmacros_compatibility_version_tl
+ \c_chemmacros_version_tl
}
- { \fp_set:Nn \l__chemmacros_compatibility_version_fp {#1} } ,
+ { \tl_set:Nn \l__chemmacros_compatibility_version_tl {#1} } ,
unknown .code:n =
\PassOptionsToPackage{\CurrentOption}{chemmacros4}
\PassOptionsToPackage{\CurrentOption}{chemmacros5}
@@ -81,36 +82,92 @@
% --------------------------------------------------------------------------
% compare version numbers
-% #1: number
+% #1: version
% #2: relation
-% #3: number
+% #3: version
% #4: true
% #5: false
\prg_new_conditional:Npnn \chemmacros_if_version:nnn #1#2#3 {p,T,F,TF}
{
- \fp_compare:nTF { floor(#1) = floor(#3) }
+ \fp_compare:nTF
{
- \fp_compare:nTF
- {
- ( \chemmacros_get_minor_version:f {#1} )
- #2
- ( \chemmacros_get_minor_version:f {#3} )
- }
- { \prg_return_true: }
- { \prg_return_false: }
- }
- {
- \fp_compare:nTF { (#1) #2 (#3) }
- { \prg_return_true: }
- { \prg_return_false: }
+ (
+ \chemmacros_get_major_version:n {#1} * 1e6 +
+ \chemmacros_get_minor_version:n {#1} * 1e3 +
+ 0 \chemmacros_get_subrelease:n {#1}
+ )
+ #2
+ (
+ \chemmacros_get_major_version:n {#3} * 1e6 +
+ \chemmacros_get_minor_version:n {#3} * 1e3 +
+ 0 \chemmacros_get_subrelease:n {#3}
+ )
}
+ { \prg_return_true: }
+ { \prg_return_false: }
}
+\cs_generate_variant:Nn \chemmacros_if_version:nnnTF {fnf}
\cs_new:Npn \__chemmacros_get_minor_version:w #1.#2.#3 \q_stop
- { \tl_if_blank:nTF {#2} {0} {#2} }
+ {
+ \tl_if_blank:nTF {#2} {0} {
+ \tl_map_function:nN {#2} \__chemmacros_get_minor_number:n
+ }
+ }
+
\cs_new:Npn \chemmacros_get_minor_version:n #1
{ \__chemmacros_get_minor_version:w #1.. \q_stop }
-\cs_generate_variant:Nn \chemmacros_get_minor_version:n {f}
+
+\cs_new:Npn \__chemmacros_get_minor_number:n #1
+ {
+ \str_case:nn {#1}
+ {
+ {0} {0}
+ {1} {1}
+ {2} {2}
+ {3} {3}
+ {4} {4}
+ {5} {5}
+ {6} {6}
+ {7} {7}
+ {8} {8}
+ {9} {9}
+ }
+ }
+
+\cs_new:Npn \__chemmacros_get_major_version:w #1.#2.#3 \q_stop
+ { \tl_if_blank:nTF {#1} {0} {#1} }
+
+\cs_new:Npn \chemmacros_get_major_version:n #1
+ { \__chemmacros_get_major_version:w #1.. \q_stop }
+
+\cs_new:Npn \__chemmacros_get_subrelease:w #1.#2.#3 \q_stop
+ {
+ \tl_if_blank:nTF {#2} {0} {
+ \tl_map_function:nN {#2} \__chemmacros_get_subrelease_number:n
+ }
+ }
+
+\cs_new:Npn \chemmacros_get_subrelease:n #1
+ { \__chemmacros_get_subrelease:w #1.. \q_stop }
+
+\cs_new:Npn \__chemmacros_get_subrelease_number:n #1
+ {
+ \str_case:nnF {#1}
+ {
+ {0} {}
+ {1} {}
+ {2} {}
+ {3} {}
+ {4} {}
+ {5} {}
+ {6} {}
+ {7} {}
+ {8} {}
+ {9} {}
+ }
+ { \int_from_alph:n {#1} }
+ }
% check compatibility
% #1: relation
@@ -119,8 +176,8 @@
% #4: false
\prg_new_conditional:Npnn \chemmacros_if_compatibility:nn #1#2 {p,T,F,TF}
{
- \chemmacros_if_version:nnnTF
- { \fp_to_decimal:N \l__chemmacros_compatibility_version_fp }
+ \chemmacros_if_version:fnfTF
+ { \l__chemmacros_compatibility_version_tl }
{#1}
{#2}
{ \prg_return_true: }
@@ -129,13 +186,13 @@
\cs_generate_variant:Nn \chemmacros_if_compatibility:nnT {nV}
% user checks:
-\NewDocumentCommand \IfChemCompatibilityTF {mm+m+m}
+\NewExpandableDocumentCommand \IfChemCompatibilityTF {mm+m+m}
{ \chemmacros_if_compatibility:nnTF {#1} {#2} {#3} {#4} }
-\NewDocumentCommand \IfChemCompatibilityT {mm+m}
+\NewExpandableDocumentCommand \IfChemCompatibilityT {mm+m}
{ \chemmacros_if_compatibility:nnT {#1} {#2} {#3} }
-\NewDocumentCommand \IfChemCompatibilityF {mm+m}
+\NewExpandableDocumentCommand \IfChemCompatibilityF {mm+m}
{ \chemmacros_if_compatibility:nnF {#1} {#2} {#3} }
% --------------------------------------------------------------------------
@@ -147,14 +204,14 @@
{ \chemmacros_if_compatibility:nnT {>=} {#1} {#2} }
\cs_new_protected:Npn \ChemCompatibilityTo #1#2 \EndChemCompatibility
- { \chemmacros_if_compatibility:nnT {<=} {#1} {#2} }
+ { \chemmacros_if_compatibility:nnT {<} {#1} {#2} }
\cs_new_protected:Npn \ChemCompatibilityBetween #1#2#3 \EndChemCompatibility
{
\bool_if:nT
{
\chemmacros_if_compatibility_p:nn {>=} {#1} &&
- \chemmacros_if_compatibility_p:nn {<=} {#2}
+ \chemmacros_if_compatibility_p:nn {<} {#2}
}
{#3}
}
@@ -170,23 +227,24 @@
\msg_new:nnn {chemmacros} {too-high-compatibility}
{
You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~
- of~ chemmacros~ is~ v \c_chemmacros_version_number_tl .~ Falling~ back~
+ of~ chemmacros~ is~ v \c_chemmacros_version_tl .~ Falling~ back~
to~ v \c_chemmacros_version_number_tl !
}
\msg_new:nnn {chemmacros} {low-compatibility}
{
You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~
- of~ chemmacros~ is~ v \c_chemmacros_version_number_tl .~ Not~ all~ features~
- will~ be~ available!
+ of~ chemmacros~ is~ v \c_chemmacros_version_tl .~ Not~ all~ features~
+ or~ fixes~ will~ be~ available!
}
% --------------------------------------------------------------------------
% let's see that the max number is the newest (=current) version
-\chemmacros_if_compatibility:nnT {>} { \c_chemmacros_version_number_tl }
+\chemmacros_if_compatibility:nnT {>} { \c_chemmacros_version_tl }
{
- \fp_set:Nn \l__chemmacros_compatibility_version_fp
- { \c_chemmacros_version_number_tl }
+ \tl_set_eq:NN
+ \l__chemmacros_compatibility_version_tl
+ \c_chemmacros_version_tl
}
% --------------------------------------------------------------------------
@@ -194,14 +252,14 @@
\chemmacros_if_compatibility:nnT {<} {4.7}
{
\msg_warning:nnx {chemmacros} {too-low-compatibility}
- { \fp_to_tl:N \l__chemmacros_compatibility_version_fp }
+ { \l__chemmacros_compatibility_version_tl }
}
% not the newest version:
-\chemmacros_if_compatibility:nnT {<} { \c_chemmacros_version_number_tl }
+\chemmacros_if_compatibility:nnT {<} { \c_chemmacros_version_tl }
{
\msg_warning:nnx {chemmacros} {low-compatibility}
- { \fp_to_tl:N \l__chemmacros_compatibility_version_fp }
+ { \l__chemmacros_compatibility_version_tl }
}
% --------------------------------------------------------------------------