-
Notifications
You must be signed in to change notification settings - Fork 8
fix(inline-props): apply end-of-line attributes to block tokens when inline Markdown present #16
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
Open
kentrpg
wants to merge
5
commits into
comarkdown:main
Choose a base branch
from
kentrpg:fix/15
base: main
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8e5ec86
fix(inline-props): apply end-of-line attributes to block tokens when …
kentrpg 1a19fc4
test(fixtures): update inline-props input and output for block-level …
kentrpg 829eb76
test(fixtures): fix unintended changes in inline-props output
kentrpg 4ccc2c4
Merge branch 'main' into fix/15
antfu 672fbb6
chore: update snap
antfu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| <h1 class="text-red">Hello</h1> | ||
| <p class="text-green text-xl">Hello World</p> | ||
| <p><a href="https://nuxt.com" class="nuxt">Link</a></p> | ||
| <p> | ||
| <p class="text-red"><code>code</code></p> | ||
| <p class="text-red"><strong>bold</strong></p> | ||
| <p class="nuxt"><a href="https://nuxt.com">Link</a></p> | ||
| <p id="nuxt-logo"> | ||
| <img | ||
| src="https://nuxt.com/assets/design-kit/logo/icon-green.svg" | ||
| alt="Nuxt Logo" | ||
| id="nuxt-logo" | ||
| /> | ||
| </p> | ||
| <p><code style="color: red">code</code></p> | ||
| <p><em style="color: blue">italic</em></p> | ||
| <p style="color: red"><code>code</code></p> | ||
| <p style="color: blue"><em>italic</em></p> | ||
| <p><strong style="color: blue">bold</strong>!</p> | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not so sure about this behaviour change, shouldn't the style applied to the
codeandemtag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that! I was testing another (not yet submitted) issue and PR related to inline-props, and accidentally included those output changes in this PR’s tests.
I noticed the mistake and have already reverted the unintended output changes in this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert that and update the snapshot? Thanks
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was a bit nervous sending my first PR to a technical guru!
I've reviewed the logic again:
Since the attribute syntax is placed at the end of the line, the style is now applied to the block-level
<p>tag, not thecodeoremtag.If the attribute syntax needs to apply to the inline-level token instead, I found that adding an empty
{}at the end works without changing any other logic. What do you think about this approach?For example:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just to double-check, should I only revert
test(fixtures): fix unintended changes in inline-props outputthis commit, or do I also need to update the snapshot after reverting? ThanksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally think
{class="nuxt"}{}is a bit counter intutive, as I would expectfoo **bar**{style="color: red"} baz**bar**{style="color: red"}to behave the same, that applying the style to the
belementThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d like to ask for a bit more detail about your expectation.
Are you expecting this behavior only when the attribute syntax sets a style property?
If so, I think I can adjust the condition like this:
The logic here is to check whether the last mdc_inline_props token only has a style attribute.
Other attributes can still be applied to the block-level token.for example,
**bar**{.text-red}would apply the class to thepelement.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply attributes to the parent token only when the content is not purely inline elements.
Below is my attempt at designing the filtering logic with a reverse for loop.
Not sure if this meets your expectation.