Last modified: 2012-05-23 08:34:37 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20820, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18820 - Cannot parse source code containing < source >
Cannot parse source code containing < source >
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
SyntaxHighlight (GeSHi) (Other open bugs)
unspecified
All All
: Normal major (vote)
: ---
Assigned To: Nobody - You can work on this!
http://bestbrute.wikia.com/index.php?...
:
Depends on: 37042
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-17 08:29 UTC by Ronga
Modified: 2012-05-23 08:34 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ronga 2009-05-17 08:29:29 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!
Comment 1 Niklas Laxström 2009-05-17 08:34:18 UTC
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.
Comment 2 Ronga 2009-05-17 15:10:41 UTC
How to escape? None of the following methods work:
* using <nowiki> tag
* using <includeonly> tag
* using &#60; (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!
Comment 3 Niklas Laxström 2009-05-17 15:30:09 UTC
(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.
Comment 4 P.Copp 2009-05-17 15:48:01 UTC
(In reply to comment #2)
> How to escape? None of the following methods work:
> * using <nowiki> tag
> * using <includeonly> tag
> * using &#60; (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.
Comment 5 Niklas Laxström 2009-05-17 15:52:46 UTC
Added <syntaxhighlight> alternative in r50696.
Comment 6 Ronga 2009-05-17 20:54:31 UTC
(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 &#60; (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. :)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links