5

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?

Maroun
  • 94,125
  • 30
  • 188
  • 241
12378123789
  • 51
  • 1
  • 6

3 Answers3

8

Add the lists plugin when initialising TinyMCE

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

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

rmorse
  • 736
  • 6
  • 18
1

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

Thariama
  • 50,002
  • 13
  • 138
  • 166
0

try setting option, fix_list_elements : true in init method.

dhanu10896
  • 315
  • 2
  • 16