Feature: optionally display line numbers in code blocks #799
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.
📚 Context
The docs can sometimes contain long code blocks. Authors may want to reference specific lines of the code block in preceding or subsequent paragraph text. Doing so without displayed line numbers can be challenging. To that end, this PR introduces a feature to optionally include line numbers in code blocks using the prism line numbers plugin. There are two ways to do:
showLineNumbers
to the right of ```python. E.g.<Code>
component, set the propshowLineNumbers={true}
. E.g.Since we use code blocks in many places in our docs, and some places where we might not want line numbers (API cards), line numbers are turned off by default.
🧠 Description of Changes
showLineNumbers
prop to code.js that, if set by the author, shows line numbers in the<pre>
preceding the<code>
styles/text.scss
to hide the vertical border to the right of line numbersRevised:
Current:
💥 Impact
Size:
🌐 References
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.