title: Expected EOF error in KaTeX
body: <p>I'm using the KaTeX JavaScript library to parse and render LaTeX. It mostly works but much the time, seemingly randomly there's an EOF (end of file) error.</p>
  
  <p>What my script tries to do is go through an array of raw LaTeX code and print out the literal string next to the rendered LaTeX. Here it is in a nutshell:</p>
  
  <pre><code>&lt;div id='math-constructs'&gt;
  &lt;script&gt;
      $(document).ready(function() {
              $.each([
                      'frac{abc}{xyz}',
                      'overline{abc}',
                      'overrightarrow{abc}',
                      'underline{abc}',
                      'overleftarrow{abc}',
                      'sqrt{abc}',
                      'widehat{abc}',
                      'overbrace{abc}',
                      'sqrt[n]{abc}',
                      'widetilde{abc}',
                      'underbrace{abc}'
              ], function(i, char) {
                  try {
                      $('#math-constructs').append('&lt;div&gt;&lt;code&gt;\\' + char + '&lt;/code&gt;' + katex.renderToString('\\' + char) + '&lt;/div&gt;');
                  } catch (err) {
                      $('#math-constructs').append('&lt;div&gt;' + err + '&lt;/div&gt;');
                  }
          });
      });
  &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The code to catch the error appended on the end returns the same thing every time it runs into one.</p>
  
  <p><code>ParseError: KaTeX parse error: Expected 'EOF', got '\overrightarrow' at position 15: \overrightarrow̲{abc}</code></p>
  
  <p><code>ParseError: KaTeX parse error: Expected 'EOF', got '\widehat' at position 8: \widehat̲{abc}</code></p>
  
  <p>I figure that there's some weird escaping of characters happening of here, and for that reason it might be worth mentioning that I'm writing this inline within markdown (specifically GFM).</p>
  
  <p>Here's the LaTeX documentation I'm referencing: <a href="http://www.auburn.edu/~tamtiny/Symbols.pdf" rel="nofollow noreferrer">http://www.auburn.edu/~tamtiny/Symbols.pdf</a></p>