Help:Comment tags

From Meta, a Wikimedia project coordination wiki

Comment tags and what is between them are removed on expansion of the wikitext. In the case of one or more comments separated by single newlines, the newlines before, between, and after these count as not more than one. If such sequences are separated by e.g. two newlines, this rule applies separately for each sequence.

wikitext result of expanding
a<!--foo-->b

a
<!--foo-->b

a <!--foo
-->b

a<!--foo-->
b

a
<!--foo-->
b

a<!--foo-->
<!--foo-->b

a
<!--foo-->
<!--foo-->b

a<!--foo-->
<!--foo-->
b

a
<!--foo-->
<!--foo-->
b

a<!--foo--> <!--foo-->b

a
<!--foo--> <!--foo-->b

a<!--foo--> <!--foo-->
b

a
<!--foo--> <!--foo-->
b


a<!--foo-->

<!--foo-->b

a
<!--foo-->

<!--foo-->b

a<!--foo-->

<!--foo-->
b

a
<!--foo-->

<!--foo-->
b
ab

a
b

a
b

a
b

a
b

a
b

a
b

a
b

a b

a
 b

a 
b

a
 
b


a

b

a

b

a

b

a

b

Here is a re-do of the above table, since some items above don't line up, are missing, or appear to be inaccurate. A 3rd column is added with results from the Wikipedia sandbox on Dec. 26 2013, including surrounding HTML source tags, to see exactly what is happening.

wikitext	                      result of expanding
                             supposed    source code from Wikipedia:Sandbox
 
a<!--foo-->b                    ab         <p>ab</p>

a                               a          <p>a b</p>
<!--foo-->b                     b

a <!--foo                       a          <p>a b</p>
-->b                            b

a<!--foo-->                     a          <p>a b</p>
b                               b

a                               a          <p>a b</p>
<!--foo-->                      b
b

a<!--foo-->                     a          <p>a b</p>
<!--foo-->b                     b

a                               a          <p>a b</p>
<!--foo-->                      b
<!--foo-->b

a<!--foo-->                     a          <p>a b</p>
<!--foo-->                      b
b

a                                          <p>a b</p>
<!--foo-->
<!--foo-->
b

a<!--foo--> <!--foo-->b         a b        <p>a b</p>

a                               a          <p>a</p>
<!--foo--> <!--foo-->b           b         <pre>
                                           b
                                           </pre>

a<!--foo--> <!--foo-->          a          <p>a b</p>
b                               b

a                               a          <p>a b</p>
<!--foo--> <!--foo-->
b                               b

a<!--foo-->                     a          <p><br />
                                           a</p>
 *
<!--foo-->b                     b          <p>b</p>

a                               a          <p>a</p>
<!--foo-->

<!--foo-->b                     b          <p>b</p>

a<!--foo-->                     a          <p>a</p>

<!--foo-->                      b          <p>b</p>
b

a                               a          <p>a</p>
<!--foo-->

<!--foo-->                      b          <p>b</p>
b

Substitution[edit]

Preservation of comment tags on substitution can be useful to have a record in the wikitext on how it was produced, but it may also give undesirable clutter, with comments that do not make sense in the context of the resulting wikitext.

For preservation on substitution there are the following options:

  • always preserve: just put the comment tags
  • never preserve: put the comment tags in <noinclude> tags
  • control preservation: instead of comment tags, use Template:Void as follows:
{{{{{|safesubst:}}}void|..}} with the comment at the dots.

Parameter tags inside comment tags do not work, but they do in the void-method.

All this can be tried out with {{subst:Help:Comment tags/1|7}} and {{subst:Help:Comment tags/1|=|7}}, which substitute Help:Comment tags/1. The first removes the controllable comments, the second does not.

See also[edit]

Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences
Editing
Starting a new page · Advanced editing · Editing FAQ · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URL · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · Lists · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Magic words · System message · Substitution · Array · Calculation · Transclusion
Others
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors
Other languages: