shurcooL-legacy / atom-markdown-format

Formats your Markdown text on save.

Home Page:https://atom.io/packages/markdown-format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect formatting when the text is saved.

wf9a5m75 opened this issue · comments

Hi, this plugin is useful except the plugin breaks the format everything.

When I save the text file using [ctrl] + [s], this plugin formats the text file incorrectly.

https://www.youtube.com/watch?v=XOBZAXgdbII

Hi, can you please copy and paste the problematic sample input Markdown into a gist and share here?

https://gist.github.com/

That way I can test it and see what the issue is.

Here is the example text:
https://gist.github.com/wf9a5m75/6131319cbd44417d4f5a

I reinstalled Atom, and only installed your plugin.
The problem occurs the file extension is *.md and the text includes two-bytes characters.
The file encode is UTF-8.

https://www.youtube.com/watch?v=qCZfGJSHpnU

Here is the example text:
https://gist.github.com/wf9a5m75/6131319cbd44417d4f5a

The problem seems to be that you're not including a blank line between blocks. Markdown Format needs it.

See https://gist.github.com/shurcooL/2fe290f4fe804ec2fae9 for a fixed version (diff can be seen here), which gets formatted better (it doesn't change the rendered HTML result).

Github works without a blank line between blocks.

Yes, it does. I had to make a decision about how to handle "hard line" breaks, and I went with making blank lines between paragraphs/blocks mandatory, unlike GitHub's more flexible rules.

The reason is the following. Markdown Format tries to fix formatting, and a part of that is to remove unneeded whitespace between words. For example, if you have two spaces by accident between two words, Markdown Format fixes that:

This is a  sentence with two spaces by accident.

Becomes:

This is a sentence with two spaces by accident.

It also joins a paragraph that was split up into multiple lines into a single paragraph, so:

This is
a paragraph
that will
 become a single line.

Becomes:

This is a paragraph that will become a single line.

That's why it thinks the line entry belongs as part of the previous sentence if you don't include an empty line break.

I suggest you either use a blank line to separate paragraphs and blocks, or avoid using Markdown Format. Its formatting is a certain way, and if you don't like it, unfortunately it's not customizable.

I see. How about insert a break line? That's normal formatter role (I
think).

On Mon, Mar 9, 2015, 10:02 PM Dmitri Shuralyov notifications@github.com
wrote:

Yes, it does. I had to make a decision about how to handle "hard line"
breaks, and I went with making blank lines between paragraphs/blocks
mandatory.

The reason is the following. Markdown Format tries to fix formatting, and
a part of that is to remove unneeded whitespace between words. For example,
if you have two spaces by accident between two words, Markdown Format fixes
that:

This is a sentence with two spaces by accident.

It also joins a paragraph that was split up into multiple lines into a
single paragraph, so:

This is
a paragraph
that will
become a single line.

Becomes:

This is a paragraph that will become a single line.

That's why it thinks the line entry belongs as part of the previous
sentence if you don't include an empty line break.

I suggest you either use a blank line to separate paragraphs and blocks,
or avoid using Markdown Format. Its formatting is a certain way, and if you
don't like it, unfortunately it's not customizable.


Reply to this email directly or view it on GitHub
#16 (comment)
.

One of the design goals is to convert paragraphs with manually added newlines, such as,

This is
a paragraph
that will
 become a single line
- even if it has a dash in it
-
see how this might also be interpreted as a header underline if a newline were inserted.

Into paragraphs without newlines (to be wrapped automatically via word-wrap of your editor):

This is a paragraph that will become a single line - even if it has a dash in it - see how this might also be interpreted as a header underline if a newline were inserted.

Because of that, inserting break lines is not really an option.

Ok, this is your plugin. You can choose the final answer.
Thanks for your help :)

No problem, thanks for reporting issue and sorry I couldn't help more.