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

hanging punctuation for right-aligned blocks? #55

Open mbutterick opened 4 years ago

mbutterick commented 4 years ago

As part of my research on #52 I also studied whether the push/pull technique could be applied to blocks with text-align:right (that is, the punctuation would hang over the right margin instead of the left). I haven’t gotten it to work yet. It may be too complicated to be worthwhile. What I tried:

davidmerfield commented 4 years ago

This is an interesting challenge. Nothing comes to mind at the moment. I will give this some further thought.

I suppose we could mandate an inline-style instead of a class but it's hardly ideal!

[style*="text-align"][style*="right"] .push-closed {
  ...
}

Terrible hack aside, getting right-aligned hanging punctuation working for a predetermined parent class (e.g. .right) at compile time is a decent first step.

There's a part of me that would like to offer some optional front-end JavaScript which could handle this automatically. The front-end JavaScript could also generate the magic numbers for .push and .pull widths in typeset.css automatically, but that's for another thread...