From: Thomas Walker Lynch Date: Thu, 25 Jun 2026 07:43:19 +0000 (+0000) Subject: working counter object, will next move to cdot namespacing X-Git-Url: https://git.reasoningtechnology.com/RT-Manuscript_locator.js?a=commitdiff_plain;h=41653b0970a30ea98f04cf94f3020a58fcf467e7;p=RT-Style working counter object, will next move to cdot namespacing --- diff --git a/administrator/tool/RT-style_v2_to_v3 b/administrator/tool/RT-style_v2_to_v3 new file mode 100644 index 0000000..df95092 --- /dev/null +++ b/administrator/tool/RT-style_v2_to_v3 @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +import sys +import os +import re + +def migrate_rt_tags(file_path): + if not os.path.isfile(file_path): + print(f"Error: File '{file_path}' not found.") + sys.exit(1) + + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # 1. Migrate legacy tag terminology to current vocabulary + content = re.sub(r'<(/?)(RT)-index(\b|/|>)', r'<\g<1>\g<2>⋅term-index\g<3>', content) + content = re.sub(r'<(/?)(RT-counter)[_-]init(\b|/|>)', r'<\g<1>\g<2>⋅make\g<3>', content) + content = re.sub(r'<(/?)(RT-counter)[_-]inc(\b|/|>)', r'<\g<1>\g<2>⋅step\g<3>', content) + content = re.sub(r'<(/?)(RT-counter)[_-]label(\b|/|>)', r'<\g<1>\g<2>⋅snapshot\g<3>', content) + + # 2. Migrate the primary RT namespace separator + rt_tags = [ + "article", "memo", "book", "title", "TOC", "term-index", + "endnotes", "term", "term-em", "neologism", "neologism-em", + "code", "math", "symbol", "constraint", "crossref", "ref", + "cite", "footnote", "page", "page-break", "chapter", "theme-selector" + ] + rt_pattern = "|".join(rt_tags) + content = re.sub(rf'<(/?)(RT)-({rt_pattern})(\b|/|>)', r'<\g<1>\g<2>⋅\g<3>\g<4>', content) + + # 3. Migrate the secondary RT-counter namespace separator + counter_tags = ["make", "step", "indent", "snapshot", "read"] + counter_pattern = "|".join(counter_tags) + content = re.sub(rf'<(/?)(RT-counter)[_-]({counter_pattern})(\b|/|>)', r'<\g<1>\g<2>⋅\g<3>\g<4>', content) + + # 4. Migrate the 'initial' parameter to 'on-first-step' within make tags + content = re.sub(r'(]+)initial=', r'\g<1>on-first-step=', content) + + # 5. Migrate 'key="initial"' to 'key="on-first-step"' within read tags + content = re.sub(r'(]+key=[\'"])initial([\'"])', r'\g<1>on-first-step\g<2>', content) + + backup_path = file_path + '.v2.bak' + os.rename(file_path, backup_path) + + with open(file_path, 'w', encoding='utf-8') as f: + f.write(content) + + print(f"Migration complete: {file_path}") + print(f"Original file backed up to: {backup_path}") + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python3 migrate_rt_v3.py ") + sys.exit(1) + + migrate_rt_tags(sys.argv[1]) diff --git a/developer/authored/Manuscript.copy/Document/manual.html b/developer/authored/Manuscript.copy/Document/manual.html new file mode 100644 index 0000000..fd9fd54 --- /dev/null +++ b/developer/authored/Manuscript.copy/Document/manual.html @@ -0,0 +1,255 @@ + + + + + RT Style System: Reference Manual + + + + + + + + + + + + + + +

Layout Environments

+

+ The RT tags are available to be used inside of layout environments. They are: +

+ + + + + + + + + + + + + + + + + + + + + + +
TagDescription
<RT⋅article>Standard technical document layout with dynamic pagination.
<RT⋅memo>Strict print layout (6.5 inch width, serif typography, monochrome).
<RT⋅book>Multi chapter compilation layout (Upcoming).
+ +

Article Environment

+

+ The <RT⋅article> container provides the standard toolset for technical documentation, whitepapers, and specifications. It utilizes dynamic soft limit pagination and responsive ink ratio balancing. +

+ +

Section Generators

+ + + + + + + + + + + + + + + + + + + + + + + + + +
TagDescription
<RT⋅title>Constructs the standardized title block and metadata header.
<RT⋅TOC>Compiles an automatic table of contents by scanning heading depths.
<RT⋅term-index>Compiles an alphabetized glossary of terms defined within the document.
<RT⋅endnotes>Container for extracted bibliographic citations.
+ +

Semantic Tags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TagDescription
<RT⋅term>Standard technical term. Decorates first occurrence and establishes an anchor.
<RT⋅term-em>Forces visual emphasis for a term subsequent to its first occurrence.
<RT⋅neologism>Project specific vocabulary. Styled distinctly from conventional terms.
<RT⋅neologism-em>Forces visual emphasis for a neologism subsequent to its first occurrence.
<RT⋅code>Code span or pre formatted code block with theme aware borders.
<RT⋅math>Inline or block mathematics evaluated by MathJax.
<RT⋅symbol>Technical symbol wrapper enforcing strict font weight and character spacing.
<RT⋅constraint>Highlights architectural limits or hard requirements in a distinct block.
+ +

Declarative Counters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TagDescription
<RT-counter⋅make>Declares an empty named counter sequence (e.g., figure, equation).
<RT-counter⋅step>Advances the counter from empty or increments to the next ordinal address.
<RT-counter⋅indent>Pushes a new structural depth onto the tracking stack.
<RT-counter⋅snapshot>Deep copies the active count and styling parameters to a dictionary key.
<RT-counter⋅read>Recalls a saved count or format parameter from the snapshot dictionary.
+ +

References and Citations

+ + + + + + + + + + + + + + + + + + + + + + + + + +
TagDescription
<RT⋅crossref>Context aware internal anchor link.
<RT⋅ref>Dynamic reference evaluating to a structural target.
<RT⋅cite>Bibliographic citation marker mapping to the endnotes block.
<RT⋅footnote>Inline text extracted and appended to the bottom of the active page.
+ +

Pagination Control

+ + + + + + + + + + + + + + + + + +
TagDescription
<RT⋅page>Automatically generated boundary container. Do not author manually.
<RT⋅page-break>Explicit directive forcing subsequent content to the next page container.
+ +

Memo Environment

+

+ The <RT⋅memo> container inherits all valid tags from the Article environment but overrides the global CSS to enforce a static, print ready monochrome aesthetic. +

+ +

Book Environment

+

+ The <RT⋅book> container is reserved for multi chapter compilations. It introduces tags designed exclusively for macro level document orchestration. +

+ +

Book Specific Tags

+ + + + + + + + + + + + + +
TagDescription
<RT⋅chapter>Chapter heading. Implies a page break, inherits standard H1 typography, and registers as a top level division in the TOC.
+ +

Global Widgets

+ + + + + + + + + + + + + +
TagDescription
<RT⋅theme-selector>Floating interactive widget permitting real time swapping of visual themes.
+ +
+ + diff --git a/developer/authored/Manuscript.copy/Document/style_manual.html b/developer/authored/Manuscript.copy/Document/style_manual.html deleted file mode 100644 index 16d795f..0000000 --- a/developer/authored/Manuscript.copy/Document/style_manual.html +++ /dev/null @@ -1,413 +0,0 @@ - - - - - RT Style System - - - - - - - - - - - - - - Table of custom tags - -

Style tag reference

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TagDescription
<RT-article>Article container.
<RT-title> - Title block and metadata. -
<RT-TOC>Compiles TOC.
<RT-index>Compiles an alphabetical glossary of defined terms.
<RT-term>Conventional term.
<RT-term-em>Forces emphasis for a term even after first occurrence.
<RT-neologism>Project specific term.
<RT-neologism-em>Forces emphasis for a neologism even after first occurrence.
<RT-code>Code span or code block.
<RT-math>Inline or block math.
<RT-footnote>Inline text to be extracted and rendered at the bottom of the page.
<RT-cite>Bibliographic citation marker.
<RT-ref>Dynamic cross reference to another element in the document.
<RT-page>Automatically inserted pagination container.
<RT-chapter>Chapter heading with implied page break.
<RT-page-break>Explicit page break directive. Must be explicitly closed.
- - Architecture overview -

- The RT Style System is a client-side, JavaScript-driven publishing framework designed to turn raw HTML into high-readability technical documentation. Unlike standard CSS frameworks, RT uses JavaScript to handle complex layout tasks like ink-ratio balancing and dynamic pagination. -

- -

Pulling style files into a document

-

Put `setup.js` in the directory, and include it at the top of the document, - `setup.js` points at the style files and is installation specific.

- - - Semantic tags -

- The system relies on a specific set of custom tags in the RT- namespace to separate meaning from presentation. -

- -

Terminology

- -

Conventional terms

-

- Use <RT-term> for standard, industry accepted technical terms. The system decorates only the first occurrence of each unique term so that the first appearance functions as a definition point, and later appearances do not overload the page with styling. -

- - - The Singleton Pattern restricts instantiation... - - -

- Renders as: The Singleton Pattern restricts instantiation... -

- -

Neologisms

-

- Use <RT-neologism> for terms invented specifically for the current document or project. Neologisms are styled more strongly than conventional terms, visually distinguishing "jargon you should know" from "jargon we invented." -

- - - We define the Hyper Tape as a construct... - - -

- Renders as: We define the Hyper Tape as a construct... -

- -

First occurrence rule

-

- The term system is intentionally conservative. For the tags <RT-term> and <RT-neologism>, only the first occurrence of a unique term is decorated. Subsequent mentions are rendered as normal prose. -

- -

- Uniqueness is tracked by normalizing the term text (trimmed, then lowercased). This means that Symbol and symbol count as the same term. -

- -

Forced emphasis variants

-

- Sometimes a later mention of a term should be emphasized again. For that purpose, the system provides explicit emphasis tags: -

- -
    -
  • <RT-term-em>
  • -
  • <RT-neologism-em>
  • -
- -

- These variants are always decorated, even if the term appeared earlier. -

- -

Automatic definition anchors

-

- For first occurrences, the term module automatically assigns an id attribute if one does not already exist. This establishes stable anchors for future indexing and linking. -

- - - We define a Symbol as... - - -

- The first occurrence will be given an id similar to def-symbol. For neologisms, an additional marker is used, for example def-neo-hyper-tape. -

- -

Technical content

- -

Code

-

- Use <RT-code>. If placed inline, it acts like a span. If placed as a block (with newlines), it acts like a pre formatted block with a theme aware border. -

- - - # Block Code Example - def hello(): - return "World" - - -

Mathematics

-

- Use <RT-math>. The system auto detects if it is a block equation or inline variable and wraps it in MathJax delimiters. -

-

- Inline: Let x be the input. -

-

- Block: -

- - f(x) = \sum_{i=0}^{n} x_i - - -

References, citations, and indexing

- -

Footnotes

-

- Use <RT-footnote> to author footnote content directly inline with the text it references. During the layout phase, the pagination engine extracts the text, replaces the element with an invisible structural marker, and compiles a formatted footnote container at the bottom of the active <RT-page>. -

- -

Citations

-

- Use <RT-cite> with the ref attribute to insert bibliographic citations. This ensures formatting remains consistent and separates citation data from standard prose. -

- - ... formalized as Basic Law V . - - -

Dynamic cross referencing

-

- A person authoring a technical document frequently refers back to tables, equations, or previous sections. Use <RT-ref target="element-id"> to link to specific content. This tag dynamically retrieves the numbering or caption of the target element, maintaining correct references even if preceding elements shift during editing. -

- -

Glossary indexing

-

- Use <RT-index> at the end of the document to compile a glossary. Similar to the TOC compiler, this tag scans the DOM for automatic definition anchors produced by the term module and generates an alphabetized list of defined terms and neologisms. -

- - Navigation and layout - -

Automatic table of contents

-

- Use <RT-TOC> to insert a compiled table of contents. The tag scans the document forward from its current position to collect headings. -

- -

Explicit mode

-

- Use the level="N" attribute to target a specific heading depth. -

-
    -
  • <RT-TOC level="1">: Collects all <h1> elements until the end of the document. Best for the main document index.
  • -
  • <RT-TOC level="2">: Collects all <h2> elements until it encounters the next <h1>. Best for chapter summaries.
  • -
- -

Implicit mode

-

- If no level is specified, the TOC scans backwards to find the nearest heading (for example H1) and assumes you want to collect children one level deeper (for example H2). -

-

- Note: Implicit mode can fail if placed before the first heading of a section. Use explicit levels for robust results. -

- -

The title block

-

- Use <RT-title> as the first element in your <body> (before the article container). This tag produces a standardized, styled header block with the document title and metadata. -

- -

Attributes

-
    -
  • title (Required): The main heading of the document.
  • -
  • author (Optional): The author's name. Renders in a bold accent color.
  • -
  • date (Optional): The publication or revision date.
  • -
- -

Example

- - - - - -

- Renders as: A centered, high contrast H1 followed by a serif styled metadata row containing the author and date. -

- -

The article container

-

- The root element must be <RT-article>. This is the boundary for the pagination logic. -

- -

Pagination

-

- The script paginate_by_element.js scans the article. It calculates the height of every element (including margins) and bundles them into <RT-page> elements. -

-

- Soft Limit Pagination: The system attempts to keep headers with their following paragraphs. It will break a page early rather than stranding a header at the bottom. -

- -

Manual page breaks and chapters

-

- A person can assert explicit control over the layout engine using the <RT-page-break></RT-page-break> tag. This tag forces the engine to close the current page and push all subsequent content to the top of the next page. Standard HTML5 parsing requires this custom tag to be explicitly closed; self-closing syntax will fail. -

-

- For major document divisions, use <RT-chapter>. The semantic processor translates this tag into an <RT-page-break> followed by an <h1 class="RT-chapter">. This ensures the chapter starts on a new page, inherits standard typography, and is automatically indexed by the TOC engine. -

- - Debugging - -

Debug tokens

-

- RT provides a lightweight debug logging system in utility.js. Logging is controlled by a set of active debug tokens. Each log message is assigned a token, and the message prints only if that token is enabled. -

- -

- Examples of common tokens include style, layout, pagination, selector, config, and term. -

- -

How logging is gated

-

- Normal log and warning output are gated. The methods debug.log(token,message) and debug.warn(token,message) will print only when the token exists in debug.active_tokens. -

- -

- This prevents the console from being flooded during normal use, while still allowing deep visibility during development. -

- -

Errors are always printed

-

- Errors are treated differently. The method debug.error(token,message) always prints, regardless of token state. These messages represent failures that require attention. -

- -

Enabling and disabling tokens

-

- Tokens are enabled or disabled in two ways: by editing the active_tokens set in utility.js, or at runtime by calling: -

- - - window.RT.debug.enable('term') - window.RT.debug.disable('term') - - -

- For example, the term system (RT_term.js) uses the term token. When that token is enabled, the module will print messages describing how terms were detected and which term definitions were assigned IDs. -

- - Themes -

- The system supports hot swapping themes by changing the script import in the head. -

-
    -
  • Dark: style/theme_dark_gold.js (Default)
  • -
  • Light: style/theme_light_gold.js
  • -
- - Manifest - - 2. utility.js (Math/Color physics) - 3. article_tech_ref.js (Typography and CSS injection) - 4. RT_code.js (Code block logic) - 5. RT_math.js (MathJax wrapper) - 6. RT_term.js (Term styling) - 7. RT_TOC.js (Navigation generator) - 8. paginate_by_element.js (Page splitter) - 9. page_fixed_glow.js (Visual page container) - - - RT conventions -

Headings are first letter capitalized. Remaining words are as they would be in English prose.

- - Exercises - -
    -
  1. -

    - Term occurrences: If an author tags a word with <RT-term> five times in a document, how many times will the term be visually decorated by the styling engine? How does a person force the engine to decorate a later occurrence? -

    -
  2. -
  3. -

    - Term normalization: A person writes <RT-term>Parse Tree</RT-term> in paragraph one, and <RT-term>parse tree</RT-term> in paragraph two. Will the system assign a definition anchor to the second occurrence? -

    -
  4. -
  5. -

    - TOC compilation: What happens if a person places an <RT-TOC> tag without a level attribute before the first heading of a section? -

    -
  6. -
  7. -

    - Code and math formatting: How does the RT system determine whether to render an <RT-code> or <RT-math> element inline with the text versus as a standalone block? -

    -
  8. -
  9. -

    - Pagination logic: When the script bundles elements into an <RT-page> container, how does the soft limit pagination handle a heading that falls at the very bottom of the page capacity? -

    -
  10. -
- -
- - diff --git a/developer/authored/Manuscript.copy/Element/counter.js b/developer/authored/Manuscript.copy/Element/counter.js index 633b387..f3693db 100644 --- a/developer/authored/Manuscript.copy/Element/counter.js +++ b/developer/authored/Manuscript.copy/Element/counter.js @@ -1,105 +1,202 @@ window.RT = window.RT || {}; -window.RT.dict_label = {}; + +window.RT.dict_counter = {}; +window.RT.dict_snapshot = {}; + +function clone_counter_state(state) { + return { + counter: state.counter, + stack: [...state.stack], + empty: [...state.empty], + separator: state.separator, + 'separator-placement': state['separator-placement'], + style: state.style, + 'on-first-step': state['on-first-step'], // The literal string authored + count: state.count + }; +} window.RT.counter_do_count = function (root_node) { - let counters_state = {}; - - function walk(node) { - if (node.nodeType !== Node.ELEMENT_NODE) return; - - const tag = node.tagName.toLowerCase(); - let pushed_name = null; - - if (tag === 'rt-counter-init') { - const name = node.getAttribute('name'); - if (name) { - let initial_val = parseInt(node.getAttribute('initial'), 10); - if (isNaN(initial_val)) { - initial_val = 1; - } - - counters_state[name] = { - stack: [initial_val - 1], - separator: node.getAttribute('separator') || '.', - style: node.getAttribute('style') || 'Natural', - initial: initial_val, - current_count_str: '' - }; - } - } else if (tag === 'rt-counter-indent') { - const name = node.getAttribute('name'); - if (name && counters_state[name]) { - counters_state[name].stack.push(0); - pushed_name = name; - } - } else if (tag === 'rt-counter-inc') { - const name = node.getAttribute('name'); - if (name && counters_state[name]) { - const state = counters_state[name]; - state.stack[state.stack.length - 1] += 1; - state.current_count_str = state.stack.join(state.separator); - - node.setAttribute('data-count', state.current_count_str); - node.innerHTML = state.current_count_str; - } - } else if (tag === 'rt-counter-label') { - const name = node.getAttribute('name'); - if (name && counters_state[name]) { - const state = counters_state[name]; - // Stamp all relevant metadata for the labeling phase - node.setAttribute('data-count', state.current_count_str); - node.setAttribute('data-style', state.style); - node.setAttribute('data-separator', state.separator); - node.setAttribute('data-initial', state.initial); - } + window.RT.dict_counter = {}; + window.RT.dict_snapshot = {}; + + function to_roman(num) { + if (num < 1) return num.toString(); + const lookup = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1}; + let roman = ''; + for (let i in lookup) { + while (num >= lookup[i]) { + roman += i; + num -= lookup[i]; + } + } + return roman; + } + + function parse_first_step(val_str, style, counter_name) { + if (!val_str) return 1; + + let num = NaN; + + if (style === 'alpha') { + if (/^[a-z]$/.test(val_str)) { + num = val_str.charCodeAt(0) - 96; + } + } else if (style === 'Alpha') { + if (/^[A-Z]$/.test(val_str)) { + num = val_str.charCodeAt(0) - 64; + } + } else if (style === 'roman' || style === 'Roman' || style === 'roman-outline') { + let is_upper = (style === 'Roman' || style === 'roman-outline'); + let regex = is_upper ? /^M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/ : /^m*(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})$/; + + if (regex.test(val_str)) { + const lookup = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1}; + let temp = val_str.toUpperCase(); + num = 0; + let i = 0; + while (i < temp.length) { + if (i + 1 < temp.length && lookup[temp.substring(i, i + 2)]) { + num += lookup[temp.substring(i, i + 2)]; + i += 2; + } else { + num += lookup[temp[i]]; + i++; + } } + } + } else { + if (/^\d+$/.test(val_str)) { + num = parseInt(val_str, 10); + } + } + + if (isNaN(num) || num < 1) { + console.error(`RT-Style Layout Error: Type mismatch. Invalid 'on-first-step' value '${val_str}' for style '${style}' in counter '${counter_name}'.`); + return 1; + } + return num; + } + + function format_count(num, style, depth) { + if (style === 'roman') return to_roman(num).toLowerCase(); + if (style === 'Roman') return to_roman(num); + if (style === 'Alpha') return String.fromCharCode(64 + num); + if (style === 'alpha') return String.fromCharCode(96 + num); + + if (style === 'roman-outline') { + const levels = ['Roman', 'Alpha', 'Natural', 'alpha', 'roman']; + const current_style = levels[depth % levels.length]; + return format_count(num, current_style, 0); + } + + return num.toString(); + } + + function walk(node) { + if (node.nodeType !== Node.ELEMENT_NODE) return; + + const tag = node.tagName.toLowerCase(); + let pushed_name = null; - let child = node.firstElementChild; - while (child) { - walk(child); - child = child.nextElementSibling; + if (tag === 'rt-counter_make') { + const name = node.getAttribute('counter'); + if (name) { + const style = node.getAttribute('style') || 'Natural'; + const on_first_step_str = node.getAttribute('on-first-step'); + + let first_step_int = parse_first_step(on_first_step_str, style, name); + + window.RT.dict_counter[name] = { + counter: name, + stack: [0], + empty: [true], + separator: node.getAttribute('separator') || '.', + 'separator-placement': node.getAttribute('separator-placement') || 'embedded', + style: style, + 'on-first-step': on_first_step_str || '1', + on_first_step_int: first_step_int, // Stored internally for execution + count: '' + }; + } + } else if (tag === 'rt-counter_indent') { + const name = node.getAttribute('counter'); + if (name && window.RT.dict_counter[name]) { + window.RT.dict_counter[name].stack.push(0); + window.RT.dict_counter[name].empty.push(true); + pushed_name = name; + } + } else if (tag === 'rt-counter_step') { + const name = node.getAttribute('counter'); + if (name && window.RT.dict_counter[name]) { + const state = window.RT.dict_counter[name]; + const depth = state.stack.length - 1; + + if (state.empty[depth]) { + state.stack[depth] = (depth === 0) ? state.on_first_step_int : 1; + state.empty[depth] = false; + } else { + state.stack[depth] += 1; + } + + const formatted_stack = state.stack.map((val, index) => + format_count(val, state.style, index) + ); + + let count_str = formatted_stack.join(state.separator); + if (state['separator-placement'] === 'embedded-after') { + count_str += state.separator; } + + state.count = count_str; + } + } else if (tag === 'rt-counter_snapshot') { + const counter_name = node.getAttribute('counter'); + const snapshot_name = node.getAttribute('snapshot'); + + if (counter_name && snapshot_name && window.RT.dict_counter[counter_name]) { + const state = window.RT.dict_counter[counter_name]; + const depth = state.stack.length - 1; - if (pushed_name) { - counters_state[pushed_name].stack.pop(); + if (state.empty[depth]) { + console.error(`RT-Style Layout Error: Attempted to snapshot an empty counter '${counter_name}' at snapshot '${snapshot_name}'. A person must use before taking a snapshot.`); + } else { + window.RT.dict_snapshot[snapshot_name] = clone_counter_state(state); } + } } - walk(root_node); -}; + let child = node.firstElementChild; + while (child) { + walk(child); + child = child.nextElementSibling; + } -window.RT.counter_do_label = function (root_node) { - window.RT.dict_label = {}; - const labels = root_node.querySelectorAll('rt-counter-label'); - for (let i = 0; i < labels.length; i++) { - const lbl = labels[i].getAttribute('label'); - if (lbl) { - // Store a complete property object instead of just a string - window.RT.dict_label[lbl] = { - count: labels[i].getAttribute('data-count'), - name: labels[i].getAttribute('name'), - style: labels[i].getAttribute('data-style'), - separator: labels[i].getAttribute('data-separator'), - initial: labels[i].getAttribute('data-initial') - }; - } + if (pushed_name) { + window.RT.dict_counter[pushed_name].stack.pop(); + window.RT.dict_counter[pushed_name].empty.pop(); } + } + + walk(root_node); +}; + +window.RT.counter_do_snapshot = function (root_node) { + return; }; window.RT.counter_do_read = function (root_node) { - const reads = root_node.querySelectorAll('rt-counter-read'); - for (let i = 0; i < reads.length; i++) { - const label = reads[i].getAttribute('label'); - // Default to 'count' if no key is provided - const key = reads[i].getAttribute('key') || 'count'; - - if (label && window.RT.dict_label[label]) { - const value = window.RT.dict_label[label][key]; - if (value !== undefined && value !== null) { - reads[i].innerHTML = value; - } else { - reads[i].innerHTML = `[Missing key: ${key}]`; - } - } + const reads = root_node.querySelectorAll('rt-counter_read'); + for (let i = 0; i < reads.length; i++) { + const snapshot_name = reads[i].getAttribute('snapshot'); + const key = reads[i].getAttribute('key') || 'count'; + + if (snapshot_name && window.RT.dict_snapshot[snapshot_name]) { + const value = window.RT.dict_snapshot[snapshot_name][key]; + reads[i].innerHTML = (value !== undefined) ? value : `[Missing key: ${key}]`; + } else { + reads[i].innerHTML = `[Unknown snapshot: ${snapshot_name}]`; + console.error(`RT-Style Layout Error: failed. No snapshot named '${snapshot_name}' found in the dictionary.`); } + } }; diff --git a/developer/authored/Manuscript.copy/Layout/article_tech_ref.js b/developer/authored/Manuscript.copy/Layout/article_tech_ref.js index ae2f517..46e2243 100644 --- a/developer/authored/Manuscript.copy/Layout/article_tech_ref.js +++ b/developer/authored/Manuscript.copy/Layout/article_tech_ref.js @@ -193,10 +193,8 @@ RT.article(); if(RT.counter_do_count){ RT.counter_do_count(document.body); - if(RT.counter_do_label){ - RT.counter_do_label(document.body); - if(RT.counter_do_read) RT.counter_do_read(document.body); - }} + if(RT.counter_do_read) RT.counter_do_read(document.body); + } if(RT.title) RT.title(); if(RT.term) RT.term(); if(RT.math) RT.math(); diff --git a/document/RT-style-HTML.html b/document/RT-style-HTML.html deleted file mode 100644 index 8bbf7e8..0000000 --- a/document/RT-style-HTML.html +++ /dev/null @@ -1,451 +0,0 @@ - - - - - RT semantic HTML tags - - - - - - - - - - -

Table of custom tags

- -

Style tag reference

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TagDescription
<RT-article>Article container.
<RT-memo>Alternative strict print layout container.
<RT-title>Title block and metadata.
<RT-TOC>Generates TOC.
<RT-term>Conventional term.
<RT-term-em>Forces emphasis for a term even after first occurrence.
<RT-neologism>Project specific term.
<RT-neologism-em>Forces emphasis for a neologism even after first occurrence.
<RT-code>Code span or code block.
<RT-math>Inline or block math.
<RT-symbol>Technical or mathematical symbol wrapper.
<RT-constraint>Architectural limits or hard requirement block.
<RT-crossref>Context-aware internal link.
<RT-cite>Inline reference marker.
<RT-endnotes>Container for extracted citations.
<RT-footnote>Inline footnote generator.
<RT-page>Automatically inserted pagination tag.
<rt-theme-selector>Floating widget for hot-swapping themes.
- -

Architecture overview

-

- The RT Style System is a client-side, JavaScript-driven publishing framework designed to turn raw HTML into high-readability technical documentation. RT uses JavaScript to handle complex layout tasks like ink-ratio balancing and dynamic pagination, operating quite differently than standard CSS frameworks. -

- -

The document header

-

- The document header must bootstrap the RT Style engine before the body renders. An author places setup.js in the directory and includes it via a script tag at the top of the document. Following this, the window.StyleRT.include directives pull in the necessary modules, such as the theme and the specific layout orchestrator (e.g., RT/layout/article_tech_ref). -

- -

Pulling style files into a document

-

- Put `setup.js` in the directory, and include it at the top of the document. `setup.js` points at the style files and is installation specific. -

- -

Semantic tags

-

- The system relies on a specific set of custom tags in the RT- namespace to separate structure from presentation. -

- -

Terminology

- -

Conventional terms

-

- Use <RT-term> for standard, industry accepted technical terms. The system decorates only the first occurrence of each unique term so that the first appearance functions as a definition point, and later appearances do not overload the page with styling. -

- - - The Singleton Pattern restricts instantiation... - - -

- Renders as: The Singleton Pattern restricts instantiation... -

- -

Neologisms

-

- Use <RT-neologism> for terms invented specifically for the current document or project. Neologisms are styled more strongly than conventional terms, visually distinguishing "jargon you should know" from "jargon we newly created." -

- - - We define the Hyper Tape as a construct... - - -

- Renders as: We define the Hyper Tape as a construct... -

- -

First occurrence rule

-

- The term system is intentionally conservative. For the tags <RT-term> and <RT-neologism>, only the first occurrence of a unique term is decorated. Subsequent mentions are rendered as normal prose. -

- -

- Uniqueness is tracked by normalizing the term text (trimmed, then lowercased). This means that Symbol and symbol count as the same term. -

- -

Forced emphasis variants

-

- Sometimes a later mention of a term should be emphasized again. For that purpose, the system provides explicit emphasis tags: -

- -
    -
  • <RT-term-em>
  • -
  • <RT-neologism-em>
  • -
- -

- These variants are always decorated, even if the term appeared earlier. -

- -

Automatic definition anchors

-

- For first occurrences, the term module automatically assigns an id attribute if one lacks existence. This creates stable anchors for future indexing and linking. -

- - - We define a Symbol as... - - -

- The first occurrence will be given an id similar to def-symbol. For neologisms, an additional marker is used, for example def-neo-hyper-tape. -

- -

Technical content

- -

Code

-

- Use <RT-code>. When placed inline, it functions as a span. When placed as a block (with newlines), it functions as a pre formatted block with a theme aware border. The engine will automatically strip common leading whitespace so that the text aligns relative to the indentation of the <RT-code> tag itself. -

- - - # Block Code Example - def hello(): - return "World" - - -

Mathematics

-

- Use <RT-math>. The system auto detects if it is a block equation or inline variable and wraps it in MathJax delimiters. -

-

- Inline: Let x be the input. -

-

- Block: -

- - f(x) = \sum_{i=0}^{n} x_i - - -

Architectural notation and constraints

- -

Symbols

-

- Use <RT-symbol> for specialized technical or mathematical symbols. This enforces a consistent font-weight and character spacing across different browser engines, ensuring that these symbols avoid anti-aliasing artifacts often seen with standard Unicode glyphs in technical documentation. -

- -

Constraints

-

- Use <RT-constraint> to explicitly highlight physical limitations, memory boundaries, or structural constraints within a system. This tag triggers a unique block-display, rendering with a distinct background shade and a left-hand rule, visually separating hard requirements from descriptive prose. -

- -

Cross-references

-

- Use <RT-crossref> for internal structural linking between sections. This tag provides context-aware linking, managing anchor states to jump across soft-limit boundaries seamlessly. -

- -

Citations, endnotes, and footnotes

-

- The system manages academic and technical references through a paired tag approach, ensuring citations are extracted and formatted before the layout engine calculates page boundaries. It also supports dynamically expanding footnotes. -

- -

Inline citations

-

- An author places <RT-cite ref="Author, Source"></RT-cite> inline within the text. The engine transforms this into a superscript bracketed number, establishing a bi-directional link. -

- -

Endnote generation

-

- The <RT-endnotes> container functions as the destination for all extracted citations. If an author places this tag at the bottom of the article, the engine populates it with an ordered list of references. Should the author omit the tag, the semantic parser will dynamically generate and append it as a top-level child of the article. -

- -

Footnotes

-

- An author places <RT-footnote>Note text</RT-footnote> inline within the prose. The engine operates in three phases: it strips the tag to prevent layout disruption, paginates the raw text blindly, and finally expands the completed page to append the extracted footnote block at the bottom. This ensures perfect spatial routing across soft limits. -

- - - The core architecture operates at 5GHz.Assuming optimal thermal conditions. - - -

Navigation and layout

- -

Automatic table of contents

-

- Use <RT-TOC> to insert a generated table of contents. The tag scans the document forward from its current position to collect headings. -

- -

Explicit mode (Specific levels or ranges)

-

- Use the level attribute to target a specific heading depth or a range of depths. -

-
    -
  • <RT-TOC level="1">: Collects all <h1> elements until the end of the document. Best for the main document index.
  • -
  • <RT-TOC level="1-3">: Collects all <h1>, <h2>, and <h3> elements, nesting them structurally.
  • -
  • <RT-TOC level="2">: Collects all <h2> elements until it encounters the next <h1>. Best for chapter summaries.
  • -
- -

Implicit mode

-

- If no level is specified, the TOC scans backwards to find the nearest heading (for example H1) and assumes an author wants to collect children one level deeper (for example H2). -

-

- Note: Implicit mode has a probability to fail if placed before the first heading of a section. Use explicit levels for robust results. -

- -

The title block

-

- Use <RT-title> as the first element in your <body> (before the article container). This tag generates a standardized, styled header block with the document title and metadata. -

- -

Attributes

-
    -
  • title (Required): The main heading of the document.
  • -
  • author (Optional): The author's name. Renders in a bold accent color.
  • -
  • date (Optional): The publication or revision date.
  • -
  • copyright (Optional): Appends a copyright notice to the bottom of the title block.
  • -
- -

Example

- - - - - -

- Renders as: A centered, high contrast H1 followed by a serif styled metadata row containing the author and date, and a smaller copyright note. -

- -

Layout containers

- -

The article container

-

- The primary root element for documentation is <RT-article>. This establishes the boundary for the standard typography rules and the dynamic pagination logic. -

- -

The memo container

-

- Alternatively, use <RT-memo> for strict print formatting. This sets the document width to a strict 6.5 inches (standard 8.5 inch page with 1-inch margins), overrides theme colors to enforce black text on a white background, and sets the typography to a 12pt serif font (Times New Roman) suitable for formal documentation. -

- -

Pagination

-

- The script paginate_by_element.js scans the article. It calculates the height of every element (including margins) and bundles them into <RT-page> elements. -

-

- Soft Limit Pagination: The system attempts to keep headers with their following paragraphs. It will break a page early rather than stranding a header at the bottom. -

-

- Fragment Splitting: When confronted with large unbroken data structures, the paginator acts intelligently to split `

    `, `
      `, and `` elements across multiple pages to maximize space efficiency without breaking the document structure. -

      - -

      Debugging

      - -

      Debug tokens

      -

      - RT provides a lightweight debug logging system in utility.js. Logging is controlled by a set of active debug tokens. Each log message is assigned a token, and the message prints only if that token is enabled. -

      - -

      - Examples of common tokens include style, layout, pagination, selector, config, and term. -

      - -

      How logging is gated

      -

      - Normal log and warning output are gated. The methods debug.log(token,message) and debug.warn(token,message) will print only when the token exists in debug.active_tokens. -

      - -

      - This prevents the console from being flooded during normal use, while still allowing deep visibility during development. -

      - -

      Errors are always printed

      -

      - Errors are treated differently. The method debug.error(token,message) always prints, regardless of token state. These messages represent failures that require attention. -

      - -

      Enabling and disabling tokens

      -

      - Tokens have permission to be enabled or disabled in two ways: by editing the active_tokens set in utility.js, or at runtime by calling: -

      - - - window.StyleRT.debug.enable('term') - window.StyleRT.debug.disable('term') - - -

      - For example, the term system (RT_term.js) uses the term token. When that token is enabled, the module will print messages describing how terms were detected and which term definitions were assigned IDs. -

      - -

      Themes

      -

      - The system supports hot swapping themes by changing the script import in the head. -

      -
        -
      • Dark: style/theme_dark_gold.js (Default)
      • -
      • Light: style/theme_light_gold.js
      • -
      - -

      Theme selector widget

      -

      - Including the tag <rt-theme-selector></rt-theme-selector> anywhere in the DOM will generate a floating widget in the upper right corner of the window, permitting the user to hot-swap the visual theme and automatically persist the choice via local storage. -

      - -

      Manifest

      - - 1. style_orchestrator.js (Example/default footer script) - 2. utility.js (Math/Color physics) - 3. article_tech_ref.js (Typography and CSS injection) - 4. RT_code.js (Code block logic) - 5. RT_math.js (MathJax wrapper) - 6. RT_term.js (Term styling) - 7. RT_TOC.js (Navigation generator) - 8. paginate_by_element.js (Page splitter) - 9. page_fixed_glow.js (Visual page container) - - -

      RT conventions

      -

      Headings are first letter capitalized. Remaining words are as they would be in English prose.

      - -

      Exercises

      - -
        -
      1. -

        - Term Occurrences: If an author tags a word with <RT-term> five times in a document, how many times will the term be visually decorated by the styling engine? How does a person force the engine to decorate a later occurrence? -

        -
      2. -
      3. -

        - Term Normalization: A person writes <RT-term>Parse Tree</RT-term> in paragraph one, and <RT-term>parse tree</RT-term> in paragraph two. Will the system assign a definition anchor to the second occurrence? -

        -
      4. -
      5. -

        - TOC Generation: What happens if a person places an <RT-TOC> tag without a level attribute before the first heading of a section? -

        -
      6. -
      7. -

        - Code and Math Formatting: How does the RT system determine whether to render an <RT-code> or <RT-math> element inline with the text versus as a standalone block? -

        -
      8. -
      9. -

        - Pagination Logic: When the script bundles elements into an <RT-page> container, how does the soft limit pagination handle a heading that falls at the very bottom of the page capacity? -

        -
      10. -
      - - - - - diff --git a/tester/authored/Counter/test_0.html b/tester/authored/Counter/test_0.html index ec44d60..05c454f 100644 --- a/tester/authored/Counter/test_0.html +++ b/tester/authored/Counter/test_0.html @@ -1,65 +1,70 @@ + - + Manuscript Counter Test Bench - - + + + - - -

      Primary Analysis

      -

      - Observe the data in Figure . -

      - + + +

      Primary Analysis

      +

      + Observe the data in Figure + + + . +

      - +

      - Detail view of the left quadrant: Figure . + Detail view of the left quadrant: Figure + + + .

      -

      - Detail view of the right quadrant: Figure . + Detail view of the right quadrant: Figure + + + .

      - - -

      - Microscopic inspection: Figure . -

      - -
      -
      + +

      + Microscopic inspection: Figure + + + . +

      +
      + -

      Secondary Analysis

      -

      - Proceeding to the next major component, shown in Figure . -

      +

      Secondary Analysis

      +

      + Proceeding to the next major component, shown in Figure + + + . +

      -
      +

      Forward Reference Validation

      This text proves we can accurately call back to earlier elements.

        -
      • The primary analysis was Figure .
      • -
      • The left quadrant was Figure .
      • -
      • The microscopic view was Figure .
      • +
      • The primary analysis was Figure .
      • +
      • The left quadrant was Figure .
      • +
      • The microscopic view was Figure .
      -
      +
      - - +
      + diff --git a/tester/authored/Counter/test_1.html b/tester/authored/Counter/test_1.html index a6c4df2..f9d4a1f 100644 --- a/tester/authored/Counter/test_1.html +++ b/tester/authored/Counter/test_1.html @@ -1,66 +1,60 @@ - + - Manuscript Counter Test Bench + Manuscript Counter Test Bench 1 - - + + + - - -

      Primary Analysis

      -

      - Observe the data in Figure . -

      - + + +

      Primary Analysis

      +

      + Observe the data in Figure + + + . +

      - +

      - Detail view of the left quadrant: Figure . + Detail view of the left quadrant: Figure + + + .

      -

      - Detail view of the right quadrant: Figure . + Detail view of the right quadrant: Figure + + + .

      - - -

      - Microscopic inspection: Figure . -

      - -
      -
      + +

      + Microscopic inspection: Figure + + + . +

      +
      + -

      Secondary Analysis

      -

      - Proceeding to the next major component, shown in Figure . -

      +

      Secondary Analysis

      +

      + Proceeding to the next major component, shown in Figure + + + . +

      -
      -

      Forward Reference Validation

      -

      This text proves we can accurately call back to earlier elements.

      -
        -
      • The primary analysis was Figure .
      • -
      • The left quadrant was Figure .
      • -
      • The microscopic view was Figure .
      • -
      -
      - - - +
      + diff --git a/tester/authored/Counter/test_2.html b/tester/authored/Counter/test_2.html index e908237..b6cf04a 100644 --- a/tester/authored/Counter/test_2.html +++ b/tester/authored/Counter/test_2.html @@ -1,70 +1,59 @@ - + Manuscript Counter Test Bench 2 - - - + + + - + -
      +

      Executive Summary (Forward References)

      - This section appears before any counting occurs in the DOM. - The final equation in this document is Equation . + This section appears before any counting occurs in the DOM. + The final equation in this document is Equation .

      -

      - Metadata Verification for label "eq-final": -

        -
      • Name parameter:
      • -
      • Style parameter:
      • -
      • Separator parameter:
      • -
      • Initial parameter:
      • -
      -

      -
      +
      -

      Mathematical Proofs

      - -

      - The base formulation is defined in Equation . -

      - +

      Mathematical Proofs

      + +

      + The base formulation is defined in Equation + + + . +

      - +

      - Derivation step A: Equation . + Derivation step A: Equation + + + .

      -

      - Derivation step B: Equation . + Derivation step B: Equation + + + .

      - -
      + -

      - The concluding formulation is established in Equation . -

      - +

      + The concluding formulation is established in Equation + + + . +

      - - +
      + diff --git a/tester/authored/Counter/test_3.html b/tester/authored/Counter/test_3.html new file mode 100644 index 0000000..655cc3c --- /dev/null +++ b/tester/authored/Counter/test_3.html @@ -0,0 +1,76 @@ + + + + + + Manuscript Counter Test Bench 3 + + + + + + + + + +

      Regulatory Formatting

      +

      + The embedded-after placement requires a trailing separator.
      + Observe Rule + + + +

      + +

      + Subset rule + + + +

      +

      + Subset rule + + + +

      +
      + +

      Outline Hierarchy

      +

      + The outline format automatically cycles styles by depth.
      + Level 0 evaluates to Section + + + . +

      + + +

      + Level 1 evaluates to Section + + + . +

      + + +

      + Level 2 evaluates to Section + + + . +

      +

      + Level 2 continues at Section + + + . +

      +
      +
      + +
      + + diff --git a/tester/authored/Counter/test_4.html b/tester/authored/Counter/test_4.html new file mode 100644 index 0000000..77b1126 --- /dev/null +++ b/tester/authored/Counter/test_4.html @@ -0,0 +1,99 @@ + + + + + Manuscript Counter Test Bench 4 + + + + + + + + + + + +
      +

      Executive Summary

      +

      + This summary proves the snapshot dictionary is populated before the reading phase executes. +

      +
        +
      • The first major section is .
      • +
      • The deepest nested section is .
      • +
      • The final section, proving successful outdenting, is .
      • +
      +
      + +

      Main Content

      + +

      + Beginning the primary sequence: Section + + + . +

      + + +

      + First nested item: Section + + + . +

      +

      + Second nested item: Section + + + . +

      +
      + +

      + Outdented back to the primary sequence: Section + + + . +

      + + +

      + First nested item of the second sequence: Section + + + . +

      + + +

      + Double nested item: Section + + + . +

      +
      + +

      + Outdented to level one: Section + + + . +

      +
      + +

      + Double outdented back to root level: Section + + + . +

      + +
      + + diff --git a/tester/authored/Counter/test_5.html b/tester/authored/Counter/test_5.html new file mode 100644 index 0000000..7a0a795 --- /dev/null +++ b/tester/authored/Counter/test_5.html @@ -0,0 +1,51 @@ + + + + + Manuscript Counter Test Bench 5 + + + + + + + + +
      +

      Metadata Validation

      +

      + Querying the final snapshot dictionary for parameters assigned at initialization: +

      +
        +
      • Counter name parameter:
      • +
      • Style parameter:
      • +
      • Separator parameter:
      • +
      • first step leads to:
      • +
      +
      + +

      Content

      + +

      + First diagram: + + + + + + + . +

      + +

      + Final diagram: + + + . +

      + +
      + +