This Cursor software engineering question asks candidates to build a streaming Markdown code-fence parser that handles partial input and state transitions. It is useful practice for parsing, incremental processing, and designing robust behavior around malformed or incomplete text.
Implement a streaming Markdown parser that recognizes inline code spans marked with backticks and fenced code blocks marked with triple backticks. The parser receives chunks of text incrementally, so delimiters may be split across chunk boundaries. Return or emit tokens that preserve normal text, inline code, and fenced code content.
### Constraints & Assumptions
- Only backtick inline code and triple-backtick fences are required.
- Input arrives in arbitrary chunk sizes.
- A delimiter can cross a chunk boundary.
- Nested Markdown constructs are out of scope unless clarified.
### Clarifying Questions to Ask
- Should unterminated code spans be emitted as text or buffered until end of stream?
- Do fenced code blocks support an info string after the opening fence?
- Should escaped backticks be handled?
- Is output event-based, token-array-based, or rendered HTML?
### What a Strong Answer Covers
```premium-lock What a Strong Answer Covers
```
### Follow-up Questions
- How would you add tildes as an alternate fence marker?
- How would you support language info strings?
- How would you prevent unbounded buffering?
- How would you make the parser resumable after a process restart?
Quick Answer: This Cursor software engineering question asks candidates to build a streaming Markdown code-fence parser that handles partial input and state transitions. It is useful practice for parsing, incremental processing, and designing robust behavior around malformed or incomplete text.
Implement a streaming Markdown parser that recognizes inline code spans marked with backticks and fenced code blocks marked with triple backticks. The parser receives chunks of text incrementally, so delimiters may be split across chunk boundaries. Return or emit tokens that preserve normal text, inline code, and fenced code content.
Constraints & Assumptions
Only backtick inline code and triple-backtick fences are required.
Input arrives in arbitrary chunk sizes.
A delimiter can cross a chunk boundary.
Nested Markdown constructs are out of scope unless clarified.
Clarifying Questions to Ask
Should unterminated code spans be emitted as text or buffered until end of stream?
Do fenced code blocks support an info string after the opening fence?
Should escaped backticks be handled?
Is output event-based, token-array-based, or rendered HTML?
What a Strong Answer Covers Premium
Follow-up Questions
How would you add tildes as an alternate fence marker?
How would you support language info strings?
How would you prevent unbounded buffering?
How would you make the parser resumable after a process restart?