Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Example in the docs is broken #7

@ZaninAndrea

Description

@ZaninAndrea

Running this code sample from the docs is broken, because unified needs a compiler such as rehype-stringify to run the process method

const unified = require('unified');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');
const rehypePrism = require('rehype-prism');

unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypePrism)
  .process(/* some markdown */);

Furthermore when adding the rehype-stringify compiler the code runs correctly, but the output is not syntax highlighted, it seems that adding rehype-prism doesn't change the output.

Full code sample:

const fs = require("fs")
const html = require("rehype-stringify")
const unified = require("unified")
const remarkParse = require("remark-parse")
const remarkRehype = require("remark-rehype")
const rehypePrism = require("rehype-prism")

unified()
    .use(remarkParse)
    .use(remarkRehype)
    .use(rehypePrism)
    .use(html)
    .process(fs.readFileSync("./test.md", "utf8"), function(err, file) {
        if (err) throw err
        fs.writeFileSync("test.html", String(file))
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions