davidmerfield/Typeset

Adjacent text nodes with hanging punctuation

davidmerfield opened this issue · 2 comments

<p>Hello, <em>"Mr"</em> Fox.</p>

I need to insert a spacer when the adjacent sibling is a text node.

So my approach to solving this is as follows:

If a text node begins with punctuation that needs to be hung:

Then check if its parent node's previous sibling is also a text node, and if so add the appropriate spacer to the end.

Likewise, if a text node ends with punctuation that needs to be hung

Check if its parent node's next sibling is also a text node, and if so add the appropriate spacer to the start.

What if the text node is not the sole child of its parent? Should I not then apply this process to the siblings of the text node and not its parent?