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

Don't strip non-breaking whitespace when reformatting (e.g. for Pandoc output) #1

Open
mbroedl opened this issue Jun 15, 2018 · 6 comments

Comments

@mbroedl
Copy link

mbroedl commented Jun 15, 2018

I would like to preserve trailing whitespace in my table to create a list-like feel.
I thought maybe non-breaking whitespaces might be preserved, but I assume they fall victim to the trimLeft command here:
https://github.com/susisu/mte-kernel/blob/master/lib/table-cell.js#L22

Would it be possible to preserve trailing non-breaking whitespaces?

@susisu
Copy link
Owner

susisu commented Jun 15, 2018

Thank you for reaching out, but I could not get the point.

"Trailing whitespace" you mean is (1) right padding of cells, or (2) right margin of rows?

| ABC     | DEF |   
| ------- | --- |
| abc     | def |
      ^^^         ^^^
      (1)         (2)

And can you describe more detail what behavior you expect?

@mbroedl
Copy link
Author

mbroedl commented Jun 15, 2018

Oh, sorry, it looks like I confused the words leading with trailing, sorry.

What I would like to do:

| ABC | DEF   |
| --- | ----- |
| ABC | DEF   |
|     |   HIJ |
        ^^

but reformatting leads to

| ABC | DEF |
| --- | --- |
| ABC | DEF | 
|     | HIJ |

regardless of whether the spaces are breaking or non-breaking.
(Which seems to be expected looking at the spec of the javascript trim function.)

Compiled with Pandoc to PDF this looks like this with normal spaces (that are stripped when reformatted)
image
and like this with non-breaking spaces (that are also stripped when reformatted)
image

I was hoping there is a way that spaces could be preserved if they are non-breaking but not when they are breaking.
Maybe the same could go for trailing spaces when items are right-aligned (and both sides if they are centered?).
If you are hesitant, maybe one could only keep them if there are two or more to assert intentionality?

Thanks for your quick reply!

PS. I use your plug-in in atom, which I really really enjoy!

@susisu
Copy link
Owner

susisu commented Jun 16, 2018

Oh, I see. Thank you for explaining.

I checked that both leading and trailing non-breaking spaces (U+00A0) are kept by Pandoc, while they are all stripped by marked and markdown-it (used by markdown-preview and markdown-preview-plus packages of Atom).
Maybe I should add an option to keep or strip them.

FYI, an HTML escape sequence   can be used for non-breaking spaces, which is a bit verbose but less confusing.

@mbroedl
Copy link
Author

mbroedl commented Jun 16, 2018

Thanks for the note on   I totally forgot about that option. It certainly does not look as nice in the formatting, but should suffice for now!
I would welcome an option to keep non-breaking spaces (not sure about half-width non-breaking spaces); at least on my keyboard there is virtually no chance I would ever make these accidentally.

Do you think I should file an issue at marked and markdown-it, as well? (I hardly ever use them though, because I enjoy monospace prose too much, haha.)

@mbroedl mbroedl changed the title Don't strip trailing non-breaking whitespace when reformatting Don't strip non-breaking whitespace when reformatting (e.g. for Pandoc output) Jun 16, 2018
@susisu
Copy link
Owner

susisu commented Jun 17, 2018

I think you should not unless you really want them to keep NBSPs!
There are no well-accepted Markdown spec and thus we have ultimately no answer which is better.

The option will be added in the next version.

@mbroedl
Copy link
Author

mbroedl commented Jun 17, 2018

Thanks a lot, I'm looking forward to the next version! :)

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

No branches or pull requests

2 participants