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

Desktop: Fixes #8530: Rich text editor: Use fewer  s in markdown while still preserving initial paragraph indentation #8529

Merged

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Jul 21, 2023

Summary

This partially reverts a change made in #8468. This should fix #8530.

Before #8468, turndown replaced HTML nonbreaking spaces with their corresponding unicode characters. After, turndown replaced nonbreaking spaces with the HTML escape  .

While this fixes an issue where leading spaces would disappear from paragraph blocks when switching notes, it makes markdown much more difficult to read. For example,

    This is a test. 

instead of

    This is a test. 

(some of the above spaces are nonbreaking).

This pull request mostly reverts this change by only replacing the first nonbreaking space with an HTML escape sequence:

    This is a test. 

When rendered, this preserves the leading indentation while minimizing HTML-escaped  s.

(A leading HTML-escaped   seems to be necessary to preserve indentation).

Testing

This pull request does have an automated test. However, it can be tested manually. To do so,

  1. Open the rich text editor.
  2. Create a new paragraph with leading spaces (e.g. this is a test).
  3. Switch to the markdown editor
  4. Switch back to the rich text editor

In step 3, the markdown should only have a single   ­— the leading space. In step 4, the paragraph should still have leading spaces.

Comment on lines -225 to -227
replaceNonbreakingSpaces(whitespace.leading) +
replaceNonbreakingSpaces(rule.replacement(content, node, this.options)) +
replaceNonbreakingSpaces(whitespace.trailing)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaceNonbreakingSpaces was not present in upstream turndown and was added by #8468. It is no longer used and has thus been removed.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Rich text editor: Use fewer  s in markdown while still preserving initial paragraph indentation Desktop: Fixes #8530: Rich text editor: Use fewer  s in markdown while still preserving initial paragraph indentation Jul 21, 2023
@laurent22 laurent22 merged commit e47985c into laurent22:dev Jul 23, 2023
10 checks passed
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.

Desktop: Rich text editor produces a large number of  s in markdown
2 participants