ChristopherBiscardi/gatsby-mdx

Error in `custom-remark-plugins` example

iamskok opened this issue · 2 comments

Describe the bug

custom-remark-plugins example errors on a fresh build.

info ℹ 「wdm」: Compiling...
 ERROR  Failed to compile with 1 errors                              10:55:14 PM
⠀
 error  in ./content/non-page.mdx
⠀
Syntax Error: SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-r
emark-plugins/content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn

 @ ./.cache/sync-requires.js 21:56-154
 @ ./.cache/app.js
 @ multi event-source-polyfill
⠀
error ✖ 「wdm」:
ERROR in ./content/non-page.mdx
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-plugins/
content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn
parentName="msup">{`2`}</mn></msup></mrow></msqrt></mrow><annotation
parentName="semantics" {...{
  319 |                 "encoding": "application/x-tex"
> 320 |               }}>&#123;`c = \\pm\\sqrt{a^2 +
b^2&#125;`}</annotation></semantics></math></span><span parentName="span" {...{
      |                                                  ^
  321 |           "className": "katex-html",
  322 |           "aria-hidden": "true"
  323 |         }}><span parentName="span" {...{
    at Object.raise (/Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
plugins/node_modules/@babel/parser/lib/index.js:6344:17)
    at Object.readToken_numberSign (/Users/skok/dev/examples/gatsby-mdx/examples
/custom-remark-plugins/node_modules/@babel/parser/lib/index.js:6661:12)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:7017:14)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:3631:18)
    at Object.nextToken (/Users/skok/dev/examples/gatsby-mdx/examples/custom-rem
info ℹ 「wdm」: Failed to compile.
info changed file at /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
 WAIT  Compiling...                                                 10:56:20 PM
⠀
info ℹ 「wdm」: Compiling...
 DONE  Compiled successfully in 294ms                               10:56:21 PM
⠀
info ℹ 「wdm」:
info ℹ 「wdm」: Compiled successfully.
 WAIT  Compiling...                                                 10:56:21 PM
⠀
info ℹ 「wdm」: Compiling...
 DONE  Compiled successfully in 146ms                               10:56:21 PM
⠀
info ℹ 「wdm」:
info ℹ 「wdm」: Compiled successfully.
info changed file at /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
 WAIT  Compiling...                                                 10:56:25 PM
⠀
info ℹ 「wdm」: Compiling...
 ERROR  Failed to compile with 1 errors                             10:56:25 PM
⠀
 error  in ./content/non-page.mdx
⠀
Syntax Error: SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-r
emark-plugins/content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn

 @ ./.cache/sync-requires.js 23:56-154
 @ ./.cache/app.js
 @ multi event-source-polyfill
⠀
error ✖ 「wdm」:
ERROR in ./content/non-page.mdx
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-plugins/
content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn
parentName="msup">{`2`}</mn></msup></mrow></msqrt></mrow><annotation
parentName="semantics" {...{
  319 |                 "encoding": "application/x-tex"
> 320 |               }}>&#123;`c = \\pm\\sqrt{a^2 +
b^2&#125;`}</annotation></semantics></math></span><span parentName="span" {...{
      |                                                  ^
  321 |           "className": "katex-html",
  322 |           "aria-hidden": "true"
  323 |         }}><span parentName="span" {...{
    at Object.raise (/Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
plugins/node_modules/@babel/parser/lib/index.js:6344:17)
    at Object.readToken_numberSign (/Users/skok/dev/examples/gatsby-mdx/examples
/custom-remark-plugins/node_modules/@babel/parser/lib/index.js:6661:12)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:7017:14)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:3631:18)
    at Object.nextToken (/Users/skok/dev/examples/gatsby-mdx/examples/custom-rem
info ℹ 「wdm」: Failed to compile.
 WAIT  Compiling...                                                 10:56:25 PM
⠀
info ℹ 「wdm」: Compiling...
 ERROR  Failed to compile with 1 errors                             10:56:26 PM
⠀
 error  in ./content/non-page.mdx
⠀
Syntax Error: SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-r
emark-plugins/content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn

 @ ./.cache/sync-requires.js 23:56-154
 @ ./.cache/app.js
 @ multi event-source-polyfill
⠀
error ✖ 「wdm」:
ERROR in ./content/non-page.mdx
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-plugins/
content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn
parentName="msup">{`2`}</mn></msup></mrow></msqrt></mrow><annotation
parentName="semantics" {...{
  319 |                 "encoding": "application/x-tex"
> 320 |               }}>&#123;`c = \\pm\\sqrt{a^2 +
b^2&#125;`}</annotation></semantics></math></span><span parentName="span" {...{
      |                                                  ^
  321 |           "className": "katex-html",
  322 |           "aria-hidden": "true"
  323 |         }}><span parentName="span" {...{
    at Object.raise (/Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
plugins/node_modules/@babel/parser/lib/index.js:6344:17)
    at Object.readToken_numberSign (/Users/skok/dev/examples/gatsby-mdx/examples
/custom-remark-plugins/node_modules/@babel/parser/lib/index.js:6661:12)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:7017:14)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:3631:18)
    at Object.nextToken (/Users/skok/dev/examples/gatsby-mdx/examples/custom-rem
info ℹ 「wdm」: Failed to compile.
 WAIT  Compiling...                                                 10:56:26 PM
⠀
info ℹ 「wdm」: Compiling...
 ERROR  Failed to compile with 1 errors                             10:56:26 PM
⠀
 error  in ./content/non-page.mdx
⠀
Syntax Error: SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-r
emark-plugins/content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn

 @ ./.cache/sync-requires.js 24:56-154
 @ ./.cache/app.js
 @ multi event-source-polyfill
⠀
error ✖ 「wdm」:
ERROR in ./content/non-page.mdx
Module build failed (from ./node_modules/gatsby/dist/utils/babel-loader.js):
SyntaxError: /Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-plugins/
content/non-page.mdx: Unexpected digit after hash token (320:49)

  318 |         }}><math parentName="span"><semantics parentName="math"><mrow
parentName="semantics"><mi parentName="mrow">{`c`}</mi><mo
parentName="mrow">{`=`}</mo><mo parentName="mrow">{`±`}</mo><msqrt
parentName="mrow"><mrow parentName="msqrt"><msup parentName="mrow"><mi
parentName="msup">{`a`}</mi><mn parentName="msup">{`2`}</mn></msup><mo
parentName="mrow">{`+`}</mo><msup parentName="mrow"><mi
parentName="msup">{`b`}</mi><mn
parentName="msup">{`2`}</mn></msup></mrow></msqrt></mrow><annotation
parentName="semantics" {...{
  319 |                 "encoding": "application/x-tex"
> 320 |               }}>&#123;`c = \\pm\\sqrt{a^2 +
b^2&#125;`}</annotation></semantics></math></span><span parentName="span" {...{
      |                                                  ^
  321 |           "className": "katex-html",
  322 |           "aria-hidden": "true"
  323 |         }}><span parentName="span" {...{
    at Object.raise (/Users/skok/dev/examples/gatsby-mdx/examples/custom-remark-
plugins/node_modules/@babel/parser/lib/index.js:6344:17)
    at Object.readToken_numberSign (/Users/skok/dev/examples/gatsby-mdx/examples
/custom-remark-plugins/node_modules/@babel/parser/lib/index.js:6661:12)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:7017:14)
    at Object.getTokenFromCode (/Users/skok/dev/examples/gatsby-mdx/examples/cus
tom-remark-plugins/node_modules/@babel/parser/lib/index.js:3631:18)
    at Object.nextToken (/Users/skok/dev/examples/gatsby-mdx/examples/custom-rem
info ℹ 「wdm」: Failed to compile.
⠸ write out redirect data — 38/15 0.51 queries/second

To Reproduce

  1. git clone git@github.com:ChristopherBiscardi/gatsby-mdx.git ./
  2. cd examples/custom-remark-plugins
  3. npm install
  4. gatsby develop

Expected behavior
Build without errors.

Looks like we have some leftover compatibility code for gatsby-remark-katex from before mdx-js/mdx fully supported html conversion. Need to remove it now.

Fixed in the 1.0 branch. Also released the katex fix in gatsby-plugin-mdx@1.0.5