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

Whitespace after newline #117

Closed
sbrugman opened this issue Jul 25, 2019 · 4 comments

Comments

@sbrugman
Copy link

@sbrugman sbrugman commented Jul 25, 2019

There is an annoying issue when saving the HTML version of argdown: there is no whitespace between sentences that are spread over multiple lines.

Example:

This is sentence 1.
Sentence 2 is longer.

Results in:

This is sentence 1.Sentence 2 is longer.
@christianvoigt christianvoigt added the bug label Jul 29, 2019
@christianvoigt

This comment has been minimized.

Copy link
Owner

@christianvoigt christianvoigt commented Sep 25, 2019

Sorry for taking so long to putting some thought into this.

Yes, at the moment "non-semantic" line breaks (that are not used to start a new Argdown block) are simply ignored by the parser (similar to comments). That also means that empty spaces added before non-semantic line breaks will be preserved. You should simply treat non-semantic line breaks as a purely "cosmetic" way to make your Argdown code look better without any effect on the real text data that will be parsed and exported. Normally, I first write each paragraph of text without any line break and then insert line breaks afterwards without deleting any whitespace to format my Argdown document.

In your example, you can insert a whitespace after the first line (This is sentence 1. ) and it will appear in the HTML and the map views.

The alternative would be to parse non-semantic line breaks as "empty space"-tokens, but this would make the parser more complicated and might be annoying to other users that do not expect it. To make this less surprising the parser could check if there already is a preceding whitespace and only replace a linebreak with a new whitespace token if not. At the moment I am not convinced that such a complicated solution is really necessary, though. Maybe it would be enough to emphasize the cosmetic role of non-semantic line breaks in the documentation.

@christianvoigt christianvoigt added feature request and removed bug labels Sep 25, 2019
@sbrugman

This comment has been minimized.

Copy link
Author

@sbrugman sbrugman commented Sep 25, 2019

Thank you for your reply.

The current behaviour is clear, new lines in a paragraph are allowed for code readibility and are ignored in the rendering process.

There are a few points in there where I would like to share my thoughts. These are best seen as personal user feedback, I do not claim a general case here. My main assumption is your vision with respect to formatting to be along the lines that argdown should provide desired formatting with the least user effort, so that users can focus on their argumentation. The current behaviour is inconsistent with that vision.

The alternative would be to parse non-semantic line breaks as "empty space"-tokens, but this would make the parser more complicated and might be annoying to other users that do not expect it.

I would argue that users get their expectation from markdown, which treats in-paragraph new lines as spaces, or from tinkering with the editor (and learn quick enough).

Normally, I first write each paragraph of text without any line break and then insert line breaks afterwards without deleting any whitespace to format my Argdown document.

I can image this works for some users, however others (including me) like to have more overview. The current workflow introduces unnecessary manual labour in that case. By introducing this feature, both workflows can be used effectively.

This issue is related to #109 in the sense that in both cases argdown deviated from markdown. Would there be a simple way to support non-conflicting markdown syntax by default?

@christianvoigt

This comment has been minimized.

Copy link
Owner

@christianvoigt christianvoigt commented Sep 25, 2019

Thanks for your feedback. I had the behaviour of HTML code in mind, but you are right that line breaks are treated differently by Markdown parsers, so maybe Argdown should do so as well.

I will have to think this through before I make a decision, but I see your point.

There is no easy way to support non-conflicting Markdown syntax by default, it has to be implemented as part of the Argdown lexer/parser structure and in some cases this is more difficult than it might seem at first glance (for example look at #118), especially because Argdown is written as a LL(k) grammar parser and not (like most Markdown parsers) only based on regular expressions. I still think this was a good decision in general, but it makes it difficult to mimic Markdown parsers in every detail.

@christianvoigt

This comment has been minimized.

Copy link
Owner

@christianvoigt christianvoigt commented Oct 21, 2019

This took a lot longer than I hoped, as all the new Newline tokens invalidated a lot of my tests and I had to check which ones I could simply rewrite and which ones where pointing to real issues. It should work now as advertised, thanks again for bringing this up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.