| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,17 +3,16 @@ import * as fixtures from '../common/fixtures.mjs'; | |||
| 3 | 3 | ||
| 4 | 4 | import assert from 'assert'; | |
| 5 | 5 | import { readFileSync } from 'fs'; | |
| 6 | - import { createRequire } from 'module'; | ||
| 7 | 6 | ||
| 8 | 7 | import * as html from '../../tools/doc/html.mjs'; | |
| 9 | 8 | import { replaceLinks } from '../../tools/doc/markdown.mjs'; | |
| 10 | - | ||
| 11 | - const require = createRequire(new URL('../../tools/doc/', import.meta.url)); | ||
| 12 | - const unified = require('unified'); | ||
| 13 | - const markdown = require('remark-parse'); | ||
| 14 | - const remark2rehype = require('remark-rehype'); | ||
| 15 | - const raw = require('rehype-raw'); | ||
| 16 | - const htmlStringify = require('rehype-stringify'); | ||
| 9 | + import { | ||
| 10 | + rehypeRaw, | ||
| 11 | + rehypeStringify, | ||
| 12 | + remarkParse, | ||
| 13 | + remarkRehype, | ||
| 14 | + unified, | ||
| 15 | + } from '../../tools/doc/deps.mjs'; | ||
| 17 | 16 | ||
| 18 | 17 | // Test links mapper is an object of the following structure: | |
| 19 | 18 | // { | |
@@ -31,14 +30,14 @@ const testLinksMapper = { | |||
| 31 | 30 | function toHTML({ input, filename, nodeVersion, versions }) { | |
| 32 | 31 | const content = unified() | |
| 33 | 32 | .use(replaceLinks, { filename, linksMapper: testLinksMapper }) | |
| 34 | - .use(markdown) | ||
| 33 | + .use(remarkParse) | ||
| 35 | 34 | .use(html.firstHeader) | |
| 36 | 35 | .use(html.preprocessText, { nodeVersion }) | |
| 37 | 36 | .use(html.preprocessElements, { filename }) | |
| 38 | 37 | .use(html.buildToc, { filename, apilinks: {} }) | |
| 39 | - .use(remark2rehype, { allowDangerousHtml: true }) | ||
| 40 | - .use(raw) | ||
| 41 | - .use(htmlStringify) | ||
| 38 | + .use(remarkRehype, { allowDangerousHtml: true }) | ||
| 39 | + .use(rehypeRaw) | ||
| 40 | + .use(rehypeStringify) | ||
| 42 | 41 | .processSync(input); | |
| 43 | 42 | ||
| 44 | 43 | return html.toHTML({ input, content, filename, nodeVersion, versions }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,21 +3,20 @@ import * as fixtures from '../common/fixtures.mjs'; | |||
| 3 | 3 | ||
| 4 | 4 | import assert from 'assert'; | |
| 5 | 5 | import fs from 'fs'; | |
| 6 | - import { createRequire } from 'module'; | ||
| 7 | 6 | ||
| 8 | 7 | import * as json from '../../tools/doc/json.mjs'; | |
| 9 | - | ||
| 10 | - const require = createRequire(new URL('../../tools/doc/', import.meta.url)); | ||
| 11 | - const unified = require('unified'); | ||
| 12 | - const markdown = require('remark-parse'); | ||
| 8 | + import { | ||
| 9 | + remarkParse, | ||
| 10 | + unified, | ||
| 11 | + } from '../../tools/doc/deps.mjs'; | ||
| 13 | 12 | ||
| 14 | 13 | function toJSON(input, filename, cb) { | |
| 15 | 14 | function nullCompiler() { | |
| 16 | 15 | this.Compiler = (tree) => tree; | |
| 17 | 16 | } | |
| 18 | 17 | ||
| 19 | 18 | unified() | |
| 20 | - .use(markdown) | ||
| 19 | + .use(remarkParse) | ||
| 21 | 20 | .use(json.jsonAPI, { filename }) | |
| 22 | 21 | .use(nullCompiler) | |
| 23 | 22 | .process(input, cb); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ import { mkdir, writeFile } from 'fs/promises'; | |||
| 9 | 9 | import gfm from 'remark-gfm'; | |
| 10 | 10 | import remarkParse from 'remark-parse'; | |
| 11 | 11 | import { toVFile } from 'to-vfile'; | |
| 12 | - import unified from 'unified'; | ||
| 12 | + import { unified } from 'unified'; | ||
| 13 | 13 | ||
| 14 | 14 | const rootDir = new URL('../../', import.meta.url); | |
| 15 | 15 | const doc = new URL('./doc/api/addons.md', rootDir); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + // Re-exporting dependencies for tests in test/doctool. | ||
| 2 | + | ||
| 3 | + export { default as rehypeRaw } from 'rehype-raw'; | ||
| 4 | + export { default as rehypeStringify } from 'rehype-stringify'; | ||
| 5 | + export { default as remarkParse } from 'remark-parse'; | ||
| 6 | + export { default as remarkRehype } from 'remark-rehype'; | ||
| 7 | + export { unified } from 'unified'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ import gfm from 'remark-gfm'; | |||
| 28 | 28 | import markdown from 'remark-parse'; | |
| 29 | 29 | import remark2rehype from 'remark-rehype'; | |
| 30 | 30 | import frontmatter from 'remark-frontmatter'; | |
| 31 | - import unified from 'unified'; | ||
| 31 | + import { unified } from 'unified'; | ||
| 32 | 32 | ||
| 33 | 33 | import * as html from './html.mjs'; | |
| 34 | 34 | import * as json from './json.mjs'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ import htmlStringify from 'rehype-stringify'; | |||
| 28 | 28 | import gfm from 'remark-gfm'; | |
| 29 | 29 | import markdown from 'remark-parse'; | |
| 30 | 30 | import remark2rehype from 'remark-rehype'; | |
| 31 | - import unified from 'unified'; | ||
| 31 | + import { unified } from 'unified'; | ||
| 32 | 32 | import { visit } from 'unist-util-visit'; | |
| 33 | 33 | ||
| 34 | 34 | import * as common from './common.mjs'; | |
@@ -395,7 +395,7 @@ export function buildToc({ filename, apilinks }) { | |||
| 395 | 395 | ||
| 396 | 396 | depth = node.depth; | |
| 397 | 397 | const realFilename = path.basename(filename, '.md'); | |
| 398 | - const headingText = file.contents.slice( | ||
| 398 | + const headingText = file.value.slice( | ||
| 399 | 399 | node.children[0].position.start.offset, | |
| 400 | 400 | node.position.end.offset).trim(); | |
| 401 | 401 | const id = getId(`${realFilename}_${headingText}`, idCounters); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ | |||
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | 22 | import html from 'remark-html'; | |
| 23 | - import unified from 'unified'; | ||
| 23 | + import { unified } from 'unified'; | ||
| 24 | 24 | import { selectAll } from 'unist-util-select'; | |
| 25 | 25 | ||
| 26 | 26 | import * as common from './common.mjs'; | |
@@ -376,7 +376,7 @@ function parseListItem(item, file) { | |||
| 376 | 376 | ||
| 377 | 377 | current.textRaw = item.children.filter((node) => node.type !== 'list') | |
| 378 | 378 | .map((node) => ( | |
| 379 | - file.contents.slice(node.position.start.offset, node.position.end.offset)) | ||
| 379 | + file.value.slice(node.position.start.offset, node.position.end.offset)) | ||
| 380 | 380 | ) | |
| 381 | 381 | .join('').replace(/\s+/g, ' ').replace(/<!--.*?-->/sg, ''); | |
| 382 | 382 | let text = current.textRaw; | |
@@ -491,8 +491,8 @@ function newSection(header, file) { | |||
| 491 | 491 | function textJoin(nodes, file) { | |
| 492 | 492 | return nodes.map((node) => { | |
| 493 | 493 | if (node.type === 'linkReference') { | |
| 494 | - return file.contents.slice(node.position.start.offset, | ||
| 495 | - node.position.end.offset); | ||
| 494 | + return file.value.slice(node.position.start.offset, | ||
| 495 | + node.position.end.offset); | ||
| 496 | 496 | } else if (node.type === 'inlineCode') { | |
| 497 | 497 | return `\`${node.value}\``; | |
| 498 | 498 | } else if (node.type === 'strong') { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments