I have a variable in which I have text written in latex format
let textVar ="$\frac{1}{2}$"
console.log(textVar)
"$rac{1}{2}"
console.log(String.raw`$\frac{1}{2}$`)
"$\frac{1}{2}$"
I lose my escape characters (\ + the next char) when I do console.log(textVar) I understand the functionality of escape charaters in text and I need to add double quotes (\\) inorder to retain them in textVar, which I cannot do
I found that String.raw`$\frac{1}{2}$` retains text without escaping.
Can I pass my textVar to String.raw in any way?
This doesn't work though String.raw`${textVar}`