Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunks[startIndex].slice is not a function #4

Open
eikowagenknecht opened this issue Jul 14, 2024 · 2 comments
Open

chunks[startIndex].slice is not a function #4

eikowagenknecht opened this issue Jul 14, 2024 · 2 comments

Comments

@eikowagenknecht
Copy link

eikowagenknecht commented Jul 14, 2024

I'm trying to use this is Astro. Unfortunately, when at least one callout is present on the page, rendering crashes:

Failed to parse Markdown file "C:\Entwicklung\repos\eiko-wagenknecht.de\src\content\posts\markdown-test.md":
chunks[startIndex].slice is not a function

Stack Trace:

TypeError: Failed to parse Markdown file "C:\Entwicklung\repos\eiko-wagenknecht.de\src\content\posts\markdown-test.md":
chunks[startIndex].slice is not a function
    at sliceChunks (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/micromark@4.0.0/node_modules/micromark/lib/create-tokenizer.js:512:32)
    at Object.sliceStream (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/micromark@4.0.0/node_modules/micromark/lib/create-tokenizer.js:153:12)
    at insideTitle (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/remark-callout@1.1.1/node_modules/remark-callout/dist/lib/micromark-syntax.js:105:33)
    at afterTypePotentialWhitespace (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/remark-callout@1.1.1/node_modules/remark-callout/dist/lib/micromark-syntax.js:100:16)
    at go (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/micromark@4.0.0/node_modules/micromark/lib/create-tokenizer.js:222:13)
    at main (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/micromark@4.0.0/node_modules/micromark/lib/create-tokenizer.js:208:9)
    at Object.write (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/micromark@4.0.0/node_modules/micromark/lib/create-tokenizer.js:129:5)
    at fromMarkdown (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/mdast-util-from-markdown@2.0.1/node_modules/mdast-util-from-markdown/lib/index.js:173:66)
    at parser (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.js:33:12)
    at Function.parse (file:///C:/Entwicklung/repos/eiko-wagenknecht.de/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js:668:12)

Input:

> [!example]
> Example

package.json:

  "dependencies": {
    "@astrojs/mdx": "3.1.2",
    "@astrojs/partytown": "2.1.1",
    "@astrojs/react": "3.6.0",
    "@astrojs/rss": "4.0.7",
    "@astrojs/sitemap": "3.1.6",
    "@astrojs/tailwind": "5.1.0",
    "@radix-ui/react-dialog": "1.1.1",
    "@types/mdast": "4.0.4",
    "astro": "4.11.5",
    "hast-util-from-html-isomorphic": "2.0.0",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "rehype-autolink-headings": "7.1.0",
    "rehype-slug": "6.0.0",
    "remark-callout": "^1.1.1",
    "remark-github-blockquote-alert": "1.2.1",
    "remark-obsidian-callout": "1.1.3",
    "remark-toc": "9.0.0",
    "sanitize-html": "2.13.0",
    "unified": "11.0.5",
    "unist-util-visit": "5.0.0"
  },
  "devDependencies": {
    "@astrojs/check": "0.8.0",
    "@biomejs/biome": "1.8.3",
    "@commitlint/cli": "19.3.0",
    "@commitlint/config-conventional": "19.2.2",
    "@commitlint/types": "19.0.3",
    "@tailwindcss/forms": "0.5.7",
    "@tailwindcss/typography": "0.5.13",
    "@types/react": "18.3.3",
    "@types/react-dom": "18.3.0",
    "lefthook": "1.7.1",
    "prettier": "3.3.2",
    "prettier-plugin-astro": "0.14.0",
    "prettier-plugin-tailwindcss": "0.6.5",
    "tailwindcss": "3.4.4",
    "typescript": "5.5.3"
  }

The other alternative plugins work fine (with their limited functionality).

@rk-terence
Copy link
Owner

Hi, thank you for your report and sorry for the late reply. This issue looks a little weird, and it might be related to depencencies this package use. I have found a similar issue here in the micromark GitHub repo. The dependency "micromark-utils-character" might be causing the problem. Further investigation is needed, and I will work on this to reach a solution when I can spare some time.

Testing locally on my machine works fine. My exact local version of dependency "micromark-util-character" is 2.0.1.
As a temporary fix, maybe specifying

"micromark-util-character": "2.0.1"

in your package.json can solve your problem (note there is no caret symbol before the version number).

@eikowagenknecht
Copy link
Author

Pinning 2.0.1 does not fix this. Thanks for investigating, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants