Item11751: TinyMCE breaks numbered headers

Priority: Enhancement
Current State: Duplicate
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: ExplicitNumberingPlugin, WysiwygPlugin
Reported By: JacobEtches
Waiting For:
Last Change By: MichaelDaum
Editing a topic that has numbered headings using the ---+# syntax using TinyMCE causes a space to be inserted resulting in ---+ #, which breaks the syntax.

-- JacobEtches - 12 Apr 2012

Isn't ---# the correct syntax? Without the + inbetween?

---# Heading level 1
works fine

---+ ##. Heading level 1
This works fine too.

---++ ##.. Heading level 2

---++ ##.. Heading level 2
One can even mix notations.

---## Heading
I prefer the ##. one, cause that always works.

-- FranzJosefGigler - 12 Apr 2012

Thanks. You're quite right that I can get what I want by using the ##. syntax. The syntax I was using is show here:

And I liked the fact that it (1) used a single command to declare the level of the header, and (2) allowed the numbering to start with header 2 in a natural way (header 1 in our wiki is always the topic name, so there's no need to number it).

Having to declare the header depth twice increases the likelihood of human error. I accidentally had incongruous results immediately trying to test it. This isn't life threatening, but it is a nuisance.

-- JacobEtches - 12 Apr 2012

I think this will be a bit of a challenge to fix. The issue is that the WysiwygPlugin doesn't understand extensions to the TML syntax, which is what this format is. And it's not "pluggable". The topic is rendered into the HTML for editing, and then when saved, Wysiwyg plugin attempts to convert backwards from HTML to TML. This process is somewhat lossy, as not all HTML can be represented in TML.

I'll confirm the task and mark it for the Wysiwyg plugin. The other option might be to extend ExplicitNumberingPlugin to recognize the ---+ # syntax. But this has the possibility of breaking sites where they want headings to begin with the #.

-- GeorgeClark - 12 Apr 2012

--- + # also looks terrible in the WysiwygPlugin because every header depth shows up as level 1. I also realized once I switched to ---++ ##. that this fixes the incompatibility I noticed with GoUptoTocPlugin. So I think the best solution for now is to remove the "single numbered" example from the documentation and call that feature deprecated.

What I would prefer going forward is a set of settings:
   * Set NUMBEREDTOC = on
So that I could make the default numbered for the site, and users could turn it off at the topic level as needed. If there was a more latex-like spacing between the number and the title, that would be excellent too. I'm not skilled enough to implement this, I'm afraid.

Hopefully this would have the added benefit of allowing the WysiwygPlugin to show numbered headers in the editor, which would make navigating in the edit window easier.

-- JacobEtches - 13 Apr 2012

There is rudimentary support for ExplicitNumberingPlugin in WysiwygPlugin as well as in the core's regular expression for TML headers. The heading regex in the core is slightly broken in a way that it does not recognize the numbering indicator as defined in ExplicitNumberingPlugin, i.e. a mix of + and # and numbers. I think it is pointless to fix the regex in the core. It actually should be removed from it, even more as it only roughly matches ENP's feature set.

WysiwygPlugin's roundtrip tries to detect the # indicator for numbered headings, but too fails to match ENP's feature set.

Once the heading regex in the core is fixed in a way WysiwygPlugin detects an explicit numbering indicator, will it loose the actual explicit numbering indicator as originally crafted so that it is lost when convering back HTML to TML.


---+# heading

Without fixing the regex in the core, TML2HTML creates:

<h1 class="TML"> # heading</h1>

and HTML2TML will rewrite it to

---+ # heading

inserting a space, and thus breaking the explict numbering

When fixing

-    $regex{headerPatternDa} = qr/^---+(\++|\#+)(.*)$/m;
+    $regex{headerPatternDa} = qr/^---+([\+\#]+)(.*)$/m;

will TML2HTML create

<h1 class="TML numbered"> heading </h1>

i.e. drop the actual numbering indicator. As a consequence saving the content will rewrite it to

---## heading

which is wrong as well.

Available options:

  1. fully add explicit numbering to the core thus extending TML
  2. fully remove explicit numbering traces from the core thus as it isn't functional anyway
  3. rewrite ExplicitNumberingPlugin in a way it is compatible with TML standards

-- MichaelDaum - 14 Mar 2018

Should be fixed in Item14729. Please test and reopen if still buggy.

-- MichaelDaum - 13 Jun 2018
Topic revision: r9 - 13 Jun 2018, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy