mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-09 06:12:28 +02:00
docs(v2): code block line highlighting (#1904)
* docs(v2): code block line highlighting * misc: update CHANGELOG * misc: respond to review * docs: add line highlighting to the template
This commit is contained in:
parent
7714afb00f
commit
f635f9aba2
20 changed files with 166 additions and 69 deletions
|
@ -31,6 +31,7 @@ export default ({children, className: languageClassName, metastring}) => {
|
|||
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
|
||||
highlightLines = rangeParser.parse(highlightLinesRange).filter(n => n > 0);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let clipboard;
|
||||
|
||||
|
@ -73,7 +74,7 @@ export default ({children, className: languageClassName, metastring}) => {
|
|||
const lineProps = getLineProps({line, key: i});
|
||||
|
||||
if (highlightLines.includes(i + 1)) {
|
||||
lineProps.className = `${lineProps.className} highlight-line`;
|
||||
lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue