decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.81k stars 3.04k forks source link

Force an empty line before code blocks in the markdown widget #944

Closed erquhart closed 1 year ago

erquhart commented 6 years ago

- Do you want to request a feature or report a bug?

feature

- What is the current behavior?

If a code block is authored without a blank line before, it's valid markdown, but some parsers won't recognize the code block. This can lead to some pretty uncool things, like example scripts being run on the published page unexpectedly.

- What is the expected behavior?

The CMS should ensure there's at least one blank line before each code block (unless it's the first child)

- Please mention your CMS, node.js, and operating system version.

CMS 1.0.3

verythorough commented 6 years ago

I'd also like to add to this that when a code block is included in another block like a list item (super common in docs! ;) ), it generally needs to get one more indentation than the rich text converter is currently giving it.

Here's a diff snippet of a working file that was auto-formatted by the CMS, caused by a rich-text edit elsewhere in the file: screen shot 2018-01-23 at 3 09 42 pm

It breaks the code block and all subsequent list item numbering. (This build is in Hugo.)

screen shot 2018-01-23 at 3 13 32 pm

Adding the extra line will fix the code block, but without the extra indent, the block will not be indented under its parent, and the list item numbering will often break because generators interpret the markdown to indicate two separate ordered lists.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

martinjagodic commented 1 year ago

Closing as stale and/or outdated.