Topic on Extension talk:SyntaxHighlight

Advanced and transclusion

3
Dpleibovitz (talkcontribs)

The advanced section suggest using tags unmodified. If I use both noinclude and onlyinclude tags (within SyntaxHighlight) without modification, then SyntaxHighlight itself works perfectly. However, if I transclude that page, the onlyinclude tags are processed, because I assume, the transclusion engine doesn't look at the SyntaxHighlight tagging. I tried all sorts of work arounds ending with using an Xonlyinclude tag instead! PS. I can't surround the entire SyntaxHighlight section with noinclude tags because they also get mixed up with the ones inside the SyntaxHighlight section. Arg!

Is there a way of putting in something that looks like onlyinclude (and noinclude), that copy-and-pastes as if that was what they were, but is not looked at by the transclusion engine? Is this a bug with the transclusion engine? One solution with little extra CPU overhead is to allow nesting of noinclude tags, so in my case, if I surrounded the entire section outside SyntaxHighlight with noincludes, everything would come out fine. I would have a balanced nesting level of 2 and only when the 2nd ending is processed would transclussion continue... MediaWiki already supports nestings, but only across different tags and only with each having a depth of 1.

PS. I use MediaWiki 1.30.0. Perhaps this is already resolved...

PerfektesChaos (talkcontribs)

If you are using <syntaxhighlight> you will run into some syntax effects on internal affairs.

  • Reason: It is strongly desired that the presentation shows all printable characters (with some problems on whitespace variants) exactly as-is. Nothing shall be interpreted, whatever it might be, with exception of the closing </syntaxhighlight>.
  • The sequence of include tag processing and syntaxhighlight tag is not really defined; therefore you should not rely on any order and make your things robust.
  • Therefore your stuff might be represented as-is and is not subject to Wikitext parsing and processing.
  • Even more, nobody on upstream software would care about MediaWiki syntax problems.
  • Nobody will change any software to match your needs. That would break other things.
  • The behaviour on include tags goes for 15 years, and syntaxhighlight did not change anything, therefore MW version has no influence.

Solution: Use {{#tag:syntaxhighlight|some code to be parsed|lang=yourLang}} instead.

  • some code to be parsed will be parsed first, and they should obey include tags, if I recall correctly.
  • Be careful with unescaped pipe symbols.
  • After parameter 1 has been parsed as usual, which might contain template transclusions as well, the resulting string will be passed to syntaxhighlight tag.
  • You can even break meaning of include tags by: <<noinclude/>onlyinclude> syntax prevention.
  • In the end you will get a predictable and stable output.

When you transclude a processed page, you get the result of the cached page. In order to change appearance you need to reparse the contents under external conditions.

  • That is done by exposing the original code again.
  • Actually I did not completely understand what you are complaining about, but I am quite sure the remedy will help.
Dpleibovitz (talkcontribs)

Thank-you. Haven't used parser tags before. Still need to add many nowiki and noinclude tags, but at least I can get it to work!

Reply to "Advanced and transclusion"