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

Assertion: expected last token to be open #25

Open
jakehwll opened this issue Jan 24, 2022 · 2 comments
Open

Assertion: expected last token to be open #25

jakehwll opened this issue Jan 24, 2022 · 2 comments

Comments

@jakehwll
Copy link

Hi there!

I was looking to use this in my latest project, however I can't seem to get around an issue and wondering perhaps if its because this library is out of date for remark?

See my example code below, using react component all I can seem to get the result to be is Assertion: expected last token to be open. The following only happens upon using the {test}^(test) syntax, else-wise all content renders fine out of unified, remark, rehype.

Am I perhaps calling something wrong?

import { createElement, Fragment } from 'react'

import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRuby from 'remark-ruby'
import remarkStringify from 'remark-stringify'
import remarkRehype from 'remark-rehype'
import rehypeReact from 'rehype-react'

const processor = unified()
  .use(remarkParse)
  .use(remarkRuby)
  .use(remarkRehype)
  .use(remarkStringify)
  .use(rehypeReact, {
    createElement: createElement,
    Fragment: Fragment,
  })

const Markdown = ({ content }: { content: string }) => {
  console.log(processor.parse(content))
  return <></>
}

const Page = ({}: any) => {
  return (
    <article className="mx-5 w-6/12">
      <Markdown content={`test {test}^(test)`} />
    </article>
  )
}
@laysent
Copy link
Owner

laysent commented Jan 25, 2022

@jakehwll Do you have a demo project for this? Or which remark do you use. I think this plugin is out of date and perhaps need some rewrite to make it work with new version of remark.

@jakehwll
Copy link
Author

Found it!

Seems to be an issue between remark-parse at ver. ^10.0.0 rather than ^9.0.0, downgrading this library for the time being has solved the issue. Was good to hear it wasn't me going crazy trying to learn remark 🙂

(Photo evidence).

image

Time to investigate the breaking changes between them!

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