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

Added collapseMultipleWhitespaces option #362

Closed
wants to merge 1 commit into from
Closed

Added collapseMultipleWhitespaces option #362

wants to merge 1 commit into from

Conversation

eliascotto
Copy link

Added an option collapseMultipleWhitespaces to replace series of multiple whitespaces with a single one, if true. Otherwise do that only for leading and trailing.

See #361

@martincizek
Copy link
Collaborator

martincizek commented Jan 22, 2021

With the option turned on, the conversion would become broken. There can be arbitrary sequences of whitespace anywhere in the original HTML. Even though you trim leading and trailing WS runs, the whitespace inside of the text can introduce e.g. paragraphs or indented code blocks that are not present in the original HTML.

Also, mixing ASCII and non-ASCII whitespace differs between HTML and Markdown - see the specs and it would have consequences in escaping rules.

What Turndown tries to do, is to convert the whitespace to the best semantic equivalent. Preserving the insignificant white space from HTML syntax is not completely possible by design. And even though there can be some partial preserving some whitespace, I currently think it's not worth it.

You can check the complexity of dealing with significant whitespace translation, which is currently done for:

I suggest to better describe the need of preserving insignificant WS in the related ticket. Based on that, we should decide whether to rework or close this PR. Thanks.

@eliascotto eliascotto closed this Jan 24, 2021
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

Successfully merging this pull request may close these issues.

2 participants