Markdown as a tree, CommonMark with GFM’s tables, task lists, strikethrough and autolinks, with every node’s offsets into the source. While the text streams, what is cut at its end is closed in the tree, and only the last block is parsed again. Raw HTML is kept as text.