Topic on Extension talk:SyntaxHighlight

Jump to navigation Jump to search
Sokote zaman (talkcontribs)


I use this template:

<div style="overflow-x: auto;">
<div style="padding: 8px 20px;margin-bottom: 25px; text-align: {{{align}}};direction: {{{ltr}}}; clear: both; box-shadow: none!important; overflow-x: auto; background-color: none;"><h3>{{{title|}}}</h3>
 <!--[[Image:Crystal Clear action apply.png|25px]]-->
|{{#tag:syntaxhighlight|{{{source|{{{1|}}}}}}|lang="{{{lang|html}}}"|highlight="{{{highlight|}}}"|enclose="div"|line="y"|style="border-left: 4px solid #4CAF50; background: none;"}}
|{{#tag:syntaxhighlight|{{{source|{{{1|}}}}}}|lang="{{{lang|html}}}"|highlight="{{{highlight|}}}"|enclose="div"|style="border-left: 4px solid #4CAF50; background: none;"}}
<div style="text-align: right; clear: both;">{{Clickable button 2|{{{textbutton|مشاهدهٔ نتیجه »}}}|class=mw-ui-{{{colorbutton|progressive}}}|url={{{dars|}}}/{{{link|}}}&type={{{output|client}}}}}

But after the article in the source section, for example:

<!--This is a comment. Comments are not displayed in the browser-->

<p>This is a paragraph.</p>

I put, the output shows only this:

<p>This is a paragraph.</p>

And does not show this part:

<!--This is a comment. Comments are not displayed in the browser-->

What is the problem?

Thank you for your help


PerfektesChaos (talkcontribs)

Two issues at first glance:

  1. Please omit quotes when providing wiki parameters, they will be put around again: |lang={{{lang|text}}}
  2. If the comment is really part of the source input, it will be displayed. However, I guess it will we removed already when you provide your input. You will need some smart method for encoding to keep it alive.
Sokote zaman (talkcontribs)

Thank you for your reply

I " picked the quote

Did not matter and re-show comments in the output

If possible explain more


PerfektesChaos (talkcontribs)
  • You are feeding your template from somewhere.
  • When you are providing parameter values, any comment will be removed and the template or module code will never ever know about that comment.
  • When you are feeding your template code, it will not know about any comment.
  • You need to escape e.g. the leading < but resolve that before further processing. Not easy and not possible to explain here since quite tricky.
Tacsipacsi (talkcontribs)

(edit conflict) When you use the {{#tag: form, the wikitext is preprocessed before passing it to SyntaxHighlight. This includes substituting template parameters, which you want to take advantage of, but also includes removing HTML-style comments (just like they are removed from the HTML output). I found that <nowiki/> can be used to prevent them from being processed as comments:

{{Template|source=<!-<nowiki/>-This is a comment. Comments are not displayed in the browser-->

<p>This is a paragraph.</p>}}

(I’d probably “break” the closing --> as well: while it’s not needed for this example to work, not “breaking” it can lead to unexpected results when one wants to comment out this part of the article.)

Sokote zaman (talkcontribs)


Thank you for your guidance

My problem was solved

Thanks & Regards

Reply to "not show comment"