InterviewDB Experience

Markup Processor: Parse and Render a Subset of Markdown to HTML

Interview Experience

Round 1 Coding

Problem

Implement a markup processor that converts a simplified markdown string to HTML. Support: headers (#, ##, ###), bold (**text**), italic (*text*), and unordered lists (- item).

python
def markdown_to_html(md: str) -> str:
    ...

Example

md = """# Title
## Subtitle
Hello **world** and *everyone*.
- Item one
- Item two
"""

markdown_to_html(md)
# ->
# <h1>Title</h1>
# <h2>Subtitle</h2>
# <p>Hello <strong>world</strong> and <em>everyone</em>.</p>
# <ul><li>Item one</li><li>Item two</li></ul>

Follow-ups

  1. How do you handle inline formatting (**bold**) that spans across what looks like a word boundary?
  2. How would you support nested lists (indented - subitem)?
  3. What happens with malformed input like unclosed **bold — how do you handle that gracefully?
  4. How would you extend the processor to support hyperlinks in the format [text](url)?

Full Details

Round 1 Coding

Problem

Implement a markup processor that converts a simplified markdown string to HTML. Support: headers (#, ##, ###), bold (**text**), italic (*text*), and unordered lists (- item).

python
def markdown_to_html(md: str) -> str:
    ...

Example

md = """# Title
## Subtitle
Hello **world** and *everyone*.
- Item one
- Item two
"""

markdown_to_html(md)
# ->
# <h1>Title</h1>
# <h2>Subtitle</h2>
# <p>Hello <strong>world</strong> and <em>everyone</em>.</p>
# <ul><li>Item one</li><li>Item two</li></ul>

Follow-ups

  1. How do you handle inline formatting (**bold**) that spans across what looks like a word boundary?
  2. How would you support nested lists (indented - subitem)?
  3. What happens with malformed input like unclosed **bold — how do you handle that gracefully?
  4. How would you extend the processor to support hyperlinks in the format [text](url)?

About This Question

This is a candidate experience report from a samsara interview during the phone round.

It covers the following topics: Coding, Phone, Strings .