dendron icon indicating copy to clipboard operation
dendron copied to clipboard

Parse backslash '\' as hard line break

Open reneverschoor opened this issue 3 years ago • 1 comments

Please select if your request is either something new or an enhancement

  • [x] Enhancement of an existing Feature.
  • [ ] Request of a new feature.

Please select the area your request applies to. (Multiple selections are Possible. You can leave blank if you're not sure.)

  • [ ] Workspace - VSCode workspace, vaults, Intellisense/autocomplete, Dendron settings
  • [ ] Lookup - Dendron's Lookup Command
  • [ ] Views - Dendron Preview, Tree View, Side Panels in the UI
  • [ ] Schema - Dendron Schemas
  • [ ] Pod - Data import from / export to Dendron
  • [ ] Publish - External Site Publish
  • [x] Markdown - Markdown features, such as syntax support and features

Is your feature request related to a problem? Please describe

The original Markdown implementation uses two or more spaces at the end of a line to indicate a hard line break.
See e.g. https://www.markdownguide.org/basic-syntax/#line-breaks.
This was met with criticism:

  • Editors can remove trailing spaces
  • Spaces are not visible to the human writer

Many Markdown parsers therefore started supporting the backslash \ character to denote a hard line break.
This issue is proof of that, I've used backslashes in this text ;)

In the Dendron wiki is a section Compatibility with CommonMark:

CommonMark is a strongly defined, highly compatible specification of Markdown. When possible, Dendron will try to stay to CommonMark spec for syntax.

The CommonMark spec states:

  • 6.7 Hard line breaks

For a more visible alternative, a backslash before the line ending may be used instead of two or more spaces

Interestingly it also has:

  • 6.8 Soft line breaks

A renderer may also provide an option to render soft line breaks as hard line breaks

This relates to Add option to create Line Break on single Carriage Return · Issue #1604 · dendronhq/dendron · GitHub

Describe the solution you'd like

Have the Dendron Markdown parser interpret the backslash at the end of a line as a hard line break.
Ideally, make it configurable where you can select one or more of the following options:

  • Legacy: interpret two or more space at the end of a line as a hard line break
  • CommonMark: interpret a backslash at the end of a line as a hard line break
  • Plain: interpret a line end as a hard line break

Describe alternatives you've considered

Other Dendron-like apps.

Additional context

In my personal- and work-life I've made many notes.
I used to do this in wikis and plain text files.
Most of my notes are made up of short lines.

When Markdown was introduced, I liked it because it would be an improvement over plain text notes.
I did not adopt it though, I hated the need for two spaces to get a line break.

After a few years I had to adopt Markdown, as a lot of my tools switched to it.
Having to use a \ to get the text the way I want it is still suboptimal, but way better that having to use spaces.

I've been using Dendron for quite some time now, but am still on the fence if I should totally convert to it.
The notes I make or copy from/to other systems all use \, but things like preview and publishing fail for me.

reneverschoor avatar Jul 17 '22 15:07 reneverschoor

Thank you for the suggestion.

Internally we use remark, and is commonmark / gfm compliant so I am wondering why the hard line break isn't working as remark should support it out of the box.

We'll track this and let you know if any work gets done on this.

hikchoi avatar Jul 18 '22 01:07 hikchoi