• Resolved fodden

    (@fodden)


    Despite repeated assertions that browsers will collapse two consecutive spaces, I find that on my multi-author blog, two spaces after a period are displayed just fine. I don’t want this. What I want is to be able to force one space only between sentences. Does anyone know of a way to do this?

    The blog in question is http://www.slaw.ca

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter fodden

    (@fodden)

    Yes, well, I meant “Force one space between sentences” of course. Sorry about that.

    I ‘m making the assumption that you may want to get rid of the space between paragraphs?

    Find this in the style sheet:

    div.entry p {
    margin: 10px 0;
    font-family: Verdana, Arial, sans-serif;
    font-size: 11px;
    line-height: 160%;
    color:#000;
    }

    Try changing it to this:

    div.entry p {
    margin: 0;
    font-family: Verdana, Arial, sans-serif;
    font-size: 11px;
    line-height: 160%;
    color:#000;
    }

    And see if the margin change makes the difference you are looking for. Make a backup before editing, just in case.

    Thread Starter fodden

    (@fodden)

    Thanks, ClaytonJames. But it’s the two spaces after the end of a sentence that I want to get rid of. This is a multi-author blog, and some authors use one space between sentences, but others are stuck with the old typewriter rule and use two. It’s the latter I’d like to correct automatically. So… how might I ensure only one space between sentences, i.e. after a period.

    Moderator keesiemeijer

    (@keesiemeijer)

    Put this in your theme’s functions.php :

    function remove_spaces($the_content) {
        return preg_replace( '/[\p{Z}\s]{2,}/u', ' ', $the_content );
    }
    
    add_filter('the_content', 'remove_spaces');

    Thread Starter fodden

    (@fodden)

    A thousand thanks, Keesiemeijer. (Dank u zeer?). I must must must learn regular expressions.

    Wow, I’ve been searching for a solution like this FOREVER! The tricky part is I want to search for “double-space” but that inevitably pulls up discussions about LINE spacing, not spaces between sentences/after periods.

    Oddly, while most themes display two spaces in a row the way they should (as a single space) some display two spaces AS two spaces. The crazy thing of it all is that the source code doesn’t show ”  ” as one would expect, but rather 2 spaces ” “. So that leads me to think that some themes have a funky CSS that displays ” ” as double-space.

    All ranting aside, that’s why this function is so crucial, and probably should be built into the WP core. Perhaps with an option to be disabled in the admin in case the blogger wants to use double space. Just a thought…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Force one space between periods’ is closed to new replies.