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

140
Views
Cambie las viñetas de rebajas a html en Javascript

Por el momento tengo una función.

 export function markdownToHtml(mdText) { const toHTML = mdText .replace(/^### (.*$)/gim, "<h3>$1</h3>") // h3 tag .replace(/^## (.*$)/gim, "<h2>$1</h2>") // h2 tag .replace(/^# (.*$)/gim, "<h1>$1</h1>") // h1 tag .replace(/\*\*(.*)\*\*/gim, "<b>$1</b>") // bold text .replace(/\*(.*)\*/gim, "<i>$1</i>") // italic text .replace(/\[(.*?)\]\((.*?)\)/gim, "<a href='$2'>$1</a>") // link return toHTML.trim() // using trim method to remove whitespace }

donde estoy analizando algunos de los estilos de Markdown en HTML, pero me falta la expresión regular para analizar las viñetas.

¿alguna idea? (no usar una dependencia es mejor)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Algo como esto?

No envuelve en UL

 function markdownToHtml(mdText) { const toHTML = mdText.split("\n").map(text => text .trim() // using trim method to remove whitespace .replace(/^### (.*$)/i, "<h3>$1</h3>") // h3 tag .replace(/^## (.*$)/i, "<h2>$1</h2>") // h2 tag .replace(/^# (.*$)/i, "<h1>$1</h1>") // h1 tag .replace(/^\* (.*$)/i, "<li>$1</li>") // <li> tag .replace(/\*\*(.*)\*\*/i, "<b>$1</b>") // bold text .replace(/\*(.*)\*/i, "<i>$1</i>") // italic text .replace(/\*(.*)\*/i, "<i>$1</i>") // italic text .replace(/\[(.*?)\]\((.*?)\)/i, "<a href='$2'>$1</a>")) // link return toHTML.join("\n") } console.log(markdownToHtml(`### Title\n* *Bold bullet*`))

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!