Comment

Comment removes Line Break

Similar to how a trailing “\” removes the following line break, a leading comment will remove the previous line break.

The first line ends in a backslash\
Second line

Result:
The first line ends in a backslashSecond line
The first line
[!----]Second line starts with a comment

Result:
The first lineSecond line starts with a comment

Nested comments?

Can you comment out a a section of code that itself may contain comments?

Standard Method

The standard method doesn't work. The starting comment is ended by the end of first nested comment.

Code before commented section
[!--
A section of ``code'' containing @@a@@ [!-- nested --] comment
--]
Code after commented section

Result:
Code before commented section comment
—]
Code after commented section

Extended Method

To comment out a code section that may contain nested comments use

  • "[!--", "[[code]]" as a comment start and
  • "[[/code]]", "--]" as end comment
Code before commented section
[!--
[[code]]
A section of ``code'' containing @@a@@ [!-- nested --] comment
[[/code]]
--]
Code after commented section

Result:
Code before commented section
Code after commented section
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-NoDerivs 3.0 License