Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tinymce makes invalid nested lists

Tags:

html

tinymce

Is there a way to get tinymce to generate valid html? It's generating lists like this:

    <li>text</li>
    <li>text</li>
    <li>text</li>
    <ul>
        <li>text</li>
        <li>text</li>
        <li>text</li>
        <ul>
            <li>text</li>
            <ul>
                <li>text</li>
            </ul>
        </ul>
    </ul>
</ul>

Unicorn outputs:

Element ul not allowed as child of element ul in this context.

I'd prefer lists like this:

<ul>
    <li>text</li>
    <li>text</li>
    <li>
        text
        <ul>
            <li>text</li>
            <li>text</li>
            <li>
                text
                <ul>
                    <li>text</li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

I was happy to find that this question solved the issue (setting source_formatting to false when initializing tinymce); however it seems when tinymce parses some markup (for example if you put some in a textarea and then initilize tinymce) tinymce re-parses it as in example 1. Any ideas on how to make tinymce not change the markup originally in the editor I initialize it on?

like image 424
12378123789 Avatar asked Aug 02 '11 20:08

12378123789


2 Answers

Add the lists plugin when initialising TinyMCE

tinyMCE.init({
...
plugins : "lists",
...
});

Edit: I believe this only applies to TinyMCE 3.x

like image 82
rmorse Avatar answered Oct 14 '22 03:10

rmorse


Check the latest version 3.4.4. It should be fixed there.

like image 31
Thariama Avatar answered Oct 14 '22 03:10

Thariama