Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widont short headlines #18

Merged
merged 4 commits into from
Jun 2, 2014
Merged

Widont short headlines #18

merged 4 commits into from
Jun 2, 2014

Conversation

mattly
Copy link
Contributor

@mattly mattly commented Mar 7, 2014

I had a problem with a two-word headline overflowing its containing box on a mobile layout, thanks to inadvertent use of widont and the non-breaking space it inserted. Thinking about it, in a case like this, four words is probably the minimum that should have its trailing words non-breaking, but I think there's room for discussion there.

This perhaps isn't the best solution, since I am short-circuiting the regexp, but it was easier to get something that worked and provided a better point for awareness of the problem.

mattly added 2 commits March 7, 2014 11:58
This perhaps isn't as good of a solution as it could be since it doesn't tie
into the existing regexp, but it is simple and doesn't trample on any of the
other tests.  It also allows me to provide awareness of the problem and provide
a proposed solution, without investing too much time in trying to modify the
regexp.
@brandonaaron
Copy link
Contributor

I believe (I didn't verify) this will fail on short text that has one or more inline tags (a, span) with multiple attributes that are space separated. I could definitely see this as being a desirable config item/feature though.

@mattly
Copy link
Contributor Author

mattly commented Mar 14, 2014

yeah, this will also not do the intended thing on headlines inside of larger texts. I'll take more intentful stab at making the regexp do what I've intended here

This will also handle strings like "<h1>One Two</h1><p>Three Four Five</p>" or
html tags with spaces in them for attributes.
@mattly
Copy link
Contributor Author

mattly commented Mar 15, 2014

OK, I got a solution working with the regexp. Matching group 1 now requires [space][non-space][space][non-space] to trigger, so you'd need four "words" to get the nbsp. Or really three words with a space in front of them.

I suppose it'll also match tags with spaces for attributes, (f.e. <h1>Click <a href='#' title='the link'>Here</a></h1>), but it was before. If this is a problem I can expand the concept of [non-space] a bit.

Thus, for "<h1>Foo <a href='#'>bar baz</a></h1>", the h1 tag has for the
purposes of the matching regexp three words.
@mattly
Copy link
Contributor Author

mattly commented Mar 15, 2014

Solved the inline tag problem. Let me know what you think.

ekalinin added a commit that referenced this pull request Jun 2, 2014
@ekalinin ekalinin merged commit 4751715 into ekalinin:master Jun 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants