Escape sequence problem with template literals

Tagged templates are awesome! However, there are certain rules for escape sequences (if used) inside a template literal:

  • Anything starting with \u will be regarded as a Unicode escape sequence
  • Anything starting with \x will be regarded as a hexadecimal escape sequence
  • Anything starting with \ and then a digit will be regarded as an octal escape sequence

Therefore, as of now, even with tagged templates, you cannot make use of languages such as LaTeX with template strings because of the syntax of these languages.

LaTeX is a document preparation system usually used to write complicated equations, math formulas, and so on. Using an escape sequence such as `E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}` ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.