Trying to use textbook with ChemEquations.jl package

I have been learning Julia along side my AP chemistry class and was trying the ChemEquations.jl. It uses keyword ce to define a chemical Equations like this.

balance(ce"Al{3} + Cl{-1} = AlCl3")

What is ce above as a language construct? If I want someone to enter the equation in a text box it will be a string. If I define the equation as a string, how do I trigger the ce to convert?
eq=“Al{3} + Cl{-1} = AlCl3”

Here is my GitHub repository link so you can check equation notebook out if you would like!

I don’t know ChemEquations specifically (you might try posting an issue in that package), but in general see:

This is a string macro. You can construct it using the ce_str macro, which it parses to:

equation = @ce_str "C3H8 + O2 = CO2 + H2O"
balance(equation)

As far as I know, you can’t pass the value of a variable to a macro the same way as a string literal. But for your purposes, you can use the ChemEquation(str) method:

equation_string = "C3H8 + O2 = CO2 + H2O"
equation = ChemEquation(equation_string)
balance(equation)
1 Like