Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Dec 28, 2021
1 parent 821470a commit c248b82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/docusaurus-utils/src/markdownLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default MyComponent;

:::tip prefer comments

Prefer highlighting with comments where you can. This way, highlight is inlined in the code, and if you add/remove lines, you don't have to offset your line ranges. You also don't have to manually count the lines if your code block becomes long.
Prefer highlighting with comments where you can. By inlining highlight in the code, you don't have to manually count the lines if your code block becomes long. If you add/remove lines, you also don't have to offset your line ranges.

````diff
- ```jsx {3}
Expand All @@ -233,6 +233,8 @@ Prefer highlighting with comments where you can. This way, highlight is inlined
```
````
In the future, we may extend the magic comment system and let you define custom directives and their functionalities. The magic comments would only be parsed if a highlight metastring is not present.
:::
## Interactive code editor {#interactive-code-editor}
Expand Down

0 comments on commit c248b82

Please sign in to comment.