Hi after hours of try I found the problem..

Seem that if I write (html) TinyMCE remove all line breaks.

If I disable editor and insert line return at the end of any H2 your code run well
but after this editor eat line returns and your code present only one item with all H2 togheter.

<p>Som:<!--tableofcontents--></p> <p>x</p> <h2>A</h2><p>&nbsp;</p> <h3>a</h3> <h3>b</h3> <h3>c</h3><p>&nbsp;</p> <h2>B</h2> <p>&nbsp;</p> <h2>C</h2><p>&nbsp;</p> <h2>D</h2><p>&nbsp;</p>

Return:

Table of Contents

   1. A  a b c  B C  D

This run right but editor eat this line return:

<p>Som:<!--tableofcontents--></p>
<p>x</p>
<h2>A</h2><p>&nbsp;</p>
<h2>a</h2>
<h2>b</h2>
<h2>c</h2><p>&nbsp;</p>
<h2>B</h2><p>&nbsp;</p>
<h2>C</h2><p>&nbsp;</p>
<h2>D</h2><p>&nbsp;</p>

Comments

deviantintegral’s picture

Assigned: Unassigned » deviantintegral
Status: Active » Closed (fixed)

First thing, the tag shouldn't be within

tags as it has a div. It probably works, but would produce invalid HTML.

The code from the 2.x branch doesn't seem to have this problem - could you give it a try? I was able to have the correct result with this:

<!--tableofcontents minlevel:3; maxlevel:3-->
<h3>Test</h3><p>Test</p><h3>test2</h3><p>test2</p>

Thanks,
--Andrew