atom / markdown-preview

📝 Markdown preview in Atom
MIT License
1.23k stars 357 forks source link

Fix markdown preview HTML file save with fenced code blocks. #567

Closed bdaehlie closed 1 year ago

bdaehlie commented 5 years ago

Description of the Change

Fixes issue #552, which is about markdown preview silently failing to "Save As..." when the markdown contains plain text fenced code blocks.

The patch here simply stops attempting to tokenize plain text fenced code blocks for syntax highlighting. It isn't necessary anyway.

You can read about the development of this patch in this comment:

https://github.com/atom/markdown-preview/issues/552#issuecomment-509915012

This explains the code paths taken, and ultimately what the problem is (an unfulfilled promise when attempting to tokenize plain text).

Alternate Designs

A possible alternative fix might consider why no onDidTokenize callback happens when attempting to tokenize plain text. I don't believe the effects of such a fix would be any different than this patch, as there is no point in attempting to tokenize a plain text block.

Benefits

Issue #552 is fixed. Plain text (no language) fenced code blocks no longer cause file saves to fail.

Possible Drawbacks

None that I'm aware of.

Applicable Issues

Issue 552

rsese commented 5 years ago

Thanks @bdaehlie! The team will need tests to be added before they can review, and tests will also help guard against future changes breaking your work 😄 If you need any help, there are a bunch of helpful community members on the Atom Slack team that should be willing to point you in the right direction.