/**
 * Preprocess TeX code to convert things that KaTeX doesn't know how to handle
 * to things is does.
 */

module.exports = (texCode) => {
    // Replace uses of \begin{align}...\end{align} which KaTeX doesn't
    // support (yet) with \begin{aligned}...\end{aligned} which renders
    // the same is supported by KaTeX.  It does the same for align*.
    // TODO(kevinb) update content to use aligned instead of align.
    return texCode.replace(/\{align[*]?\}/g, '{aligned}');
};

/**
 * Preprocess TeX code to convert things that KaTeX doesn't know how to handle
 * to things is does.
 */

module.exports = (texCode) => texCode
    // Replace uses of \begin{align}...\end{align} which KaTeX doesn't
    // support (yet) with \begin{aligned}...\end{aligned} which renders
    // the same is supported by KaTeX.  It does the same for align*.
    // TODO(kevinb) update content to use aligned instead of align.
    .replace(/\{align[*]?\}/g, '{aligned}')

    // Replace non-breaking spaces with regular spaces.
    .replace(/[\u00a0]/g, ' ');

Replace non-breaking spaces with real spaces before rendering math with KaTeX
Replace non-breaking spaces with real spaces before rendering math with KaTeX

Summary: https://app.asana.com/0/74945521838608/174138257679861

Test Plan:
- make serve
- localhost:9000
- write some math containing a non-breaking space
- verify that the math is rendered with KaTeX instead of MathJax

Reviewers: jared

Reviewed By: jared

Differential Revision: https://phabricator.khanacademy.org/D30837
