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

plaintext does not render empty lines (\n line breaks) #157

Closed
ben519 opened this issue Jan 16, 2024 · 2 comments · Fixed by #158
Closed

plaintext does not render empty lines (\n line breaks) #157

ben519 opened this issue Jan 16, 2024 · 2 comments · Fixed by #158
Labels
bug Something isn't working

Comments

@ben519
Copy link

ben519 commented Jan 16, 2024

When I set the language to plaintext, it loses formatting and copy-paste'ability regarding empty lines. For example,

```plaintext
Hello

World
```

becomes

```plaintext
Hello
World
```

(Same thing happens when I set defaultLang: "plaintext")


@atomiks I'd like to sponsor you if you're open to it. Appreciate the hard work you put into this package!

@atomiks
Copy link
Collaborator

atomiks commented Jan 16, 2024

Yeah this is due to the display: grid option.

That's what this part fixes, which you saw in the other issue:

onVisitLine(node: { children: string | any[] }) {
  // Prevent lines from collapsing in `display: grid` mode, and allow empty
  // lines to be copy/pasted
  if (node.children.length === 0) {
    node.children = [{ type: "text", value: " " }]
  }
},

This is done internally for the grid: true option, but I think it's skipped for plaintext language, since it returns early to avoid highlighting...


btw, thank you for the offer, but I don't have a GitHub Sponsor page set up

@ben519
Copy link
Author

ben519 commented Jan 16, 2024

Thanks for the quick patch! If you set up a sponsor page, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants