Implement a function that converts a plain-text string into HTML supporting only these features:
(
-
Paragraphs: two or more consecutive newline characters separate paragraphs; wrap each paragraph in
<p>
...
</p>
.
(
-
Soft line breaks: a single newline inside a paragraph becomes
<br/>
.
(
-
Blockquotes: one or more consecutive lines that each begin with "> " (greater-than followed by a space) form a single
<blockquote>
...
</blockquote>
; within the blockquote, strip the leading "> " from each quoted line; preserve soft line breaks as
<br/>
; blockquotes cannot span paragraphs.
(
-
Strikethrough: text enclosed by a pair of tildes, e.g.,
like this
, becomes
<del>
like this
</del>
.
(
-
Formatting commands do not cross paragraphs; if a strikethrough is opened in one paragraph, it must close in the same paragraph or be treated as literal text. The output must be valid HTML; exact whitespace and self-closing syntax need not match any reference output. Provide the algorithm, discuss how you will tokenize/scan the input (single pass vs. multi-pass), specify time and space complexity in terms of input length n, and describe how you will handle edge cases such as trailing spaces, empty paragraphs, consecutive blockquote groups, malformed or unmatched tildes, and lines that mix quoted and non-quoted text. Include a few test cases, for example: "This is a paragraph with a
soft line break.
Some quoted text
continues here
This has a strikethrough word."