From: Thomas Walker Lynch Date: Wed, 14 Jan 2026 15:40:00 +0000 (+0000) Subject: document TOC working adds a title tag X-Git-Url: https://git.reasoningtechnology.com/style/theme_dark_gold.js?a=commitdiff_plain;h=a08f3e293c2174027f857ec80466737924b21652;p=Epimetheus%2F.git document TOC working adds a title tag --- diff --git a/developer/document/Epimetheus.html b/developer/document/Epimetheus.html index 07e122f..e24c925 100644 --- a/developer/document/Epimetheus.html +++ b/developer/document/Epimetheus.html @@ -30,7 +30,7 @@ The code related to this discussion is implemented in Python, however issues with other languages are considered. On salient difference that is considered is that Python integers are bignums are passed by reference. In some other languages integers are considered primitives, are bounded and bit copied.

-

Symbol

+

Symbol

Instance

@@ -87,64 +87,6 @@ The factory’s make returns an original instance that is not equal to any other original. All copies stemming from an original remain in the same equivalence class. Therefore any instance in the class can represent the symbol, and we may choose any one instance as the symbol’s name (a canonical representative), or we could use a dictionary, and use, say, the original instance, to lookup a string as a name.

-

Symbol

- -

Instance

- -

- We are given a symbol instance factory. Each time the make function on the factory interface is called, the factory returns an instance of a distinct symbol. -

- -

- A symbol instance may be copied. A common method for - making a copy in many languages is to use assignment, e.g., - x = y, where y is a variable holding a symbol instance. After execution of the assignment, x will hold another instance of the same symbol. However in Python an - assignment will copy a reference, and the symbol itself will not be copied. -

- -

- Any two, or by transitivity, any number of, symbol instances can be compared for equality, say - x == y. A comparison between symbol instances - will always return True or False. -

- -

- A symbol instance newly minted using the given symbol factory make function is said to come direct from the factory. Such a symbol is also called an original. -

- -

Required Properties

- -

- Any two symbol instances returned directly from the factory using two different make calls will always equality compare to be False. In other words, two distinct originals will always be not equal. -

- -

- Given an original, all copies stemming from it will be equal to each other and to the original. By stemming we mean to include all direct copies and copies of copies. -

- -

- Given any two originals, say A and B, we know that A is not equal to B, as discussed above. Note also that A is not equal to any copy stemming from B, and B is not equal to any copy stemming from A. -

- -

- Though symbol instances are integer-like in that copy and equality compare can be used with them, symbol instances are disallowed from being used with other integer operators. Symbols cannot be compared for greater-than or less-than; they cannot be incremented, added, nor subtracted, etc. -

- - -

What is a Symbol

- -

- A symbol is not manipulated directly. Only symbol instances exist at runtime. -

- -

- Define a relation ~ over instances by x ~ y iff x == y. This partitions instances into equivalence classes. Each such equivalence class is a symbol. -

- -

- The factory’s make returns an original instance that is not equal to any other original. All copies stemming from an original remain in the same equivalence class. Therefore any instance in the class can represent the symbol, and we may choose any one instance as the symbol’s name (a canonical representative). -

-

Distinctness Across Contexts

diff --git a/developer/document/style/RT_TOC.js b/developer/document/style/RT_TOC.js index dc1c5f5..86ee51a 100644 --- a/developer/document/style/RT_TOC.js +++ b/developer/document/style/RT_TOC.js @@ -1,40 +1,58 @@ /* - Processes existing tags. - Populates each with headings found below it that are exactly one level deeper. - Stops scanning if a heading of the same or higher level is encountered. + Processes tags. + Populates each with headings found below it. + + Attributes: + level="N" : Explicitly sets the target heading level (1-6). + e.g., level="1" collects H1s. level="2" collects H2s. + Stops collecting if it hits a heading of (level - 1) or higher. + + Default (No attribute): + Context-Aware. Looks backwards for the nearest heading H(N). + Targets H(N+1). Stops at the next H(N). */ window.StyleRT = window.StyleRT || {}; window.StyleRT.RT_TOC = function() { - const debug = window.StyleRT.debug; + const debug = window.StyleRT.debug || { log: function(){} }; const toc_tags = document.querySelectorAll('rt-toc'); toc_tags.forEach((container, toc_index) => { container.style.display = 'block'; - // 1. Determine the context level of this TOC - // We look backward to find the most recent heading (H1-H6) - let context_level = 0; // Default to 0 (looking for H1s) - let prev = container.previousElementSibling; + // 1. Determine Target Level + const attr_level = parseInt(container.getAttribute('level')); + let target_level; - while (prev) { - const match = prev.tagName.match(/^H([1-6])$/); - if (match) { - context_level = parseInt(match[1]); - break; - } - prev = prev.previousElementSibling; + if (!isNaN(attr_level)) { + // EXPLICIT MODE + target_level = attr_level; + if (debug.log) debug.log('RT_TOC', `TOC #${toc_index} explicit target: H${target_level}`); + } else { + // IMPLICIT / CONTEXT MODE + let context_level = 0; // Default 0 (Root) + let prev = container.previousElementSibling; + while (prev) { + const match = prev.tagName.match(/^H([1-6])$/); + if (match) { + context_level = parseInt(match[1]); + break; + } + prev = prev.previousElementSibling; + } + target_level = context_level + 1; + if (debug.log) debug.log('RT_TOC', `TOC #${toc_index} context implied target: H${target_level}`); } - const target_level = context_level + 1; - const stop_at_or_above = context_level; - - if (debug) debug.log('RT_TOC', `TOC #${toc_index} context: H${context_level}. Targeting: H${target_level}`); + // Stop condition: Stop if we hit a heading that is a "parent" or "sibling" of the context. + // Mathematically: Stop if found_level < target_level. + const stop_threshold = target_level; - // 2. Setup Internal Structure - container.innerHTML = ''; // Clear any placeholder content + // 2. Setup Container + container.innerHTML = ''; const title = document.createElement('h1'); - title.textContent = context_level === 0 ? 'Table of Contents' : 'Section Contents'; + // Title logic: If targeting H1, it's a Main TOC. Otherwise it's a Section TOC. + title.textContent = target_level === 1 ? 'Table of Contents' : 'Section Contents'; title.style.textAlign = 'center'; container.appendChild(title); @@ -43,20 +61,21 @@ window.StyleRT.RT_TOC = function() { list.style.paddingLeft = '0'; container.appendChild(list); - // 3. Scan Forward for headings + // 3. Scan Forward let next_el = container.nextElementSibling; while (next_el) { const match = next_el.tagName.match(/^H([1-6])$/); if (match) { const found_level = parseInt(match[1]); - // STOP condition: We hit a heading at our level or higher - // (e.g., if we are under an H1 looking for H2s, we stop at the next H1) - if (context_level !== 0 && found_level <= stop_at_or_above) { + // STOP Logic: + // If we are looking for H2s, we stop if we hit an H1 (level 1). + // If we are looking for H1s, we stop if we hit... nothing (level 0). + if (found_level < target_level) { break; } - // COLLECT condition: Heading is exactly one level deeper + // COLLECT Logic: if (found_level === target_level) { if (!next_el.id) next_el.id = `toc-ref-${toc_index}-${found_level}-${list.children.length}`; @@ -70,8 +89,7 @@ window.StyleRT.RT_TOC = function() { a.style.color = 'inherit'; a.style.display = 'block'; - // Hover effects - a.onmouseover = () => a.style.color = 'hsl(42, 100%, 50%)'; + a.onmouseover = () => a.style.color = 'var(--rt-brand-primary)'; a.onmouseout = () => a.style.color = 'inherit'; li.appendChild(a); diff --git a/developer/document/style/RT_title.js b/developer/document/style/RT_title.js new file mode 100644 index 0000000..93757f8 --- /dev/null +++ b/developer/document/style/RT_title.js @@ -0,0 +1,60 @@ +/* + Processes tags. + Generates a standard document header block. + + Usage: + +*/ +window.StyleRT = window.StyleRT || {}; + +window.StyleRT.RT_title = function() { + const debug = window.StyleRT.debug || { log: function(){} }; + + document.querySelectorAll('rt-title').forEach(el => { + const title = el.getAttribute('title') || 'Untitled Document'; + const author = el.getAttribute('author'); + const date = el.getAttribute('date'); + + if (debug.log) debug.log('RT_title', `Generating title block: ${title}`); + + // Container + const container = document.createElement('div'); + container.style.textAlign = 'center'; + container.style.marginBottom = '3rem'; + container.style.marginTop = '2rem'; + container.style.borderBottom = '1px solid var(--rt-border-default)'; + container.style.paddingBottom = '1.5rem'; + + // Main Title (H1) + const h1 = document.createElement('h1'); + h1.textContent = title; + h1.style.margin = '0 0 0.8rem 0'; + h1.style.border = 'none'; // Override standard H1 border + h1.style.padding = '0'; + h1.style.color = 'var(--rt-brand-primary)'; + h1.style.fontSize = '2.5em'; + h1.style.lineHeight = '1.1'; + h1.style.letterSpacing = '-0.03em'; + + container.appendChild(h1); + + // Metadata Row (Author | Date) + if (author || date) { + const meta = document.createElement('div'); + meta.style.color = 'var(--rt-content-muted)'; + meta.style.fontStyle = 'italic'; + meta.style.fontSize = '1.1em'; + meta.style.fontFamily = '"Georgia", "Times New Roman", serif'; // Classy serif + + const parts = []; + if (author) parts.push(`${author}`); + if (date) parts.push(date); + + meta.innerHTML = parts.join('  —  '); + container.appendChild(meta); + } + + // Replace the raw tag with the generated block + el.replaceWith(container); + }); +}; diff --git a/developer/document/style/article_tech_ref_2.js b/developer/document/style/article_tech_ref_2.js new file mode 100644 index 0000000..544c98e --- /dev/null +++ b/developer/document/style/article_tech_ref_2.js @@ -0,0 +1,181 @@ +/* + Article Layout: Technical Reference + Standard: Theme 1.0 + Description: High-readability layout for technical documentation on screens. + Features: Sans-serif, justified text, distinct headers, boxed code. +*/ +(function(){ + const RT = window.StyleRT = window.StyleRT || {}; + + RT.article = function() { + const debug = RT.debug || { log: function(){} }; + debug.log('layout', 'RT.article starting...'); + + RT.config = RT.config || {}; + + // Default Configuration + RT.config.article = { + font_family: '"Noto Sans", "Segoe UI", "Helvetica Neue", sans-serif' + ,line_height: "1.8" + ,font_size: "16px" + ,font_weight: "400" // Default (String) + ,max_width: "820px" + ,margin: "0 auto" + }; + + // SAFE THEME DETECTION + // If the theme is loaded and explicitly Light, bump the weight. + try { + if (RT.config.theme && RT.config.theme.meta_is_dark === false) { + RT.config.article.font_weight = "600"; + debug.log('layout', 'Light theme detected: adjusting font weight to 600.'); + } + } catch(e) { + console.warn("StyleRT: Auto-weight adjustment failed, using default.", e); + } + + const conf = RT.config.article; + const article_seq = document.querySelectorAll("RT-article"); + + if(article_seq.length === 0) { + debug.log('layout', 'No elements found. Exiting.'); + return; + } + + // 1. Apply Container Styles + article_seq.forEach( (article) =>{ + const style = article.style; + style.display = "block"; + style.fontFamily = conf.font_family; + style.fontSize = conf.font_size; + style.lineHeight = conf.line_height; + style.fontWeight = conf.font_weight; + style.maxWidth = conf.max_width; + style.margin = conf.margin; + style.padding = "0 20px"; + style.color = "var(--rt-content-main)"; + }); + + // 2. Inject Child Typography + const style_id = 'rt-article-typography'; + if (!document.getElementById(style_id)) { + debug.log('layout', 'Injecting CSS typography rules.'); + const style_el = document.createElement('style'); + style_el.id = style_id; + + style_el.textContent = ` + /* --- HEADERS --- */ + rt-article h1 { + color: var(--rt-brand-primary); + font-size: 2.0em; + font-weight: 500; + text-align: center; + margin-top: 1.2em; + margin-bottom: 0.6em; + border-bottom: 2px solid var(--rt-border-default); + padding-bottom: 0.3em; + line-height: 1.2; + letter-spacing: -0.02em; + } + + rt-article h2 { + color: var(--rt-brand-secondary); + font-size: 1.5em; + font-weight: 400; + text-align: center; + margin-top: 1.0em; + margin-bottom: 0.5em; + } + + rt-article h2 + h3 { + margin-top: -0.3em; + padding-top: 0; + } + + rt-article h3 { + color: var(--rt-brand-tertiary); + font-size: 1.4em; + font-weight: 400; + margin-top: 1.0em; + margin-bottom: 0.5em; + } + + /* --- DEEP LEVELS (H4-H6) --- */ + rt-article h4, rt-article h5, rt-article h6 { + color: var(--rt-brand-tertiary); + font-weight: bold; + margin-top: 1.2em; + font-style: italic; + } + rt-article h4 { margin-left: 2em; } + rt-article h5 { margin-left: 4em; } + rt-article h6 { margin-left: 6em; } + + /* --- SEMANTIC TAGS --- */ + rt-article rt-neologism { + font-family: "Georgia", "Times New Roman", serif; + font-size: 1.2em; /* <--- ADD THIS LINE */ + font-style: italic; + font-weight: 400; + color: var(--rt-brand-tertiary); + letter-spacing: 0.02em; + } + + + /* --- BODY TEXT --- */ + rt-article p { + margin-bottom: 1.4em; + text-align: justify; + hyphens: auto; + color: var(--rt-content-main); + } + + /* --- RICH ELEMENTS --- */ + rt-article blockquote { + border-left: 4px solid var(--rt-brand-secondary); + margin: 1.5em 0; + padding: 0.5em 1em; + font-style: italic; + color: var(--rt-content-muted); + background: var(--rt-surface-1); + border-radius: 0 4px 4px 0; + } + + rt-article ul, rt-article ol { + margin-bottom: 1.4em; + padding-left: 2em; + } + rt-article li { + margin-bottom: 0.4em; + } + rt-article li::marker { + color: var(--rt-brand-secondary); + font-weight: bold; + } + + /* Links */ + rt-article a { + color: var(--rt-brand-link); + text-decoration: none; + border-bottom: 1px dotted var(--rt-border-default); + transition: all 0.2s; + } + rt-article a:hover { + color: var(--rt-brand-primary); + border-bottom: 1px solid var(--rt-brand-primary); + background: var(--rt-surface-1); + } + + /* --- TECHNICAL --- */ + rt-article pre { + background: var(--rt-surface-code); + padding: 1em; + border-radius: 4px; + overflow-x: auto; + border: 1px solid var(--rt-border-default); + } + `; + document.head.appendChild(style_el); + } + }; +})(); diff --git a/developer/document/style/style_orchestrator.js b/developer/document/style/style_orchestrator.js index a076d4a..e745035 100644 --- a/developer/document/style/style_orchestrator.js +++ b/developer/document/style/style_orchestrator.js @@ -1,6 +1,5 @@ /* Master Loader & Orchestrator for StyleRT. - Renamed from do_style.js */ window.StyleRT = window.StyleRT || {}; @@ -10,12 +9,13 @@ window.StyleRT.style_orchestrator = function() { const modules = [ // Theme & Semantics + 'style/RT_title.js', 'style/theme_dark_gold.js', 'style/RT_term.js', 'style/RT_math.js', 'style/RT_code.js', - 'style/article_tech_ref.js', // Renamed from article_generic - 'style/RT_TOC.js', + 'style/article_tech_ref_2.js', + 'style/RT_TOC.js', // Layout & Pagination 'style/paginate_by_element.js', @@ -57,8 +57,12 @@ window.StyleRT.style_orchestrator = function() { RT.debug.log('style', 'Starting Phase 1: Setup & Semantics'); // Naming Convention: RT. - if(RT.theme) RT.theme(); // Was theme - if(RT.article) RT.article(); // Was article_generic + if(RT.theme) RT.theme(); + if(RT.article) RT.article(); + + // NEW: Trigger the Title Generator + if(RT.RT_title) RT.RT_title(); + if(RT.RT_term) RT.RT_term(); if(RT.RT_math) RT.RT_math(); if(RT.RT_code) RT.RT_code(); diff --git a/developer/document/style/theme_dark_gold.js b/developer/document/style/theme_dark_gold.js index 36d7929..f576147 100644 --- a/developer/document/style/theme_dark_gold.js +++ b/developer/document/style/theme_dark_gold.js @@ -91,6 +91,4 @@ } }; - // Auto-load for dev - RT.theme_dark(); } )(); diff --git a/developer/document/style/theme_light_gold.js b/developer/document/style/theme_light_gold.js index 374948a..206f3da 100644 --- a/developer/document/style/theme_light_gold.js +++ b/developer/document/style/theme_light_gold.js @@ -100,8 +100,4 @@ } }; - if(!RT.theme_loaded) { - RT.theme(); - RT.theme_loaded = true; - } } )(); diff --git a/developer/document/style_manual.html b/developer/document/style_manual.html new file mode 100644 index 0000000..849bd3f --- /dev/null +++ b/developer/document/style_manual.html @@ -0,0 +1,170 @@ + + + + + RT Style System: Reference Manual + + + + + + + + + + + + + + + + + + + + + + + +

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

+ +

The Orchestrator

+

+ The core of the system is style_orchestrator.js. It is placed at the bottom of the HTML <body>. Its job is to: +

+
    +
  1. Detect which modules are already loaded.
  2. +
  3. Load missing modules (defaulting to Dark Theme if none is specified).
  4. +
  5. Execute the Semantics Phase (styling tags).
  6. +
  7. Wait for MathJax (if present).
  8. +
  9. Execute the Layout Phase (pagination, page rendering).
  10. +
  11. Reveal the document.
  12. +
+ +

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 Singleton Pattern restricts instantiation... + +

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

+ +

Neologisms (Novel Concepts)

+

+ Use <RT-neologism> for terms invented specifically for the current document or project. This visually distinguishes "jargon you should know" from "jargon we just made up." +

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

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

+ +

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 + + +

Navigation & 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 (Recommended)

+

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

+ + +

Implicit Mode (Context Aware)

+

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

+

+ Note: Implicit mode can fail if placed before the first heading of a section (the "Halting Problem" scenario). Use explicit levels for robust results. +

+ +

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

+ +

Themes

+

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

+ + +

Recovery Manifest

+

+ If memory is lost, ensure these files exist in style/: +

+ +1. style_orchestrator.js (The brain) +2. utility.js (Math/Color physics) +3. article_tech_ref.js (Typography & 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) + + + + + + +