Comments are an SGML construction, and are normally only valid inside a DTD. However, as 節 3.4, “Escaping back to SGML” shows, it is possible to use SGML syntax within your document.
The delimiter for SGML comments is the string
“--
”. The first occurrence of this string
opens a comment, and the second closes it.
<!-- 測試註解 -->
<!-- 這是註解 --> <!-- 這也是註解 --> <!-- 要寫多行註解的話, 這是其中之一的方式 --> <!-- 要寫多行註解, -- -- 也可以這樣子用 -->
If you have used HTML before you may have been shown different rules
for comments. In particular, you may think that the string
<!--
opens a comment, and it is only closed by
-->
.
This is not the case. A lot of web browsers have broken HTML parsers, and will accept that as valid. However, the SGML parsers used by the Documentation Project are much stricter, and will reject documents that make that error.
<!-- This is in the comment -- THIS IS OUTSIDE THE COMMENT! -- back inside the comment -->
The SGML parser will treat this as though it were actually:
<!THIS IS OUTSIDE THE COMMENT>
This is not valid SGML, and may give confusing error messages.
<!----- This is a very bad idea ----->
As the example suggests, do not write comments like that.
<!--===================================================-->
That is a (slightly) better approach, but it still potentially confusing to people new to SGML.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.