← Questions

Parse and repair Markdown emphasis markers

0
FigmaCodingLast asked Jun 2024

Handle a small subset of Markdown: * for italic, ** for bold and ~~ for strikethrough, which must nest properly.

  1. Render a string to tagged output, recognizing the two-character markers before a single * (and deciding what *** means).
  2. Report whether the input is well formed.
  3. Repair malformed input with a fixed rule: a marker that closes the innermost open format closes it, a marker that would cross an outer open format is dropped, and anything still open at the end is dealt with consistently. Use a stack of open markers throughout.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding