id | title | sidebar_label |
---|---|---|
highlight-test |
Advanced Highlighting |
Highlighting |
:::note
Assumes you are using @docusaurus-preset-classic
.
:::
// You can highlight js using comments
const myFunction = () => {
// highlight-next-line
return 100;
};
// highlight-start
const myOtherFunction = () => {
return 101;
};
// highlight-end
export { myFunction, myOtherFunction };
// or jsx
const myComponent = () => {
return <div>
{ /* highlight-next-line */ }
<p>Highlighted</p>
<p>Not Highlighted</p>
{ /* highlight-start */ }
<div>
<p>All highlighted!</p>
</div>
{ /* highlight-end */ }
</div>
}
Why *not* highlight **Markdown**?
// highlight-next-line
*highlighted*
not highlighted
// highlight-start
> ALL OF
> THIS IS
> HIGHLIGHTED
// highlight-end
You can highlight plaintext too
// highlight-next-line
single line
not highlighted
// highlight-start
line range
all
highlighted
// highlight-end
but not this
# python (and hopefully any other language) works too!
# highlight-next-line
print('Hello!')
print('World.')
# highlight-start
def hello_world():
print('Hello world!')
# highlight-end
hello_world()