Opened 16 years ago

Closed 16 years ago

#1012 closed Bug (fixed)

FCK moves around Templates inside tables

Reported by: barns Owned by:
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version:
Keywords: Cc:


Try entering this as wikitext:


Save it, then open it in FCK: the template is outside the table.

Change History (3)

comment:1 Changed 16 years ago by barns

To be exact, the output after opening in FCK above's wikitext is:




comment:2 Changed 16 years ago by barns

If I understand properly what you are doing in the FCKeditorParser.body.php file, here is what I think:
1) you ask MW to convert to HTML the wikitext before and after the template, and insert in between a special span for the template

2) the problem is that when converting the wikitext before the template, the table will be incomplete, and MW will complete the missing piece of table when converting to HTML to be compliant
Possible resolution:

            foreach ($tags as $pos=>$type) {
                $sum += $type;
                if ($sum == 1 && $lastSum == 0) {
                    $finalString .= parent::internalParse(strtr(substr($text, $startingPos, $pos - $startingPos), $strtr));
                    $startingPos = $pos;
                else if ($sum == 0) {
                    $finalString .= '<span class="fck_mw_template">' . htmlspecialchars(strtr(substr($text, $startingPos, $pos - $startingPos + 19), $strtr)) . '</span>';
                    $startingPos = $pos + 19;
                $lastSum = $sum;
            $finalString .= parent::internalParse(substr($text, $startingPos));

should be changed so that internalParse is only done on the complete reconstructed string, and not on substring. In addition, the templates could be stored into an array while only the span tag would be inserted into the complete string.
After the internalParse occured, we could re-insert the templates by replacing the nth occurence of

     '<span class="fck_mw_template"></span>'


'<span class="fck_mw_template">' . htmlspecialchars(nth template wikitext) . '</span>'

comment:3 Changed 16 years ago by Wiktor Walc

Resolution: fixed
Status: newclosed

First of all thank you for your report, it was very helpful.
You're right, parsing incomplete parts of text was wrong and I did just like you wrote.

Thanks again!

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy