question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example in the docs is broken

See original GitHub issue

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))
    })

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
thescientist13commented, Oct 31, 2020

fwiw, I am observing the same issue as well, in regards to following the docs markdown usage example, e.g.

const rehypePrism = require('@mapbox/rehype-prism');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');

const processedMarkdown = await unified()
  .use(remarkParse)
  .use(remarkeRhype)
  .use(rehypePrism)
  .process(markdownContents);
Error: Cannot `process` without `Compiler`

To fix, I would need to add something like rehypeStringify as suggested in the original comment.

1reaction
silvenoncommented, Apr 26, 2020

You might be installing the wrong package? The correct one is @mapbox/rehype-prism, not rehype-prism.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The formatting while viewing my google doc via mobile phone ...
The formatting of my google docs look fine when viewing from a desktop. However, when I view from a mobile device the formatting...
Read more >
Google Docs: Headers, Footers, and Page Breaks
In Google Docs headers and footers let you add important information to each page. Use the Google Docs page break feature to separate...
Read more >
Docs is broken: Writing Docs we actually need [closed]
Let's take as an example the Boost library. The official documentation is pretty lackluster, consisting of 404'd links and unclear explanations.
Read more >
Check On-Page for Broken Links with Google Docs | tinkerEdge
A step-by-step example using Google Docs to extract anchor text and hyperlinks, and check for broken links on your web pages.
Read more >
Adding Section breaks in Google Docs - YouTube
You can now add continuous or next page sections breaks and set the margins and other formatting of a specific section of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found