# Why does markdown do this? (whitespace trimming and other features)

**URL:** <https://meta.discourse.org/t/why-does-markdown-do-this-whitespace-trimming-and-other-features/279437>\
**Category:** Development\
**Tags:** markdown\
**Created:** [September 18, 2023, 8:34pm UTC](https://meta.discourse.org/t/why-does-markdown-do-this-whitespace-trimming-and-other-features/279437 "2023-09-18T20:34:06Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Rhababo](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Rhababo](https://meta.discourse.org/u/Rhababo)\
**Post date:** [September 18, 2023, 8:34pm UTC](https://meta.discourse.org/t/why-does-markdown-do-this-whitespace-trimming-and-other-features/279437/1 "2023-09-18T20:34:06Z")

</div>

Apologies for the vague title,

I’m in the process of modifying some of the functionality with markdown on discourse to better suit the needs of my community which is coming over from a mybb forum.

Discourse is my first exposure to markdown, and I want to take the approach of “don’t tear down a fence if you don’t know why it’s there.” However, I am having difficulty finding out why markdown takes certain actions and I would love some resources to help me understand, (especially if there are some security concerns I could be overlooking).

The response in this topic provided some good general references including some early discussion and a (now defunct) plugin:

> [@Rich Text Formatting (WYSIWYG)](https://meta.discourse.org/t/rich-text-formatting-wysiwyg/148687):
>
> Hi all, The users of my Discourse community are sports teachers who are not very technical, therefore the enforced use of markdown in the editor has created some formatting problems in posts. Ideally, we could enable a rich text WYSIWYG editor to make posting as simple and familiar as possible. Are there any ways to enable this or, if not, plans for inclusion on the roadmap? Cheers

And this post has been incredibly helpful on the development side of things:

> [@Developer's guide to Markdown extensions](https://meta.discourse.org/t/developers-guide-to-markdown-extensions/66023):
>
> Discourse uses a Markdown engine called [Markdown-it](https://github.com/markdown-it/markdown-it). Here are some dev notes that will help you either fix bugs in core or create your new plugins. The Basics Discourse only contains a few helpers on top of the engine, so the vast majority of learning that needs to be done, is understanding Markdown It. The [docs directory](https://github.com/markdown-it/markdown-it/tree/master/docs) contains the current documentation. I strongly recommend reading: The [architecture document](https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md) to understand at a top level how the engine works. [Development](https://github.com/markdown-it/markdown-it/blob/master/docs/development.md) for basic d…

But, again, I’m looking to understand why certain features exist - so i can best evaluate removing or tweaking them.

The current features in my crosshairs are:

1. Removing consecutive line breaks without `</br>` or other code.
2. Automatic creation of code blocks on lines with 4 or more leading spaces.
3. Trimming leading whitespace on a new line.
4. Turning any sequence of numbers into a numbered list in consecutive increasing order.

Any guidance is appreciated! Thanks!

---

_[View the full topic](https://meta.discourse.org/t/why-does-markdown-do-this-whitespace-trimming-and-other-features/279437)._
