Opened 18 years ago
Closed 18 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: |
Description
Try entering this as wikitext:
{| |- | {{Test}} |}
Save it, then open it in FCK: the template is outside the table.
Change History (3)
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
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>'
by
'<span class="fck_mw_template">' . htmlspecialchars(nth template wikitext) . '</span>'
comment:3 Changed 18 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
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!
To be exact, the output after opening in FCK above's wikitext is: