Last modified: 2012-05-23 08:34:37 UTC
Originally reported at: http://www.mediawiki.org/wiki/Extension_talk:SyntaxHighlight_GeSHi#Error_if_i_have_.3CSource.3E_inside_the_box.... The bug is tested and confirmed at: http://bestbrute.wikia.com/index.php?title=Bestbrute_wiki:Sandbox&oldid=5415 How to reproduce bugs: If your source code uses <source>, it will conflicts the syntax used in this extension. For example the following source code can't be parsed correctly: <source lang="xml"> <?xml version="1.0"?> <Object> <Control> <Source> // This is the original source from my XML file ...... </Source> // This is the original source from my XML file </Control> </Object> </source> Please fix so any <source> syntax inside the code is escaped!
I don't think this is possible. The parser always chooses the first closing tag. It is impossible to know what the user really wants, so escape it yourself.
How to escape? None of the following methods work: * using <nowiki> tag * using <includeonly> tag * using < (for obvious reasons) It's impossible to escape it. What you can only do is to intentionally break that syntax, but this has display disadvantage and wrong syntax highlights. You have to tell the users about it too. But they often don't read so it will lead to unnecessary misunderstanding. a) I wonder if you could offer something like this: http://www.mediawiki.org/w/index.php?title=Extension:Labeled_Section_Transclusion&oldid=255140#How_it_works For example <source begin=code1 /> this is your code <source end=code1 /> b) Or offer a second syntax, let's say <syntaxhighlight> or <sourcehighlight>?? So far no source code uses those syntax. c) Or offer a way to escape <source>?? This option is kinda suboptimal as this leads to extra work. Quite many source codes use the syntax <source> too: http://www.google.com/codesearch?hl=en&lr=&q=%3Csource%3E&sbtn=Search Thanks!
(In reply to comment #2) Oh, you are correct actually, there is no way to escape it. > a) Doesn't look nice nor easy. > b) > Or offer a second syntax, let's say <syntaxhighlight> or <sourcehighlight>?? This should be pretty easy. > > c) This would be quite ugly too, or at least I do not have any idea how to make it in nice way. I would go for option b. If nobody opposes I will implement it shortly.
(In reply to comment #2) > How to escape? None of the following methods work: > * using <nowiki> tag > * using <includeonly> tag > * using < (for obvious reasons) > You could try something like {{#tag:source|<nowiki>...Your XML ....goes ... ...here...</nowiki>|lang=xml}} Of course this only works if you don't have a tag like </nowiki> in your XML.
Added <syntaxhighlight> alternative in r50696.
(In reply to comment #4) > (In reply to comment #2) > > How to escape? None of the following methods work: > > * using <nowiki> tag > > * using <includeonly> tag > > * using < (for obvious reasons) > > > You could try something like > > {{#tag:source|<nowiki>...Your XML > ....goes ... > ...here...</nowiki>|lang=xml}} > > Of course this only works if you don't have a tag like </nowiki> in your XML. > Put <nowiki> before and after the XML code defeats the purpose of this extension. It's to highlight the codes with colors and formatting. Syntax highlight is disabled when inside <nowiki>. After all I think either option (a) or (b) is the ideal way to solve this problem. It seems solved now. :)