antfu / markdown-it-mdc

MDC (Markdown Components) syntax for markdown-it.
MIT License
109 stars 3 forks source link

fix: prev might be undefined #7

Closed jdeniau closed 10 months ago

jdeniau commented 10 months ago

Description

I got the following issue when adding a "bullet point only" slide in slidev

20:24:14 [vite] Internal server error: Cannot read properties of undefined (reading 'type')
  Plugin: unplugin-vue-markdown
  File: /@slidev/slides/6.md
      at file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/markdown-it-mdc/dist/index.mjs:411:18
      at Array.forEach (<anonymous>)
      at MarkdownItInlineProps.md.parse (file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/markdown-it-mdc/dist/index.mjs:406:12)
      at MarkdownIt.render (/home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/unplugin-vue-markdown/node_modules/markdown-it/lib/index.js:544:36)
      at file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/unplugin-vue-markdown/dist/chunk-EES4WMNF.js:242:25
      at TransformContext.transform (file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/unplugin-vue-markdown/dist/chunk-EES4WMNF.js:413:37)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Object.transform (file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30)
      at async loadAndTransform (file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29)
      at async viteTransformMiddleware (file:///home/jdeniau/code/julien.deniau.me/public/open-source-howto/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:59342:32

You can experiment yourself by creating a simple slide that only contains this


---
layout:default
---

*  test

Additional context

I do not really know why this is the plugin that is triggering the error, as I did not activate it, but testing that previs defined does fix the issue.

I do not know how to test this though. I did found the following file, but as I do not want to test MDC, what should I do here ?

Workaround

encapsule the list in a ul:

::ul
- item 1
- item 2
::ul