Skip to content

Commit df0abde

Browse files
kevjinOnur Laru
authored andcommitted
Fix TOC links for HTML code tags (nodejs#234)
* fix: Fix code tags in TOC links * style: Use prettier formatting * style: Code format function titles * fix: Make util function more safe Co-Authored-By: kevjin <[email protected]> * style: Run prettier
1 parent 09117a3 commit df0abde

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/components/toc.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { fixTocCodeTag } from '../util/tocFormatter';
23

34
type Props = {
45
heading: string;
@@ -9,6 +10,7 @@ const TOC = ({ heading, tableOfContents }: Props) => {
910
if (!tableOfContents) {
1011
return null;
1112
}
13+
tableOfContents = fixTocCodeTag(tableOfContents);
1214

1315
return (
1416
<details className="toc">

src/documentation/0032-javascript-timers/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors: flaviocopes, MylesBorins, LaRuaNa, amiller-gh, ahmadawais
55
section: Getting Started
66
---
77

8-
## setTimeout()
8+
## `setTimeout()`
99

1010
When writing JavaScript code, you might want to delay the execution of a function.
1111

@@ -61,7 +61,7 @@ This is especially useful to avoid blocking the CPU on intensive tasks and let o
6161

6262
> Some browsers (IE and Edge) implement a `setImmediate()` method that does this same exact functionality, but it's not standard and [unavailable on other browsers](https://caniuse.com/#feat=setimmediate). But it's a standard function in Node.js.
6363
64-
## setInterval()
64+
## `setInterval()`
6565

6666
`setInterval` is a function similar to `setTimeout`, with a difference: instead of running the callback function once, it will run it forever, at the specific time interval you specify (in milliseconds):
6767

src/documentation/0034-javascript-promises/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ new Promise((resolve, reject) => {
212212

213213
## Orchestrating promises
214214

215-
### Promise.all()
215+
### `Promise.all()`
216216

217217
If you need to synchronize different promises, `Promise.all()` helps you define a list of promises, and execute something when they are all resolved.
218218

@@ -241,7 +241,7 @@ Promise.all([f1, f2]).then(([res1, res2]) => {
241241

242242
You are not limited to using `fetch` of course, **any promise can be used in this fashion**.
243243

244-
### Promise.race()
244+
### `Promise.race()`
245245

246246
`Promise.race()` runs when the first of the promises you pass to it resolves, and it runs the attached callback just once, with the result of the first promise resolved.
247247

src/util/tocFormatter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// See related issue: https://github.com/gatsbyjs/gatsby/issues/8982
2+
export function fixTocCodeTag(tocLinks: string = '') {
3+
const lessThanSignRegex = /&#x3C;/gi;
4+
5+
return tocLinks.replace(lessThanSignRegex, '<');
6+
}

0 commit comments

Comments
 (0)