Example in the docs is broken
See original GitHub issueRunning 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:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

fwiw, I am observing the same issue as well, in regards to following the docs markdown usage example, e.g.
To fix, I would need to add something like
rehypeStringifyas suggested in the original comment.You might be installing the wrong package? The correct one is
@mapbox/rehype-prism, notrehype-prism.