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

Highlight empty lines without breaking line numbering or hiding them #18719

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/gatsby-remark-prismjs/src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ module.exports = function highlightLineRange(code, highlights = []) {
})
.map(line => {
if (line.highlight) {
line.code = highlightWrap(line.code)
line.code
Copy link
Contributor

Choose a reason for hiding this comment

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

better check for empty string or null? Otherwise a line with number 0 and text false would be also exchanged?

Copy link
Author

@ethernal ethernal Oct 20, 2019

Choose a reason for hiding this comment

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

I checked what you suggested and lines where only word to highlight is "false" (without quotes or 0 are highlighted with no issues.

PS. @muescha is there a way to get rid of prettier complains in build errors? I am editing this in the browser.

Copy link
Author

Choose a reason for hiding this comment

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

Snapshot tests are failing as I am injecting non breakable space into empty lines ( ) so these tests should just get the snapshots updated.

? (line.code = highlightWrap(line.code))
: (line.code = highlightWrap(" "))
}
return line
})
Expand Down