Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remark replaces double trailing spaces (simple line break) with a backslash #249

Closed
ChrisRast opened this issue Apr 21, 2017 · 4 comments
Closed

Comments

@ChrisRast
Copy link

Hello,
I use remark with remark-cli as a way to parse and correct my markdown files through a npm script.
The script in question simply runs remark {dir} -oq --rc-path {somePath}.

The .remarkrc file contains this:

{
	"plugins": [
		"remark-preset-lint-recommended",
		"remark-preset-lint-consistent",
		["remark-lint-list-item-content-indent", false]
	]
}

My issue is when I parse a .md file with double space as line-break, it adds a backslash \ instead.

Original file

Some text with a double space at the end.{space}{space}
Another line but not a clear new paragraph.

Is parsed to

Some text with a double space at the end.\
Another line but not a new paragraph.

For now, the only way to reproduce that outside the cli, is to use atom-beautify and in the Markdown beautification, tick the "Commonmark" option.

Any idea why this happens, and how to avoid it?

Thank you.

@wooorm
Copy link
Member

wooorm commented Apr 21, 2017

That’s because to invisible spaces at the end of a line is a pretty bad design decision, and common mark came with a fix! If you end a line with a slash, it does the same.

So, if you specify that you want to use common mark, it’ll use the smarter, commonmark-compliant way.

Why would you want commonmark if you don’t want commonmark output? :)

@ChrisRast
Copy link
Author

Okay, let's say that I decide to use the trailing backslash.

The other issue is that if I reparse the file, the code

Some text with a double space at the end.\
Another line but not a new paragraph.

becomes

Some text with a double space at the end.\\
Another line but not a new paragraph.

All I did was to run my script again, with the same parameters.

@wooorm
Copy link
Member

wooorm commented Apr 22, 2017

Weird, I don’t this either. Maybe this is related to #250?

@wooorm
Copy link
Member

wooorm commented Apr 24, 2017

In this example, commonmark-mode is not on, so, if you remove the solidus and use two spaces, the output won’t be changed.

In this non-commonmark-mode, if you use one slash, it’ll escape it (which doesn’t affect markdown). Note that if you run lint-md multiple times, no more slashes are added.

If you’d add the following to your .remarkrc:

    "settings": {
      "commonmark": true
    }

...and use one slash, it won’t change the amount of slashes.
And if you’d use two spaces then it’d transform it to a single slash.

Oh and finally, a) if you have a .remarkrc file, you don’t need to specify it: you can drop the --rc-path ./.remarkrc, and b) you don‘t need to install remark if you’re using remark-cli!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants