WordPress.org

Ready to get started?Download WordPress

Forums

select non-breaking spaces for formatting with CSS (1 post)

  1. Bernhard
    Member
    Posted 7 months ago #

    Hi,

    I've now searched for long time, hoping to find a solution.

    Sometimes there are non-breaking spaces ( ) in content that users paste to the editor.

    I would like to highlight these non-breaking spaces for logged in users or in the backend.
    For this it would be necessary to add a class.

    What I found is wordpress.org/support/topic/can-you-select-non-breaking-spaces-in-css.

    This solution works like a charme for <p>&nbsp;</p> even when I change it to

    function user_content_replace ( $content ) {
    	return str_replace('&nbsp;', '<span class="highlight">&nbsp;</span>', $content);
    }
    add_filter ('the_content', 'user_content_replace', 99);

    But it doesn't work at all in nonempty paragraphs as e.g. <p>test&nbsp;test</p>.

    Like this a solution would be very appreciated!

    Thank you in Advance
    Bernhard

Reply

You must log in to post.

About this Topic