From 218948d516686f19e12d8d57c8c737e78f9b21e4 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 27 Jul 2022 18:32:26 +0200 Subject: [PATCH] Update top-level await in readmes --- packages/rehype-katex/readme.md | 24 ++++++++----------- packages/rehype-mathjax/readme.md | 16 +++++-------- packages/remark-math/readme.md | 22 +++++++---------- readme.md | 39 ++++++++++++++----------------- 4 files changed, 42 insertions(+), 59 deletions(-) diff --git a/packages/rehype-katex/readme.md b/packages/rehype-katex/readme.md index cfa7ba9..7994f39 100644 --- a/packages/rehype-katex/readme.md +++ b/packages/rehype-katex/readme.md @@ -96,20 +96,16 @@ import rehypeKatex from 'rehype-katex' import rehypeDocument from 'rehype-document' import rehypeStringify from 'rehype-stringify' -main() - -async function main() { - const file = await unified() - .use(rehypeParse, {fragment: true}) - .use(rehypeKatex) - .use(rehypeDocument, { - css: 'https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css' - }) - .use(rehypeStringify) - .process(await read('example.html')) - - console.log(String(file)) -} +const file = await unified() + .use(rehypeParse, {fragment: true}) + .use(rehypeKatex) + .use(rehypeDocument, { + css: 'https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css' + }) + .use(rehypeStringify) + .process(await read('example.html')) + +console.log(String(file)) ``` Now running `node example.js` yields: diff --git a/packages/rehype-mathjax/readme.md b/packages/rehype-mathjax/readme.md index 3673b9e..a607754 100644 --- a/packages/rehype-mathjax/readme.md +++ b/packages/rehype-mathjax/readme.md @@ -95,17 +95,13 @@ import rehypeParse from 'rehype-parse' import rehypeMathjax from 'rehype-mathjax' import rehypeStringify from 'rehype-stringify' -main() - -async function main() { - const file = await unified() - .use(rehypeParse, {fragment: true}) - .use(rehypeMathjax) - .use(rehypeStringify) - .process(await read('example.html')) +const file = await unified() + .use(rehypeParse, {fragment: true}) + .use(rehypeMathjax) + .use(rehypeStringify) + .process(await read('example.html')) - console.log(String(file)) -} +console.log(String(file)) ``` Now running `node example.js` yields: diff --git a/packages/remark-math/readme.md b/packages/remark-math/readme.md index d5f2c9b..3820c1e 100644 --- a/packages/remark-math/readme.md +++ b/packages/remark-math/readme.md @@ -96,19 +96,15 @@ import remarkRehype from 'remark-rehype' import rehypeKatex from 'rehype-katex' import rehypeStringify from 'rehype-stringify' -main() - -async function main() { - const file = await unified() - .use(remarkParse) - .use(remarkMath) - .use(remarkRehype) - .use(rehypeKatex) - .use(rehypeStringify) - .process(await read('example.md')) - - console.log(String(file)) -} +const file = await unified() + .use(remarkParse) + .use(remarkMath) + .use(remarkRehype) + .use(rehypeKatex) + .use(rehypeStringify) + .process(await read('example.md')) + +console.log(String(file)) ``` Now running `node example.js` yields: diff --git a/readme.md b/readme.md index 4cadf53..c765094 100644 --- a/readme.md +++ b/readme.md @@ -81,19 +81,15 @@ import remarkRehype from 'remark-rehype' import rehypeKatex from 'rehype-katex' import rehypeStringify from 'rehype-stringify' -main() - -async function main() { - const file = await unified() - .use(remarkParse) - .use(remarkMath) - .use(remarkRehype) - .use(rehypeKatex) - .use(rehypeStringify) - .process(await read('example.md')) - - console.log(String(file)) -} +const file = await unified() + .use(remarkParse) + .use(remarkMath) + .use(remarkRehype) + .use(rehypeKatex) + .use(rehypeStringify) + .process(await read('example.md')) + +console.log(String(file)) ``` Now running `node example.js` yields: @@ -130,15 +126,14 @@ Take the above KaTeX example and change: +import rehypeMathjax from 'rehype-mathjax' import rehypeStringify from 'rehype-stringify' - main() -@@ -13,7 +13,7 @@ async function main() { - .use(remarkParse) - .use(remarkMath) - .use(remarkRehype) -- .use(rehypeKatex) -+ .use(rehypeMathjax) - .use(rehypeStringify) - .process(await read('example.md')) +@@ -13,7 +13,7 @@ + .use(remarkParse) + .use(remarkMath) + .use(remarkRehype) +- .use(rehypeKatex) ++ .use(rehypeMathjax) + .use(rehypeStringify) + .process(await read('example.md')) ``` Now running `node example.js` yields: