@TsundereBug, you can walk the AST to extract text and style.
Your example string results in the following HTML and AST:
```````````````````````````````` example Issue 116: 1
So _this_ is italic and **this** is bold
.
<p>So <em>this</em> is italic and <strong>this</strong> is bold</p>
.
Document[0, 41]
Paragraph[0, 41]
Text[0, 3] chars:[0, 3, "So "]
Emphasis[3, 9] textOpen:[3, 4, "_"] text:[4, 8, "this"] textClose:[8, 9, "_"]
Text[4, 8] chars:[4, 8, "this"]
Text[9, 24] chars:[9, 24, " is i … and "]
StrongEmphasis[24, 32] textOpen:[24, 26, "**"] text:[26, 30, "this"] textClose:[30, 32, "**"]
Text[26, 30] chars:[26, 30, "this"]
Text[32, 40] chars:[32, 40, " is bold"]
````````````````````````````````
You can start with the TextCollectingVisitor
and add the emphasis nodes to the list of processed nodes and store the information as these are encountered to contain the text of their children.