import '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import assert from 'assert'; import { readFileSync } from 'fs'; import * as html from '../../tools/doc/html.mjs'; import { replaceLinks } from '../../tools/doc/markdown.mjs'; import { rehypeRaw, rehypeStringify, remarkParse, remarkRehype, unified, } from '../../tools/doc/deps.mjs'; // Test links mapper is an object of the following structure: // { // [filename]: { // [link definition identifier]: [url to the linked resource] // } // } const testLinksMapper = { 'foo': { 'command line options': 'cli.html#cli-options', 'web server': 'example.html', }, }; function toHTML({ input, filename, nodeVersion, versions }) { const content = unified() .use(replaceLinks, { filename, linksMapper: testLinksMapper }) .use(remarkParse) .use(html.firstHeader) .use(html.preprocessText, { nodeVersion }) .use(html.preprocessElements, { filename }) .use(html.buildToc, { filename, apilinks: {} }) .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeRaw) .use(rehypeStringify) .processSync(input); return html.toHTML({ input, content, filename, nodeVersion, versions }); } // Test data is a list of objects with two properties. // The file property is the file path. // The html property is some HTML which will be generated by the doctool. // This HTML will be stripped of all whitespace because we don't currently // have an HTML parser. const testData = [ { file: fixtures.path('order_of_end_tags_5873.md'), html: '
array
<Array>Describe Foobar
in more detail here.
Describe Foobar II
in more detail here.' +
'fg(1)' +
'
Describe ' +
'Deprecated thingy
in more detail here.' +
'fg(1p)' +
'
Describe Something
in more detail here.
node \\[options\\] index.js' +
'
Please see the' + 'Command Line Optionsdocument for more information.
' + 'An example of a' +
'webserverwritten with Node.js which responds with' +
'\'Hello, World!\'
:
Check' + 'out alsothis guide