The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации / Документация по FreeBSD / Руководства по FreeBSD на английском

3.5. Comments

Comments are an SGML construction, and are normally only valid inside a DTD. However, as Section 3.4 shows, it is possible to use SGML syntax within your document.

The delimiter for SGML comments is the string ``--''. The first occurence of this string opens a comment, and the second closes it.

Example 3-8. SGML generic comment

    <!-- test comment -->
    <!-- This is inside the comment -->
    
    <!-- This is another comment    -->
    
    <!-- This is one way
         of doing multiline comments -->
    
    <!-- This is another way of   --
      -- doing multiline comments -->

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.

Example 3-9. Errorneous SGML comments

    <!-- 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.

3.5.1. For you to do...

  1. Add some comments to example.sgml, and check that the file still validates using nsgmls(1)

  2. Add some invalid comments to example.sgml, and see the error messages that nsgmls(1) gives when it encounters an invalid comment.

For questions about FreeBSD, e-mail <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру