Skip to content

Commit

Permalink
Prefer context
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrswift committed Sep 26, 2024
1 parent 75a16d7 commit f190afa
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/rules/deuterated.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rules/enantiomers.typ
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rules/formulae.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rules/greek.typ
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/isomers.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/stateful.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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) = {
Expand Down

0 comments on commit f190afa

Please sign in to comment.