iamskok/gatsby-remark-code-buttons

Gatsby build fails if markdown contains a code block within a list item

adamjcooper opened this issue · 0 comments

When building markdown which contains a code block which is part of a list item, like this:

1. First install this thing.
2. Then do this:

    ```js
    const thing = require('installed-thing')
    ```

3. Then start the app.

This plugin will currently cause the gatsby build to fail with:

TypeError: Cannot read property 'replace' of undefined

This is happening because the current implementation of the visit handler assumes that every code block is a top-level node in the AST. The problem can be fixed by updating the visit handler to take a third parent argument and then, within the implementation of the handler, use parent.children instead of markdownAST.children.