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

fix: markdown import code block with prefix #5780

Conversation

samuelint
Copy link
Contributor

@samuelint samuelint commented Mar 29, 2024

Problem

When triple backtick bloc code is prefix with tabs or spaces, the parser does not recognize text as a block code.

Not parsed:

   \```typescript
   const a = 'hello';
   \```

A concret use case, is when code block is under a list.
Example of markdown string to be loaded to lexical:

1. First step
   \```bash
   echo "hello"
   \```
2. Second step
   \```bash
   echo "world"
   \```

Note: \ is only there to escape code block rendering. The real use case does not have the \

Solution

Change CODE Transformer & MarkdownImport regex to accept tabs or spaces in prefix.

Current regex

image

Updated regex

image

Copy link

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2024 2:10pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2024 2:10pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 29, 2024
Copy link
Contributor

@acywatson acywatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK. Thanks for the PR.

I will ask @fantactuka to take a look and merge if he has no concerns.

@samuelint
Copy link
Contributor Author

Any update @acywatson @fantactuka, can this MR be merged?

@StyleT
Copy link
Contributor

StyleT commented Apr 23, 2024

Merging this as apparently it got stuck :P

@StyleT StyleT merged commit 4a318ee into facebook:main Apr 23, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants