From: Thomas Walker Lynch
Date: Fri, 28 Aug 2026 03:02:17 +0000 (+0000)
Subject: cleans up counters and sections
X-Git-Url: https://git.reasoningtechnology.com/Realizable_Machine.svg?a=commitdiff_plain;h=46f6cea1f6d17160257937804121674fe90f8470;p=RT-Style
cleans up counters and sections
---
diff --git a/developer/authored/Manuscript.copy/Document/design.html b/developer/authored/Manuscript.copy/Document/design.html
index 1c6ca8f..0798ac9 100644
--- a/developer/authored/Manuscript.copy/Document/design.html
+++ b/developer/authored/Manuscript.copy/Document/design.html
@@ -37,7 +37,7 @@
- Headings capitalize the first word only. This is not house preference but a requirement of the notation: identifiers in this system carry meaning in their case, so , , and must read the same in a heading as in code. Title casing every word makes an ordinary word indistinguishable from an identifier, and worse, makes a genuine identifier look like ordinary title casing. Sentence case keeps the distinction legible. The same rule applies to headings the engine generates for itself, such as a table of contents title.
+ Headings capitalize the first word only. This is not house preference but a requirement of the notation: identifiers in this system carry meaning in their case, so , , and must read the same in a heading as in code. Title casing every word makes an ordinary word indistinguishable from an identifier, and worse, makes a genuine identifier look like ordinary title casing. Sentence case keeps the distinction legible. The same rule applies to headings the engine generates for itself, such as a table of contents title.
@@ -778,18 +778,18 @@
@@ -816,7 +816,7 @@
- The counter is named RT·Section·counter in the source. Whether the trailing word should be counter or count is unsettled: the machine is a counter but the value it holds is a count, and the tag namespace already says Counter.
+ The default counter is named Chapter, and the others in dict_counter are Front Matter and Appendix. These names are not internal: a cross reference reads the counter's name to print the word in front of the number, so what a counter is called is what the reader sees. Counters are named for print, and a name that would embarrass a page is the wrong name.
diff --git a/developer/authored/Manuscript.copy/Document/user.html b/developer/authored/Manuscript.copy/Document/user.html
index 71b2d87..cae3066 100644
--- a/developer/authored/Manuscript.copy/Document/user.html
+++ b/developer/authored/Manuscript.copy/Document/user.html
@@ -18,7 +18,7 @@
@@ -205,7 +205,7 @@
Clones the active count variables into the lookup dictionary. Snapshot processing operates independently of the layout pass, allowing global retrieval regardless of physical placement.
- Retrieves the stored snapshot and projects it as innerHTML.
+ Retrieves the stored snapshot and projects it as innerHTML. See Reading a counter below for the field table.
@@ -250,6 +250,547 @@
+
+ Sections
+
+ <RT·section> is the workhorse of a manuscript. It is not an element with numbering logic of its own: it is a macro that expands into a counter step, a snapshot, and a title. Everything a section can do is therefore something a counter can do, and the counter tags are available directly when a section is not the right shape.
+
+
+
+ Writing a section
+
+ A section takes its heading from an <RT·name> child. Sections nest, and the nesting is the numbering: a section inside a section is numbered one level deeper.
+
+
+ <RT·section id="wire-protocol">
+ <RT·name>Wire protocol</RT·name>
+ <p>Prose belongs here.</p>
+
+ <RT·section>
+ <RT·name>Framing</RT·name>
+ <p>This section numbers one level deeper.</p>
+ </RT·section>
+ </RT·section>
+
+
+ The <RT·name> child is hidden rather than removed, because the counter reads it to populate the name of the step. Do not style it or rely on its position in the flow; its text reaches the page through the title the macro builds.
+
+
+ A title prints the number and then the name. It does not print the name of the counter. A heading that should read Appendix B rather than B is a cross reference, and is written where it is wanted rather than imposed on every section in the book.
+
+
+
+
+ Section attributes
+
+
+ Optional, and worth writing on anything that will be referred to. It does three things at once: it anchors the section for table of contents links, it names the section's counter snapshot, and it is therefore the handle a cross reference reads. Without it the engine allocates an internal name that an author cannot predict.
+
+
+ Optional. Names the counter this section steps. Nested sections inherit it, so it is written once at the top of a division and not repeated. Default: Chapter.
+
+
+
+
+
+ Divisions of a book
+
+ The divisions of a book are not one sequence. A single counter across the whole manuscript would number the preface as chapter one and start the appendices wherever the last chapter left off. So each division names its own counter, and the counter's name is the word the reader sees.
+
+
+
+ The default. Counting numbers at every level: 1, then 1.1, then 1.1.1.
+
+
+ Lower case roman: i, then i.ii.
+
+
+ Upper case letters at the top level and counting numbers below: A, then A.1.
+
+
+
+ <RT·section counter="Front Matter">
+ <RT·name>Preface</RT·name>
+ …
+ </RT·section>
+
+ <RT·section>
+ <RT·name>Getting started</RT·name>
+ …
+ </RT·section>
+
+ <RT·section counter="Appendix" id="app-wire">
+ <RT·name>Wire protocol</RT·name>
+ …
+ </RT·section>
+
+
+ Counters are named for print. A cross reference reads the counter's name to print the word in front of the number, so a name that would embarrass a page is the wrong name.
+
+
+ A counter named on a section but not in the table is still made, on the default numbering. That is how a second appendix sequence or a numbered part is introduced with no configuration at all. To give a new counter a style of its own, add an entry before the document is processed. Put it in a second script element in the head, after the loads, so that the section element has been loaded by the time it runs:
+
+
+ <script>
+ RT.Element.Section.dict_counter['Part'] =
+ { style: 'Roman' ,on_first_step: 'I' };
+ </script>
+
+
+
+
+ What a section does to the page
+
+ Heading size, indent, and opacity all derive from nesting depth; there is nothing to set. A top level section is preceded by a page break unless one is already there, so divisions start on a fresh leaf. Deeper sections do not break.
+
+
+
+
+
+ Reading a counter
+
+ <RT·Counter·read> is how a number reaches the page. It reads a snapshot, never a live counter: a counter's value is a moving thing, and a reference to it has to name the moment it refers to. Snapshots are global, so a read may appear anywhere in the document, before or after the thing it refers to.
+
+
+ <RT·Counter·read snapshot="app-wire" key="counter count"></RT·Counter·read>
+
+
+ The tag is a container and must be closed. Its content is replaced, so anything written inside it is discarded.
+
+
+
+ Where snapshots come from
+
+
+ Every <RT·section> snapshots itself under its id. This is the ordinary way to refer to a section.
+
+
+ An explicit <RT·Counter·snapshot> takes one under a name of your choosing. Use this for figures, tables, and anything counted by a counter of your own.
+
+
+
+
+
+ The key attribute
+
+ key names the fields to emit. It is optional and defaults to count.
+
+
+
+ The formatted number, styled and separated as the counter was configured. This is the default.
+
+
+ The name of the counter, which is the word that belongs in front of the number: Chapter, Appendix, Figure.
+
+
+ The name of the step, which for a section is its title.
+
+
+ The raw level numbers, comma separated, unformatted. Diagnostic.
+
+
+ The same without the innermost level.
+
+
+ The step name at the innermost level, without the scope correction that step applies. Diagnostic.
+
+
+ empty, preamble, or between. Diagnostic.
+
+
+ The counter's own settings, as configured on its make tag. Diagnostic.
+
+
+
+
+
+ Reading several fields at once
+
+ Fields may be named together, separated by spaces, and are emitted in the order written with a single space between them. This is how a reference reads as a phrase rather than as a number the author has to caption by hand:
+
+
+
+ B
+
+
+ Appendix B
+
+
+ Appendix B Wire protocol
+
+
+
+ An empty field is dropped rather than left as a hanging space, so a read that names a field the counter has nothing for closes up rather than printing a gap.
+
+
+
+
+ When a read fails
+
+ A read never throws and never silently vanishes. It prints its complaint where the value would have gone, so a broken reference is visible on the page rather than in a console nobody is reading.
+
+
+
+ No snapshot by that name. Usually a misspelt id, or a snapshot attribute left off entirely.
+
+
+ The snapshot has no such field. Check the field table above.
+
+
+ A snapshot was taken of a counter that had not yet taken a step.
+
+
+
+
+
+
+ Counters of your own
+
+ Figures, tables, equations, exhibits, and requirements are all the same shape: a sequence that numbers, is named, and is referred to from elsewhere. Sections are one instance of that shape, made convenient. The counter tags are the shape itself.
+
+
+
+ The four tags
+
+ <RT·Counter·make counter="Figure" style="CountingNumber" on-first-step="0"></RT·Counter·make>
+
+ <RT·Counter·step counter="Figure">
+ <RT·name>Packet layout</RT·name>
+ <RT·Counter·snapshot counter="Figure" snapshot="fig-packet"></RT·Counter·snapshot>
+ <p><RT·Counter·read snapshot="fig-packet" key="counter count"></RT·Counter·read>: the frame.</p>
+ </RT·Counter·step>
+
+ … and elsewhere in the document …
+
+ As shown in <RT·Counter·read snapshot="fig-packet" key="counter count"></RT·Counter·read>…
+
+
+ Put the make tag once, near the top of the article. Put a step around each item. Take a snapshot inside the step, after at least one step has run, and name it something you will remember. Read it wherever the reference belongs.
+
+
+
+
+ Make attributes
+
+
+ Required. The counter's name, and the word a reference prints in front of the number.
+
+
+ Comma separated, one per nesting level, the last repeating. Default: NaturalNumber.
+
+
+ What the first step reads, written in the counter's own top level style: on-first-step="A" for a counter styled Alpha. Default: the style's zero.
+
+
+ What goes between levels. Default: a period.
+
+
+ embedded, or embedded-after to place a trailing separator after the last level. Default: embedded.
+
+
+ scoped or milestone. A scoped counter drops the innermost level once a scope closes, which is what nested sections want. A milestone counter keeps it, which is what a page number wants. Default: scoped.
+
+
+
+
+
+ Number styles
+
+
+ 0, 1, 2, 3. Counts from zero.
+
+
+ 1, 2, 3, 4. Counts from one.
+
+
+ I, II, III, IV.
+
+
+ i, ii, iii, iv.
+
+
+ A, B, C, D.
+
+
+ a, b, c, d.
+
+
+ A shorthand, not a style. Expands to Roman, Alpha, roman, alpha, CountingNumber, which is the classical outline sequence: I, then I.A, then I.A.i.
+
+
+
+
+
+ Step and snapshot attributes
+
+
+ Required. Which counter to step. A step inside another step of the same counter numbers one level deeper.
+
+
+ Optional. Names the step, and is what key="step" reads back.
+
+
+ Required. Which counter to snapshot.
+
+
+ Required. The name the snapshot is filed under, and the name a read asks for.
+
+
+
+ Steps also carry splitable, continued, continuation, and split-id. These are written by the paginator when a scope crosses a page boundary. They are not authored.
+
+
+
+
+
+ Cross references and page numbers
+
+ There are two kinds of reference, and they answer different questions. A counter read answers what is it called. A note read answers where is it. A full reference usually wants both.
+
+
+
+ Referring to a section
+
+ Give the section an id and read its snapshot. Wrap the reference in an anchor if it should also be clickable.
+
+
+ <RT·section counter="Appendix" id="app-wire">
+ <RT·name>Wire protocol</RT·name>
+ …
+ </RT·section>
+
+ … described in
+ <a href="#app-wire"><RT·Counter·read snapshot="app-wire" key="counter count"></RT·Counter·read></a>,
+ <RT·Counter·read snapshot="app-wire" key="step"></RT·Counter·read>.
+
+
+ That reads: described in Appendix B, Wire protocol. Neither the letter nor the title is repeated by hand, so neither can fall out of step with the section itself.
+
+
+
+
+ Referring to a page
+
+ A page number is not known until the document has been paginated, which is why it is a separate mechanism. Mark the target with <RT·Note·write> and read it with <RT·Note·read>.
+
+
+ <RT·name><RT·Note·write key="env-setup">Article environment</RT·Note·write></RT·name>
+
+ … see <RT·Note·read key="env-setup"></RT·Note·read>
+ on page <RT·Note·read key="env-setup" field="page"></RT·Note·read>.
+
+
+
+ The content that was wrapped by the write tag. This is the default.
+
+
+ The number of the page the write tag landed on, after pagination.
+
+
+
+ A read against a key that was never written prints [Unknown note: k]; an unknown field prints [Invalid field: f].
+
+
+
+
+
+
+
+ The order things happen in
+
+ Knowing the schedule explains most of what would otherwise look arbitrary: why a page number can be referenced at all, why a counter read may appear before the thing it refers to, and why nothing an author writes needs to be in dependency order.
+
+
+
+ The theme is compiled into a layout configuration.
+
+
+ Generators expand and elements are styled. Sections become counter steps here.
+
+
+ The continuous document is sliced into pages.
+
+
+ Page geometry is applied.
+
+
+ Counters are walked and every read is resolved. After pagination, because a page number is itself a counter.
+
+
+ Cross references are resolved. After counters, because a reference target may contain a counter value.
+
+
+ Pages that overflowed are grown. This phase only ever grows a page; it never moves content between pages, because that would change page numbers, which would change reference lengths, which would move more content.
+
+
+
+ The consequence for an author is that document order does not matter to a reference. A read placed in chapter one may name a snapshot taken in an appendix, because every snapshot has been taken before any read is resolved.
+
+
+
+
+ A worked document
+
+ Everything above, assembled. A title page that is not numbered, front matter in roman, chapters, an appendix, a figure counter of the author's own, and references that survive the material being moved.
+
+
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <title>Wire Protocol Handbook</title>
+ <script src="RT-Manuscript_locator.js"></script>
+ <script>
+ window.RT.theme_preference('inverse_wheat');
+ window.RT.load('Layout/paginate');
+ window.RT.load('Layout/article_tech_ref');
+ window.RT.load('Element/theme_selector');
+ </script>
+ <script>
+ RT.Element.Section.dict_counter['Part'] =
+ { style: 'Roman' ,on_first_step: 'I' };
+ </script>
+ </head>
+ <body>
+ <RT·theme-selector></RT·theme-selector>
+ <RT·article>
+
+ <RT·page no-number>
+ <RT·title
+ title="Wire Protocol Handbook"
+ author="A. Author"
+ date="2026-08-28"
+ copyright="2026 Reasoning Technology">
+ </RT·title>
+ </RT·page>
+
+ <RT·TOC level="1-2"></RT·TOC>
+
+ <RT·Counter·make counter="Figure" style="CountingNumber" on-first-step="0"></RT·Counter·make>
+
+ <RT·section counter="Front Matter" id="preface">
+ <RT·name>Preface</RT·name>
+ <p>Numbered i, and its subsections i.ii and so on.</p>
+ </RT·section>
+
+ <RT·section id="ch-framing">
+ <RT·name>Framing</RT·name>
+ <p>
+ A <RT·term>frame</RT·term> is the unit of transmission.
+ Its layout is given in
+ <RT·Counter·read snapshot="fig-packet" key="counter count"></RT·Counter·read>,
+ and the encoding rules in
+ <a href="#app-wire"><RT·Counter·read snapshot="app-wire" key="counter count"></RT·Counter·read></a>.
+ </p>
+
+ <RT·Counter·step counter="Figure">
+ <RT·name>Packet layout</RT·name>
+ <RT·Counter·snapshot counter="Figure" snapshot="fig-packet"></RT·Counter·snapshot>
+ <RT·grid major="x">
+ <RT·e type="x-label" y="0" x="1">Octets</RT·e>
+ <RT·e type="y-label" y="1" x="0">header</RT·e>
+ <RT·e type="data">4</RT·e>
+ </RT·grid>
+ <p style="text-align: center;">
+ <RT·Counter·read snapshot="fig-packet" key="counter count step"></RT·Counter·read>
+ </p>
+ </RT·Counter·step>
+
+ <RT·section>
+ <RT·name>Escaping</RT·name>
+ <p>Numbered one level deeper than its parent.</p>
+ </RT·section>
+ </RT·section>
+
+ <RT·section counter="Appendix" id="app-wire">
+ <RT·name>Wire protocol</RT·name>
+ <p>
+ Introduced in
+ <RT·Note·read key="framing-intro"></RT·Note·read>,
+ on page <RT·Note·read key="framing-intro" field="page"></RT·Note·read>.
+ </p>
+ </RT·section>
+
+ </RT·article>
+ </body>
+ </html>
+
+
+ The forward reference in ch-framing to a figure that has not yet been stepped, and to an appendix that comes later in the file, both resolve. The backward reference from the appendix to a note written in the chapter resolves too, and carries a page number that nothing in the source states.
+
+
+
+
+ Reserved names and common mistakes
+
+
+ Names the engine uses
+
+ Counters are a single flat namespace. A counter of your own that collides with one of these will be stepped by the engine as well as by you, and the numbering will be wrong in a way that is tedious to trace.
+
+
+
+ The section element. Safe to step by writing sections; do not step directly.
+
+
+ The paginator.
+
+
+ The endnote element.
+
+
+ A snapshot name, not a counter. Taken by the paginator for each numbered leaf. Read page numbers through <RT·Note·read field="page"> rather than by naming these.
+
+
+
+
+
+ Mistakes worth knowing about in advance
+
+
+ The separator is a middle dot, not a period or a hyphen. On macOS: Option + Shift + 9. On Windows: Alt and 0183 on the numeric keypad. On Linux: Compose, then period, then hyphen.
+
+
+ Every RT tag is a container and must be closed. <RT·Counter·read /> is not a closed tag in HTML and swallows the rest of the document.
+
+
+ The snapshot attribute was omitted. There is no default and no reading of a live counter.
+
+
+ A <RT·code> whose opening and closing tags are on the same line is inline; anything containing a newline is a block. The same rule applies to <RT·math>.
+
+
+ The title comes from an <RT·name> child. A section without one numbers correctly and prints no name.
+
+
+ Decorate every occurrence of a term, not just the first. The first is styled and given an id; later ones are recognised and left plain.
+
+
+ Top level sections already insert a page break. Writing one as well produces an empty leaf.
+
+
+
+
+
Global widgets
@@ -258,7 +799,6 @@
-