-
Notifications
You must be signed in to change notification settings - Fork 5
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
Render neighboring inline tags with no whitespace between them #54
Merged
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
cpsievert
reviewed
Mar 31, 2023
cpsievert
reviewed
Apr 3, 2023
cpsievert
reviewed
Apr 3, 2023
cpsievert
reviewed
Apr 3, 2023
cpsievert
reviewed
Apr 3, 2023
1 task
cpsievert
reviewed
Apr 3, 2023
jcheng5
approved these changes
Apr 3, 2023
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 PR makes the following changes.
Each tag function gets a boolean parameter
_add_ws
, which defaults toFalse
for (normally) inline components like<span>
, andTrue
for (normally) block components like<div>
. The user can call those functions with a different value, because it is possible for CSS to change a component from inline to block and vice versa.If two inline tags (like
<span>
or plain strings), are next to each other, they will be rendered with no whitespace between them:The examples above show what happens if the inline tags are in another inline tag. Note that there's no whitespace between the opening
<span>
tag and the first child.If they are within a block tag like
div
, there will be whitespace between the opening<div>
tag and the first child.If a block tag contains a block tag, each of the block children will be on its own line. If there are multiple inline children in sequence, they will render without whitespace between them.
I have not described the behavior when an inline tag contains a block tag, like
span(div("a"))
. This is because in normal HTML, block tags can contain inline or block tags, but inline tags can only contain inline tags -- inline tags cannot contain block tags.I added many tests for the correct whitespace behavior.
Note: One important change is that when a user writes code like this, no whitespace will be added automatically:
Previously, that would render as:
Now it will render as:
This is a significant change, but it's best to do it now rather than later.