htmlspaces

How do I put two spaces after every period in our HTML?


I need there to be two spaces after every period in every sentence in our entire site (don't ask).

One way to do it is to embark on manually adding a &nbsp  after every single period. This will take several hours.

We can't just find and replace every period, because we have concatenations in PHP and other cases where there is a period and then a space, but it's not in a sentence.

Is there a way to do this...and everything still work in Internet Explorer 6?

[edit] - The tricky part is that in the code, there are lines of PHP that include dots with spaces around them like this:

<?php echo site_url('/css/' . $some_name .'.css');?>

I definitely don't want extra spaces to break lines like that, so I would be happy adding two visible spaces after each period in all P tags.


Solution

  • You might be able to use the JavaScript split method or regex depending on the scope of the text.

    Here's the split method:

    var el = document.getElementById("mydiv");
    if (el){
        el.innerText = el.innerText.split(".").join(".\xA0 ");   
    }
    

    Test case:

    Hello world.Insert spaces after the period.Using the split method.

    Result:

    Hello world. Insert spaces after the period. Using the split method.