diff --git a/src/rules/deuterated.typ b/src/rules/deuterated.typ index a2a49ac..dcce4ba 100644 --- a/src/rules/deuterated.typ +++ b/src/rules/deuterated.typ @@ -3,12 +3,11 @@ #let deuterated(body) = { - show regex("(\w-d\d+)"): (it) => { + show regex("(\w-d\d+)"): (it) => context { if-state-enabled( it , { //show "-": "–" show regex("\d"): sub it - }) } body diff --git a/src/rules/enantiomers.typ b/src/rules/enantiomers.typ index d8e3cf2..e5168ab 100644 --- a/src/rules/enantiomers.typ +++ b/src/rules/enantiomers.typ @@ -1,7 +1,7 @@ #import "../stateful.typ": * #let enantiomers(body) = { - show regex("\([EZRS]\)"): (it) => { + show regex("\([EZRS]\)"): (it) => context { if-state-enabled( it , { show regex("\w"): text.with(style:"italic") it diff --git a/src/rules/formulae.typ b/src/rules/formulae.typ index e7a980d..eedf23c 100644 --- a/src/rules/formulae.typ +++ b/src/rules/formulae.typ @@ -8,7 +8,7 @@ #let ChemRegex = "(\(?((" + all-elements.map(it=>{"("+it+")"}).join("|") + ")+\d?)+(\)\d*)?(\d*([\+-])?)*)" #let formulae(body) = { - show regex(ChemRegex): (it) => { + show regex(ChemRegex): (it) => context { if-state-enabled( it , { show regex("\d"): set text(features: ("sinf", "subs")) show regex("\d*[+-]"): super diff --git a/src/rules/greek.typ b/src/rules/greek.typ index 1b119b4..bdfad48 100644 --- a/src/rules/greek.typ +++ b/src/rules/greek.typ @@ -1,7 +1,7 @@ #import "../stateful.typ": * #import "../constants.typ" -#let greek(body) = { +#let greek(body) = context { if-state-enabled( body , { show: it => { for (k, v) in constants.greek { diff --git a/src/rules/isomers.typ b/src/rules/isomers.typ index f983bf7..b136c0b 100644 --- a/src/rules/isomers.typ +++ b/src/rules/isomers.typ @@ -1,7 +1,7 @@ #import "../stateful.typ": * #let isomers(body) = { - show regex("(((iso)|(sec)|(tert)|(cis)|(trans)|(syn)|(anti)|(endo)|(exo)|[iompnNO])-)|([N][,′'’])"): (it) => { + show regex("(((iso)|(sec)|(tert)|(cis)|(trans)|(syn)|(anti)|(endo)|(exo)|[iompnNO])-)|([N][,′'’])"): (it) => context { if-state-enabled( it , { show "-": "–" emph(it) diff --git a/src/stateful.typ b/src/stateful.typ index 77ff6fc..71a5751 100644 --- a/src/stateful.typ +++ b/src/stateful.typ @@ -3,10 +3,8 @@ #let chem-toggle(bool) = {Chemistry-Style-disable-state.update(bool)} #let if-state-enabled( it , fn ) = { - Chemistry-Style-disable-state.display(bDisable =>{ - if ( bDisable == false ){ return it } - return fn - }) + if ( Chemistry-Style-disable-state.get() == false ){ return it } + return fn } #let chem-disabled(content) = {