-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby-remark-prismjs): prevent additional blank line from appearing #10209
fix(gatsby-remark-prismjs): prevent additional blank line from appearing #10209
Conversation
"<span class=\\"gatsby-highlight-code-line\\"> return \\"hello world\\" | ||
</span>" | ||
`; | ||
exports[`highlighting a line range highlight-line highlights line 1`] = `"<span class=\\"gatsby-highlight-code-line\\"> return \\"hello world\\"</span>"`; |
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.
These diffs are a little messy, but it just removes the hard line breaks from the diffs. This will be handled via HTML start/end tags anyways, so this should be just fine.
@@ -47,7 +47,7 @@ const stripComment = line => | |||
) | |||
|
|||
const wrap = line => | |||
[`<span class="gatsby-highlight-code-line">`, `${line}\n`, `</span>`].join(``) | |||
[`<span class="gatsby-highlight-code-line">`, `${line}`, `</span>`].join(``) |
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.
The fix. One character 🆗
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.
🙏 Thanks @DSchau!
…ing (gatsbyjs#10209) * fix(gatsby-remark-prismjs): prevent additional blank line from appearing * chore: don't use template literals; not needed * test: update snapshots
This PR fixes a small bug where an extra line character is rendered as the generated HTML contains a structure like
</span>\n</span>
. This new line character causes a blank line to be inserted into the resultant highlighted code.I've validated that this doesn't seem to cause any regressions with the kitchen sink.
Changes in this PR
Published version