-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into bundlesize-compare
- Loading branch information
Showing
51 changed files
with
3,234 additions
and
4,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "2.62.0" | ||
".": "2.63.1" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as cheerio from "cheerio"; | ||
|
||
// Over the years we have accumulated some weird <pre> tags whose | ||
// brush is more or less "junk". | ||
// TODO: Perhaps, if you have a doc with <pre> tags that matches | ||
// this, it should become a flaw. | ||
const IGNORE = new Set(["none", "text", "plain", "unix"]); | ||
|
||
/** | ||
* Mutate the `$` instance by adding headers to <pre> tags containing code blocks. | ||
* | ||
*/ | ||
export function wrapCodeExamples($: cheerio.CheerioAPI) { | ||
// Our content will be like this: `<pre class="brush:js">` or | ||
// `<pre class="brush: js">` so we're technically not looking for an exact | ||
// match. The wildcard would technically match `<pre class="brushetta">` | ||
// too. But within the loop, we do a more careful regex on the class name | ||
// and only proceed if it's something sensible. | ||
$("pre[class*=brush]").each((_, element) => { | ||
// The language is whatever string comes after the `brush(:)` | ||
// portion of the class name. | ||
const $pre = $(element); | ||
|
||
const className = $pre.attr("class").toLowerCase(); | ||
const match = className.match(/brush:?\s*([\w_-]+)/); | ||
if (!match) { | ||
return; | ||
} | ||
const name = match[1].replace("-nolint", ""); | ||
if (IGNORE.has(name)) { | ||
// Seems to exist a couple of these in our docs. Just bail. | ||
return; | ||
} | ||
const code = $pre.text(); | ||
$pre.wrapAll(`<div class='code-example'></div>`); | ||
if (!$pre.hasClass("hidden")) { | ||
$( | ||
`<div class='example-header'><span class="language-name">${name}</span></div>` | ||
).insertBefore($pre); | ||
} | ||
const $code = $("<code>").text(code); | ||
|
||
$pre.empty().append($code); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.