pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.09k stars 131 forks source link

[Markdown Preview] Save as HTML and Copy as HTML stopped working with file that has fenced code blocks since Atom 1.32.0 #1044

Open catscarlet opened 1 week ago

catscarlet commented 1 week ago

Thanks in advance for your bug report!

What happened?

This is a good-old-classic bug since 2018. See this: atom/markdown-preview#552

The "Save As HTML" and "Copy As HTML" functionalities in the MarkDown preview doesn't work anymore if your file has a fenced code block.

It seems that the problem began since 2018 v1.32.0 of Atom, and it is still there in Pulsar nowadays.

Pulsar version

1.118.0

Which OS does this happen on?

🐧 Debian based (Linux Mint, Ubuntu, etc.)

OS details

Linux Mint 20.3 (based on Ubuntu 20.04)

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

  1. Open a Markdown file, or create new - the file must have a fenced code block e.g.
      # Hello World
  console.log();
  ```


2. Ctrl + Shift + M to open the Markdown Preview
3. Ctrl + Shift + S to save Save as HTML (or Ctrl + Ins for "Copy As HTML")
4. Save the HTML (or Paste the HTML to somewhere you like)
5. Check the result

### Expected result:
- If you choose Save the HTML, a new HTML file is saved.
- If you choose Copy As HTML, a HTML content will be in/replace clipboard, and you can paste it in anywhere you want.

### Actual result:
- If you choose Save the HTML, nothing will happen. No new save file will be created.
- If you choose Copy As HTML, nothing will be in/replace clipboard, thus nothing expecting will be pasted.

### Additional Information:

This is a very old bug since Atom 1.32.0 and they did nothing about it since 2018.

The OS and the CPU arch do not matter.

You can get all information on atom/markdown-preview#552 
savetheclocktower commented 1 week ago

The underlying problem here is that Pulsar does some magic for each embedded code block in the Markdown. That magic needs to go async. A large Promise.all is set up to aggregate all the promises over the entire file, but some of them never resolve. The ones that don't resolve seem to be the TextMate-style grammars — in my experiments, plain text and CoffeeScript didn't resolve.

(This is a note to my future self.)