[wp-hackers] newlines from rich text editor do not convert to paragraphs

Davit Barbakadze jayarjo at gmail.com
Mon Dec 14 12:32:50 UTC 2009


Probably it would have been more logical applying filters attached to
'the_content' hook within get_the_content() function. This way we
could get filtered content echoed via the_content() tag, filtered
content in a string via get_the_content() and pure content via
$post->post_content.

On Mon, Dec 14, 2009 at 3:49 PM, Davit Barbakadze <jayarjo at gmail.com> wrote:
>> In visual mode single return inserts new paragraph
>
> This is what wasn't working. But switching to default theme and
> turning off plugins corrected this issue. So my guess here (proved by
> some experiments) will be that using $post->post_content in the loop
> directly will output not converted string (which our current theme
> does intensively). Actual conversion as it seems is happening inside
> the_content() tag (which is bypassed by our theme). And not inside
> get_the_content(), but in the_content() tag only.
>
> Update: Searching for filters attached to 'the_content' hook, brought
> me to wp-includes/default-filters.php file, which is probably a
> container for all default wordpress filters. And one of filters
> attached to 'the_content' hook turned out to be wpautop() function
> (http://phpxref.com/xref/wordpress/wp-includes/formatting.php.source.html#l121),
> which does exactly that: "Replaces double line-breaks with paragraph
> elements."
>
> It means that only the_content() tag will output properly converted
> content string, all other approaches to retrieving post content will
> result in raw, unconverted text. Among others the_content() converts
> text smilies into graphics, does some simple xhtml fixing and invalid
> utf characters substitutions, and obviously much more.
>
> It can be concluded from here that wordpresses unexplainable fault in
> similar cases (which happen pretty often as I found out from my google
> search activity), is, at least partially, untrue.
>
> On Mon, Dec 14, 2009 at 12:05 PM, Andrew Ozz <admin at laptoptips.ca> wrote:
>> mccormicky wrote:
>>>
>>> I think I was going on about the html *mode* of the wp editor, not
>>> *html*itself.
>>>
>>> It's not a firefox only issue. I see this in safari and internet explorer.
>>>
>>> Simple fix: use the html *mode of the editor* to insert line breaks by
>>> *hitting
>>> the return key*.
>>> Then switch back to visual format  to do your rich text stuff * *then
>>> switch
>>> back to html mode* *and save.
>>> if you save your changes in visual mode you run the risk of losing some
>>> formatting.In this case, line breaks.
>>
>> I'm still not clear what the actual problem is... Dion explained quite well
>> how the editors work: in HTML mode single return is converted to <br /> two
>> returns are converted to <p>. In visual mode single return inserts new
>> paragraph, and Shift+Return inserts <br />. Saving either in visual or HTML
>> mode doesn't make a difference.
>>
>> If you're seeing something else, please disable all plugins and switch to
>> the default theme to see if it makes a difference.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Davit Barbakadze
>



-- 
Davit Barbakadze


More information about the wp-hackers mailing list