question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-plugin-mdx] ERROR #11321 using reserved word in plain text

See original GitHub issue

Description

When I have the Markdown formatted just so the build breaks

seems similar to https://github.com/gatsbyjs/gatsby/issues/24923 and https://github.com/gatsbyjs/gatsby/issues/17315

Steps to reproduce

Try to render the Markdown file which has exactly the following content: (I know this one is weird but a version of it ended up being generated from my source files 😛 )

    # ```
    import static
    ```

Expected result

Things are rendered somehow

Actual result

ERROR #11321  PLUGIN

"gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle:

unknown: Unexpected reserved word 'static' (1:7)

> 1 | import static
    |        ^
  2 | ```
  3 | /Users/sitalov/coding/knowledge/garden/content/garden/hello.mdx: unknown: Unexpected reserved word 'static'
(1:7)

> 1 | import static
    |        ^
  2 | ```
  3 |



  SyntaxError: unknown: Unexpected reserved word 'static' (1:7)
  > 1 | import static
      |        ^
    2 | ```
    3 | /Users/sitalov/coding/knowledge/garden/content/garden/hello.mdx: unknown: Unexpected reserve  d word 'static'
(1:7)
  > 1 | import static
      |        ^
    2 | ```
    3 |

  - error.js:60 Object._raise
    [garden]/[@babel]/parser/src/parser/error.js:60:45

  - error.js:55 Object.raiseWithData
    [garden]/[@babel]/parser/src/parser/error.js:55:17

  - error.js:39 Object.raise
    [garden]/[@babel]/parser/src/parser/error.js:39:17

Interesting variations

    # ```
    import magic
    ```

also breaks things

    # ```import static
    ```

does not break things

    # ```
        import static
    ```

does not break things

Environment

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 15.5.0 - ~/.nvm/versions/node/v15.5.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.3.0 - ~/.nvm/versions/node/v15.5.0/bin/npm
  Languages:
    Python: 3.8.5 - /Users/sitalov/.pyenv/shims/python
  Browsers:
    Chrome: 87.0.4280.88
    Firefox: 84.0
    Safari: 14.0.2
  npmPackages:
    gatsby: ^2.21.37 => 2.29.3
  npmGlobalPackages:
    gatsby-cli: 2.16.2
    gatsby-source-roamresearch: 0.4.1
    gatsby: 2.29.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ascorbiccommented, Jan 15, 2021

right now I do text replace & inject newline before any ``` I think something like that is the only way

0reactions
Stvadcommented, Jan 15, 2021

Space added so Github renders it as code (so original has no spaces). Actual file: https://gist.githubusercontent.com/Stvad/1d9ca7868e627c300d333430f9fa941f/raw/b3a4c63c11c46bc8fff7ee7d3218684fe4d8f476/example_breaking1.mdx

The triple-backticks after the # does not create a code fence, so the import on the next line should be expected to be treated as code, which is why it fails.

I see 😞. Will close this then, though would appreciate any pointers for working around this! (right now I do text replace & inject newline before any ```)

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR #11321 in `gatsby-plugin-mdx` when using ... - GitHub
I have an .md file that contains words import and export in the same sentence. This throws an error when trying to run...
Read more >
How to resolve gatsby-plugin-mdx threw an error while ...
"gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle: file.mdx: Namespace tags are not supported by default. React's JSX ...
Read more >
gatsby-plugin-mdx - npm
It lets you write JSX embedded inside markdown. It's a great combination because it allows you to use markdown's often terse syntax (such...
Read more >
How to MDX with Gatsby - clubmate.fi
An introduction to MDX, and how to configure and set it up on an existing Gatsby site. MDX explained briefly. MDX is like...
Read more >
What is MDX and how you can use it on your Gatsby blog
It's a simple conversion tool that allows you to write a simple text format that gets converted to valid HTML. For example, to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found