Help:Comment tags

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins, Researchers +/-

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]