fletcher / MultiMarkdown-4

This project is now deprecated. Please use MultiMarkdown-6 instead!
https://github.com/fletcher/MultiMarkdown-5
Other
307 stars 59 forks source link

Added support for escaped line breaks. #47

Closed njmsdk closed 10 years ago

njmsdk commented 10 years ago

Hi, I have added support for escaped line breaks, i.e. a backslash followed by a newline is also a hard line break.

This is useful with editors that automatically strip trailing spaces.

fletcher commented 10 years ago

Let me think about this one. It seems like it would be ok, but want to make sure I'm not missing something.

PS> Thanks for including the code to ignore this in compatibility mode!

njmsdk commented 10 years ago

No problem. Alternatively of you feel it would be safer, it could be implemented as an optional feature switched on using a command line flag such as --escaped-line-breaks.

njmsdk commented 10 years ago

I have implemented the --enable-line-breaks flag to turn on this syntax extension.

fletcher commented 10 years ago

I tweaked the code so that an escaped newline is treated as a regular newline if "--escaped-line-breaks" is not enabled.

Thanks for the code submission!

rolleric commented 10 years ago

Sorry, but I have to point out that this notation is counter-intuitive.

Not sure if know about this, but a backslash at the end of a line, e.g. in UNIX shell scripts, is widely accepted to achieve the exact opposite, namely to ignore the newline character, and to indicate that the command/line/paragraph continues as if everything was on the same line.

I would think it should be better to use an explicit "\n" or have some notation at the beginning of the next line. Why not something like:

This is a line.\n
This is a new line.
\nThis is also a new line.
fletcher commented 10 years ago

"\n" isn't a good option as it isn't really in the style of Markdown's low markup approach.

I'm honestly not too worried about it, as I suspect that njmsdk may be the only person who will use this feature. But perhaps I'm wrong, and we can come up with another syntax.

And since the default behavior is that this current syntax degrades to a regular line break, which in a Markdown document means don't insert a line break, the default is really the same as the Unix behavior. It's only when this particular command-line option is intentionally added by the user that a line break is inserted. One could think about it as a "don't do the regular thing" option, which sort of makes sense.

njmsdk commented 10 years ago

I understand the point, but on the other side the escaped line break syntax is also supported by the pandoc markdown version, and I think we should use a common syntax if possible.

If it becomes a problem we can of course always revert the patch.