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

Error when using remarkGfm plugin with solid-markdown #35

Closed
jcourson8 opened this issue Jun 4, 2024 · 2 comments
Closed

Error when using remarkGfm plugin with solid-markdown #35

jcourson8 opened this issue Jun 4, 2024 · 2 comments

Comments

@jcourson8
Copy link

jcourson8 commented Jun 4, 2024

I am trying to use the remarkGfm plugin with the solid-markdown library to render GitHub Flavored Markdown, but I am encountering an error in the console when I include the plugin.

Steps to Reproduce:

  1. Create a new SolidJS project and install the solid-markdown and remark-gfm packages.
  2. Import SolidMarkdown from solid-markdown and remarkGfm from remark-gfm.
  3. Use the SolidMarkdown component with the remarkGfm plugin passed to the remarkPlugins prop.
<SolidMarkdown remarkPlugins={[remarkGfm]}>
  {markdown}
</SolidMarkdown>

Specifically I'm using this example for the markdown:

const markdown = `
  # h1 Heading 8-)
  ## h2 Heading
  ### h3 Heading
  #### h4 Heading
  ##### h5 Heading
  ###### h6 Heading
  
  
  ## Horizontal Rules
  
  ___
  
  ---
  
  ***
  
  
  ## Typographic replacements
  
  Enable typographer option to see result.
  
  (c) (C) (r) (R) (tm) (TM) (p) (P) +-
  
  test.. test... test..... test?..... test!....
  
  !!!!!! ???? ,,  -- ---
  
  "Smartypants, double quotes" and 'single quotes'
  
  
  ## Emphasis
  
  **This is bold text**
  
  __This is bold text__
  
  *This is italic text*
  
  _This is italic text_
  
  ~~Strikethrough~~
  
  
  ## Blockquotes
  
  
  > Blockquotes can also be nested...
  >> ...by using additional greater-than signs right next to each other...
  > > > ...or with spaces between arrows.
  
  
  ## Lists
  
  Unordered
  
  + Create a list by starting a line with \`+\`, \`-\`, or \`*\`
  + Sub-lists are made by indenting 2 spaces:
    - Marker character change forces new list start:
      * Ac tristique libero volutpat at
      + Facilisis in pretium nisl aliquet
      - Nulla volutpat aliquam velti
  + Very easy!
  
  Ordered
  
  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa
  
  
  1. You can use sequential numbers...
  1. ...or keep all the numbers as \`1.\`
  
  Start numbering with offset:
  
  57. foo
  1. bar
  
  
  ## Code
  
  Inline \`code\`
  
  Indented code
  
      // Some comments
      line 1 of code
      line 2 of code
      line 3 of code
  
  
  Block code "fences"
  
  \`\`\`
  Sample text here...
  \`\`\`
  
  Syntax highlighting
  
  \`\`\` js
  var foo = function (bar) {
    return bar++;
  };
  
  console.log(foo(5));
  \`\`\`
  
  ## Tables
  
  | Option | Description |
  | ------ | ----------- |
  | data   | path to data files to supply the data that will be passed into templates. |
  | engine | engine to be used for processing templates. Handlebars is the default. |
  | ext    | extension to be used for dest files. |
  
  Right aligned columns
  
  | Option | Description |
  | ------:| -----------:|
  | data   | path to data files to supply the data that will be passed into templates. |
  | engine | engine to be used for processing templates. Handlebars is the default. |
  | ext    | extension to be used for dest files. |
  
  
  `;

Something as simple as this also reproduces error:
const markdown = `\`a\``;

Expected Behavior:
The markdown should be rendered correctly with GitHub Flavored Markdown support.

Actual Behavior:
The following error is thrown in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'inTable')
    at Object.exitCodeText (remark-gfm.js?v=a628acdb:2423:17)
    at compile (solid-markdown___remark-parse.js?v=a628acdb:1724:40)
    at fromMarkdown (solid-markdown___remark-parse.js?v=a628acdb:1586:29)
    at parser (solid-markdown___remark-parse.js?v=a628acdb:2314:12)
    at Function.parse (solid-markdown___unified.js?v=a628acdb:352:12)
    at Object.fn (dev.jsx:374:50)
    at runComputation (chunk-5NS34ZCI.js?v=a628acdb:766:22)
    at updateComputation (chunk-5NS34ZCI.js?v=a628acdb:749:3)
    at createMemo (chunk-5NS34ZCI.js?v=a628acdb:267:5)
    at SolidMarkdown (dev.jsx:363:24)

Environment:

  • solid-markdown version: 2.0.13
  • remark-gfm version: 4.0.0
  • SolidJS version: 1.8.11

Additional Information:
This repository demonstrates the issue in a minimal setup (specifically in the App.tsx). When the remarkGfm plugin is included in the remarkPlugins prop of the SolidMarkdown component, the error occurs. Removing the plugin resolves the error but loses the GitHub Flavored Markdown functionality.

@andi23rosca
Copy link
Owner

I think it's a version mismatch issue, solid-markdown definitely works with remark-gfm 3.0.1
I can't support higher versions yet due to a bug in how the library gets bundled (this one here: #33)

@jcourson8
Copy link
Author

This solved the issue, thanks!

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