-
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
remark-prismjs: remove extra newline #4804
Conversation
Deploy preview for using-drupal ready! Built with commit 10c389d |
The plugin was adding a newline to the end of code snippets for no good reason. Fixes #4802
const maxCodeSplits = codeSplits.length - 1 | ||
codeSplits.forEach((split, idx) => { | ||
highlightedCode += split.code | ||
if (!split.highlighted && idx < maxCodeSplits) { |
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 don't understand this change — if I'm reading this right, you changed it so that only the last split that's not highlighted has a new line character added?
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.
Isn't the issue just we're adding a code split to InlineCode blocks and we never should do that? Is there some way of detecting if we're highlighting an InlineCode block?
The previous code added newly new lines to all non-highlighted code. It was an attempt to reverse the split on new lines. The problem is it added an extra newline at the end. This fixes it. |
What was wrong with the previous pattern? The bug in #4802 only emerged with the inlinecode highlighting changes. This PR just stops adding back new lines altogether — which could be an acceptable fix. |
Correct. That's because the previous code didn't pass
It doesn't stop all newlines. It prevents an extra newline being added to the end. The previous code did (roughly) this for the no-highlighted-lines case: const codeSplits = highlightedCode.split(`\n`)
highlightedCode = ``
codeSplits.forEach(split => {
highlightedCode += `${split.code}\n`
}) The problem is that this code above adds an additional trailing That trailing |
FYI: The appveyor check is barfing on an image-sharp thing. I don't think I did that. |
Fixed it in #4823 |
Fixes #4802