From 7eed150c4806dafc8577fcc0df671cf5c5b19ecd Mon Sep 17 00:00:00 2001 From: Ryan Randall Date: Thu, 17 May 2018 09:27:56 -0400 Subject: [PATCH] Documenting String.raw (#1198) * Documenting String.raw * Typo * Rewrite String.raw doc --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b2e7247e..3da98d27 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,13 @@ Call `katex.render` with a TeX expression and a DOM element to render into: katex.render("c = \\pm\\sqrt{a^2 + b^2}", element); ``` +To avoid escaping the backslash (double backslash), you can use +[`String.raw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw) +(but beware that `${`, `\u` and `\x` may still need escaping): +```js +katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element); +``` + If KaTeX can't parse the expression, it throws a `katex.ParseError` error. #### Server side rendering or rendering to a string