Closed vermiculus closed 7 years ago
Could you elaborate on the problem? Also that link points into the stupefy_entities
function, is that what you intended?
Ah, nope – sorry: correct link
Here's a 'bad' paragraph:
This is just some filler text. It doesn't say much, but it doesn't need to: its sole purpose is to get – to begin a new line.
And here's a 'good' paragraph:
This is just some filler text. It doesn't say much, but it doesn't need to: its sole purpose is to get – to begin a new line – a plan thwarted by
 
.
It's just a rule of typography; here's a reference.
@vermiculus That link seems to go to "def default_entities" ... is that what you intended? I'm not seeing the connection between that and "likely fix"
Regarding "bad" paragraph and "good" paragraph, here's what shows in my browser. I think this is also not what you intended:
I think this is the paragraph you meant from the reference. Pasting here for safekeeping:
When a dash falls between the end of one line and the beginning of the next, you should try to ensure that the dash is placed at the end of the first line and not at the beginning of the second, if you can.
I agree it would be nice to fix this. Do you want to provide a PR?
Hm, this is what shows on my browser:
Anyway, I'll work on providing a PR.
The idea is to replace every recognized ASCII endash with a thinspace+endash – would that not be in default_entities
? (I'll freely admit I don't know Ruby beyond hello, world
.)
Unfortunately in my own testing it appears that Chrome and Firefox both will also split lines between word and dash, for example hi—just saying—this is an example
might be rendered with —just
or —this
starting a line. However both browsers seem to change their behavior if the character prior to the dash is a non-breaking space, either
or 
(zero-width non-breaking space)
So the fuller fix, ignoring the various modes, should be something like:
foo -- bar
becomes foo — bar
foo--bar
becomes foo—bar
This goes beyond modifying default_entities
and should likely be configurable in options.
@vermiculus released v0.5.1 which should fix this for you. Let me know!
Lines in a paragraph should never start with a dash – use a non-breaking space or a thinspace to remove that possibility.
Likely fix at https://github.com/jmcnevin/rubypants/blob/b2736f5d62df5c69dc9e77477ed4d9b472107227/lib/rubypants/core.rb#L329