Skip to content

Error: isSpace is not defined #2

@harpreetkhalsagtbit

Description

@harpreetkhalsagtbit

Describe the bug

Refer the code below

'use server';
import React from "react";
import { fromAsyncCodeToHtml } from '@shikijs/markdown-it/async'
import MarkdownItAsync from 'markdown-it-async'
import { codeToHtml } from 'shiki' // Or your custom shorthand bundle
import './MarkdownStyles.css'

// Initialize MarkdownIt instance with markdown-it-async
const md = MarkdownItAsync()
md.use(
  fromAsyncCodeToHtml(
    // Pass the codeToHtml function
    codeToHtml,
    {
      themes: {
        light: 'night-owl',
        dark: 'github-dark',
      }
    }
  )
)

const MarkdownRenderer: React.FC<{ content: string }> = async ({ content }) => {
  const html = await md.renderAsync(content)
  // const html = await md.renderAsync('# Title\n```ts\nconsole.log("Hello, World!")\n```')

  return <div className="markdown-body">
    <div dangerouslySetInnerHTML={{__html: html}}></div>
  </div>;
};

export default MarkdownRenderer;

I am getting this err when my markdown string includes - Numbered list
Error: isSpace is not defined

Image

for instance

1. Do not use the built-in method.
 2. Should work for all JavaScript environments.

Reproduction

use markdown string with numbered list

System Info

System:
    OS: macOS 12.7.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 23.76 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.12.0/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 126.1.67.116
    Chrome: 133.0.6943.55
    Safari: 17.6

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions