Projects · 16 / 19 Exercise Hard

Markdown to HTML converter

Objective

Build a converter from a subset of Markdown to HTML combining line-by-line reading, state and regular expressions.

Instructions

  • The first line has the number n of lines of Markdown text; then come those lines.
  • Support # t → <h1>, ## t → <h2>, lists with - item → <ul> with one <li> per item, and paragraphs <p> (several consecutive lines form a single paragraph; an empty line ends it).
  • Inside the text: **x** → <strong>x</strong>, *x* → <em>x</em> and `x` → <code>x</code>. Show one tag or block per line, with no extra spaces.
Input
6
# Título
Texto con **negrita**
y *cursiva*.

- uno
- dos
Output
<h1>Título</h1>
<p>Texto con <strong>negrita</strong> y <em>cursiva</em>.</p>
<ul>
<li>uno</li>
<li>dos</li>
</ul>

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise