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

Improve markdown newline export/import #2519

Merged
merged 1 commit into from
Jun 27, 2022
Merged

Improve markdown newline export/import #2519

merged 1 commit into from
Jun 27, 2022

Conversation

fantactuka
Copy link
Contributor

@fantactuka fantactuka commented Jun 26, 2022

Adjustments around how markdown import/export deal with new lines:

  • Export will use \n\n as block separator
  • Import ignores empty paragraphs (but keeps empty quotes, lists, headings)
  • Paragraph content is appended to the previous sibling if it is not empty separated by hard line breaks
  • Multi-line blockquote content is appended

These changes should make our markdown a bit closer to commonmark spec. It still has some differences, e.g. we do not support nested quotes (in general we do not nest quotes in editor) or soft line breaks

input:

Paragraph text
continuation

Another paragraph
- List item
continuation
> Quote line 1
> line 2
continuation

output:

<p>
  Paragraph text<br>
  continuation
</p>
<p>
  Another paragraph
</p>
<ul>
  <li>
    List item<br>
    continuation
  </li>
</ul>
<bloquoute>
  Quote line 1<br>
  line 2<br>
  continuation
</bloquoute>

@vercel
Copy link

vercel bot commented Jun 26, 2022

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

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Jun 27, 2022 at 11:49AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Jun 27, 2022 at 11:49AM (UTC)

@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 Jun 26, 2022
@jearthman
Copy link

jearthman commented Jan 9, 2024

@fantactuka @zurfyx

I think this commit is causing an issue with whitespace being parsed out at the end of the root node's text when using markdown convert functions for two-way data binding. Explanation of my issue here with code snippet.

Specifically this line: const lineTextTrimmed = lineText.trim()

https://discord.com/channels/953974421008293909/1193984435406778388/1193984435406778388

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.

4 participants