davidmerfield / Typeset

An HTML pre-proces­sor for web ty­pog­ra­phy
https://typeset.lllllllllllllllll.com/
Creative Commons Zero v1.0 Universal
2.41k stars 52 forks source link

Adjacent text nodes with hanging punctuation #6

Closed davidmerfield closed 8 years ago

davidmerfield commented 9 years ago

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

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

davidmerfield commented 8 years ago

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?

davidmerfield commented 8 years ago

Fixed in 77df1273a9669b886511fcbe37777bbdbdf76481