mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
docs: recommend highlighting with comments than number range (#6204)
* docs: recommend highlighting with comments than number range * quick fix
This commit is contained in:
parent
73ee356949
commit
4f2330a824
3 changed files with 81 additions and 74 deletions
|
@ -45,9 +45,16 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|||
|
||||
// Replace internal markdown linking (except in fenced blocks).
|
||||
let fencedBlock = false;
|
||||
let lastCodeFence = '';
|
||||
const lines = fileString.split('\n').map((line) => {
|
||||
if (line.trim().startsWith('```')) {
|
||||
fencedBlock = !fencedBlock;
|
||||
if (!fencedBlock) {
|
||||
fencedBlock = true;
|
||||
[lastCodeFence] = line.trim().match(/^`+/)!;
|
||||
// If we are in a ````-fenced block, all ``` would be plain text instead of fences
|
||||
} else if (line.trim().match(/^`+/)![0].length >= lastCodeFence.length) {
|
||||
fencedBlock = false;
|
||||
}
|
||||
}
|
||||
if (fencedBlock) {
|
||||
return line;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue