title CNM selectors (draft) content section Overview text fmt This draft tries to specify CNM content selectors: query strings that identify specific sections in a CNM document. section Syntax text fmt The CNM content selector is usually present in the hash fragment of a URL or in the ``select=cnm:`` parameter of @@/draft/old/cnp-select/ CNP selectors@@. The syntax of the selector is one of the following: raw /{section_path} #{section_title} ${section_index_path} !/{section_path} !#{section_title} !${section_index_path} text fmt ``{section_path}`` is a slash-separated path of percent-encoded section titles in the document hierarchy from the ``content`` block to the target section. If the parent section of the target has multiple child sections with the same title, the first one is selected. ``{section_title}`` is a precent-encoded title of an individual section anywhere in the document. This selects the first section with this title. ``{section_index_path}`` is a dot-separated path of section indexes, with the first section in the given parent section or the ``content`` block having the index ``1``. When any of the three above selectors are empty, the entire ``content`` block is selected. When selecting content (as with a @@/draft/old/cnp-select/ CNP selector@@) rather than just the start of a section (like with a page anchor in the hash fragment of the URL), a standard selector selects the section, all its parents without their siblings and the entire content of the section. If the selector is prefixed with ``!`` (shallow selector), all contents of child sections of the selected block are also omitted. The ``!`` selector prefix is only valid when selecting content. An empty selector selects the entire document, including non-``content`` top-level blocks (an identity mapping of the document), with the anchor selecting the top of the document. An empty ``!`` shallow selector selects the top-level document and content block, including section name lines, but omits the contents of all sections. With the following document: raw text/cnm title Test content section Foo section Bar section Baz text Test 1 section Quux text Test 2 section Bar text Test 3 text Test 4 section Quux text Test 5 section Bar text Test 6 text Test 7 text fmt The following selectors select the section ``Bar`` containing the section ``Baz`` and ``text`` containing ``Test 4``: list text fmt ``/Foo/Bar`` text fmt ``#Bar`` text fmt ``$1.1`` text fmt The following selectors select the section ``Bar`` containing ``Test 3``: list text fmt ``/Foo/Bar/Baz/Bar`` text fmt ``$1.1.1.2`` text fmt And only the following selector selects the ``Bar`` with ``Test 6``: list text fmt ``$1.3`` text fmt The following selector selects the ``Quux`` section containing ``Test 2`` and not the one containing ``Test 5``: list text fmt ``#Quux`` text fmt The content selector ``/Foo/Bar/Baz`` selects the following content: raw text/cnm content section Foo section Bar section Baz text Test 1 section Quux text Test 2 section Bar text Test 3 text fmt And the shallow content selector ``!/Foo/Bar/Baz`` selects the following: raw text/cnm content section Foo section Bar section Baz text Test 1 section Quux section Bar text fmt An empty selector selects the entire document unchanged. An empty shallow selector ``!`` selects the following: raw text/cnm title Test content section Foo text Test 7 text fmt An example URL that includes a CNM selector as an anchor is ``cnp://example.com/file.cnm##Bar`` for the section title selector ``#Bar``. Content selectors are used in the @@/draft/old/cnp-select/#/Selectors/cnm CNP selector draft@@. section Functionality text fmt CNM selectors can be used for any task where semantically selecting a section is required. For example, browsers may use CNM selectors to provide anchors within a document and scroll to the appropriate sections when used. CNM selectors can be used to retrieve only a specific subtree of blocks and their parents without siblings within a document's ``content`` block using @@/draft/old/cnp-select/ CNP ``cnm`` selector@@. section Possible changes list text fmt Add the ability to choose N-th section with a specific name in section title path and section title selectors. text fmt Add selectors for non-sections (less semantic?). site draft old cnm-selector links /spec/ Specifications /doc/ Documents /draft/ Drafts /lib/ Libraries /util/ Tools and utilities