Documenting String.raw (#1198)

* Documenting String.raw

* Typo

* Rewrite String.raw doc
This commit is contained in:
Ryan Randall
2018-05-17 09:27:56 -04:00
committed by ylemkimon
parent 1ed99d9ff3
commit 7eed150c48

View File

@@ -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