Last active
January 10, 2016 23:30
-
-
Save robinsloan/caa5fa173f540d2a0337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for functions.php | |
function em_dash_filter($content) { | |
# add to css: .nobr { whitespace: nowrap; } | |
return preg_replace('/(\w+)(—|—|—)/', '<span class="nobr">$1$2</span><wbr>', $content); | |
} | |
add_filter( "the_content", "em_dash_filter" ); |
I like things that work everywhere, forever! Changed!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not to be Mr. Semantics Guy...
So,
nobr
is non-standard (it isn't even tracked by caniuse!) and future support is possibly iffy. Aspan
tag with aclass="nobr"
and awhitespace: nowrap;
rule would accomplish the same thing and work everywhere, forever!More here!
Honestly, though, browsers should do this by default. I mean really.