-
Notifications
You must be signed in to change notification settings - Fork 48
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
New AccessKit feature: Remove unusual spacing #1171
Draft
marcustyphoon
wants to merge
14
commits into
AprilSylph:master
Choose a base branch
from
marcustyphoon:remove-unusual-spacing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
New AccessKit feature: Remove unusual spacing #1171
marcustyphoon
wants to merge
14
commits into
AprilSylph:master
from
marcustyphoon:remove-unusual-spacing
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
does not work on span-wrapped elements at the moment
This reverts commit 7020d36.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
"This should be easy," I say, immediately before spending 6 hours on a still only partially working draft.
Interesting decisions include:
white-space: pre-line
, which handles a lot of the whitespace collapsing for you but removes leading indentation, or try to go without it and correctly manually parse e.g.hello <strong> world</strong>
(simple regex will not see two spaces between hello and world there)Description
This adds an AccessKit feature that renders posts (and content in the trail in the post editor) as if they did not have multiple consecutive spaces. Artificially increasing spacing between words using is a formatting style used by a subset of the roleplay community, and many find it difficult to read.
To perform this manipulation safely and reversibly, this code clones
textBlock
elements that contain multiple spaces between words, leaving the real DOM elements hidden via CSS and untouched. It traverses its cloned nodes and replaces unusual space characters like 
in each text node with regular spaces (per MDN,white-space
only collapses regular space and regular tab characters). This is preferable over settinginnerHTML
for security reasons.This also implements a control button on posts it affects, allowing the user to toggle between viewing the original and adjusted formatting. Sadly, this problem is complicated enough that I don't think it's feasible to fix every edge case and just present a perfect view (indentation via leading whitespace gets removed by the implementation as of writing this, for example).
Testing steps