Tuesday, May 3, 2011

TinyMCE wraps my text in <p></p>. Can I avoid this?

Hello everybody. I am using TinyMCE (http://tinymce.moxiecode.com/) in a .NET page. Whenever I load a text

myTMCE.value=mycontent;

I can see that my text gets wrapped in <p></p>. This is not desirable for me, so I am trying to avoid it. Trying to initialize in

        <script>
            tinyMCE.init({
                force_p_newlines: true
            })

        </script>

did not work. Any idea? Thanks in advance, m.

From stackoverflow
  • You could strip <p> tags after the fact using .NET, or alternatively, just use a plain <textarea> field for data entry if that suits what you're trying to do.

    pomarc : I think I'll strip the leading and trailing

    but is a dirty solution.
  • See this thread and the answer in TinyMCE forum. force_p_newline is a gecko only option (ie FF).

    pomarc : however afaik force_p_newlines has another pourpose.
  • TinyMCE adds a whole load of tags to the text - its design goal is to create valid html from arbitrary input (including html input). If you want control over the generated html code, you're better off using another editor.

    pomarc : that's a pity, because tinyMCE works quite well, beside this unwanted behaviour.
  • Read the FAQ about paragraphs. link text

0 comments:

Post a Comment