• Resolved Vikestart

    (@vikestart)


    Hey, I love your plugin πŸ™‚ But there is one problem

    If the last word is assigned a colour, it will end up as a widow without colour.

    This is because the plugin inserts &nbsp; inside the <span> like this: <span style="color:&nbsp;#00ff00;"> and breaks the CSS.

    Is there a way you can make it ignore those span tags?

    http://wordpress.org/plugins/widont-part-deux/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Morgan Estes

    (@morganestes)

    I’ll take a look at this. It’s a pretty basic reffed, but I can probably extend it to insert the nbsp before any tag.

    Thread Starter Vikestart

    (@vikestart)

    I think I found a solution πŸ™‚

    $(document).ready(function($){
    	$('p').html(function(i, oldHtml) {
    		var html = $(this).html();
    		var split = html.split(' ');
    		if ( (split.length > 1) && (!$(this).find('img').length) ) {
    			return oldHtml.replace('<span style="color: ', '<span&nbsp;style="color:&nbsp;').replace(/(\d),\s/g, '$1,').replace('<span&nbsp;style="color:&nbsp;', '<span style="color: ');
    		}
    	});
    });

    It inserts a non-breaking space in those tags before it attempts to insert a non-breaking space between the two latest words, it then avoids putting that inside the tag. Afterwards, the script removes the non-breaking spaces from the inside of the tag. πŸ™‚

    Plugin Author Morgan Estes

    (@morganestes)

    Turns out this was an issue that affected all tags that contain attributes, not just this case.

    Version 1.3.1 has been released that should fix this across all tags.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Colouring problem’ is closed to new replies.