What you're building
A function markdownToHTML(md) that converts a small but useful subset of
Markdown syntax into an HTML string.
Input:
# Hello
## World
This is **bold** and *italic* text.
Output:
<h1>Hello</h1>
<h2>World</h2>
<p>This is <strong>bold</strong> and <em>italic</em> text.</p>
Markdown powers GitHub READMEs, dev blogs, documentation, and chat apps. Understanding how it works removes the mystery from these tools.
Requirements
# Headingβ<h1>Heading</h1>## Headingβ<h2>Heading</h2>**text**β<strong>text</strong>(inline, inside paragraphs)*text*β<em>text</em>(inline, inside paragraphs)- Any line that is not a heading and is not blank β wrap in
<p>...</p> - Skip blank lines (produce no output for them)
- Process lines in order; each line produces at most one output element
Stretch goals
- Support unordered lists:
- itemβ<li>item</li>wrapped in<ul> - Support inline
\code`β<code>code</code>` - Handle
***bold and italic***
What this proves
- Regex-powered line-by-line transformation
- Layered string processing: block-level first, then inline
- You understand how Markdown renderers work at their core
β‘ 50 XP
solution.jsRuns in your browser
Loading editorβ¦
Tests4 to pass
h1 heading
h2 heading
bold and italic in paragraph
blank lines are skipped
Run your code to check these.