Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
remark-prism doesn't convert to HTML with classnames

I wanted to convert markdown to syntax highlighted HTML with remark and remark-prism. But it doesn't work.

code:

import {remark} from "remark";
import prism from "remark-prism";
import html from "remark-html";

const text = '```javascript\nconsole.log("Hello, world");\n```';
remark()
  .use(prism)
  .use(html)
  .process(text, (_, {value}) => console.log(value));

result:

<div>
  <pre>
    <code>
      <span>console</span>
      <span>.</span>
      <span>log</span>
      <span>(</span>
      <span>"Hello, world"</span>
      <span>)</span>
      <span>;</span>
    </code>
  </pre>
</div>

It looks good. But it doesn't contain classnames.

I wanted just like:

<div class="remark-highlight">
  <pre class="language-javascript">
    <code>
      <span class="token console class-name">console</span>
      <span class="token punctuation">.</span>
      <span class="token method function property-access">log</span>
      <span class="token punctuation">(</span>
      <span class="token string">"Hello World"</span>
      <span class="token punctuation">)</span>
      <span class="token punctuation">;</span>
    </code>
  </pre>
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According this site, change just like below code, the code correctory work.

const content = await remark()
  .use(prism)
  .use(html, { sanitize: false })
  .process(markdown); 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!