elviswolcott / remark-admonitions

Add admonitions support to Remarkable
MIT License
110 stars 19 forks source link

this.Parser.prototype is undefined in astro project #51

Closed LuHugo closed 1 year ago

LuHugo commented 1 year ago

I am using it in the astro project, and when I start the project I get the error Cannot read properties of undefined (reading 'blockTokenizers'). When I debugged the code I found that this.Parser.prototype was undefined in the plugin code.

astro version is "astro": "^3.1.0"

project astro.config.mjs code:

import { defineConfig } from 'astro/config';
import react from "@astrojs/react";

import remarkToc from 'remark-toc';
import remarkAdmonitions from 'remark-admonitions';
import remarkA11yEmoji from '@fec/remark-a11y-emoji';
import remarkCodeTitle from 'remark-code-title';
import remarkCodeBlocks from 'remark-code-blocks'

import mdx from "@astrojs/mdx";

// https://astro.build/config
export default defineConfig({
  markdown: {
    remarkPlugins: [
      remarkToc, 
      remarkAdmonitions,
      remarkA11yEmoji,
      remarkCodeTitle,
      remarkCodeBlocks,
    ],
  },
  integrations: [react(), mdx()]
});

I don't know if it's a configuration problem or something went wrong.

Expectation: Works on astro project

LuHugo commented 1 year ago

use remark-directive

A5yncX commented 7 months ago

@LuHugo Hi! Can you be more specific? I'm having the same problem.:(

LuHugo commented 7 months ago

@LuHugo Hi! Can you be more specific? I'm having the same problem.:(

Because I used the remark-admonitions plug-in which caused the error, and then I replaced it with remark-directive and got the function I needed. I didn't delve too deeply into the reason.