From: Thomas Walker Lynch Date: Sat, 16 May 2026 15:07:14 +0000 (+0000) Subject: .gitignore was letting consumer release through X-Git-Url: https://git.reasoningtechnology.com/%28%5B%5E?a=commitdiff_plain;h=83c4841ff566a1b2af5638db35530504061793a6;p=RT-style-JS_public .gitignore was letting consumer release through --- diff --git a/.gitignore b/.gitignore index fcd4eb4..a20243b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ __pycache__/ *~ *.bak -# so that .gitignore is not required in user/release -/user/release +# so that .gitignore is not required in /consumer/release +/consumer/release + diff --git a/consumer/release/RT/core/body_visibility_hidden.js b/consumer/release/RT/core/body_visibility_hidden.js deleted file mode 100644 index d6a178a..0000000 --- a/consumer/release/RT/core/body_visibility_hidden.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - Targets the root element to ensure total blackout during load. -*/ -function body_visibility_hidden(){ - const gate = document.createElement('style'); - gate.id = 'rt-visibility-gate'; - gate.textContent = 'html{visibility:hidden !important; background:black !important;}'; - document.head.appendChild(gate); -} - -window.StyleRT = window.StyleRT || {}; -window.StyleRT.body_visibility_hidden = body_visibility_hidden; diff --git a/consumer/release/RT/core/body_visibility_visible.js b/consumer/release/RT/core/body_visibility_visible.js deleted file mode 100644 index ff1c4b6..0000000 --- a/consumer/release/RT/core/body_visibility_visible.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - Restores visibility by removing the visibility gate. -*/ -function body_visibility_visible(){ - const gate = document.getElementById('rt-visibility-gate'); - if (gate){ - gate.remove(); - } - document.body.style.visibility = 'visible'; -} - -window.StyleRT = window.StyleRT || {}; -window.StyleRT.body_visibility_visible = body_visibility_visible; diff --git a/consumer/release/RT/core/loader.js b/consumer/release/RT/core/loader.js deleted file mode 100644 index 3f4ee68..0000000 --- a/consumer/release/RT/core/loader.js +++ /dev/null @@ -1,27 +0,0 @@ -window.StyleRT = window.StyleRT || {}; - -window.StyleRT.include = function(path_identifier){ - let parts_seq = path_identifier.split('/'); - let namespace = parts_seq[0]; - - let module_path = parts_seq.slice(1).join('/'); - - if(module_path === 'theme'){ - let saved_theme = localStorage.getItem('RT_theme_preference'); - if(!saved_theme){ - saved_theme = 'dark_gold'; - localStorage.setItem('RT_theme_preference' ,saved_theme); - } - module_path = 'theme/' + saved_theme; - } - - let base_path = window.StyleRT_namespaces[namespace]; - if(!base_path){ - console.error("Namespace not found: " + namespace); - return; - } - - let full_path = base_path + '/' + module_path + '.js'; - // FIXED: No backslashes in the closing script tag - document.write(''); -}; diff --git a/consumer/release/RT/core/utility.js b/consumer/release/RT/core/utility.js deleted file mode 100644 index b070510..0000000 --- a/consumer/release/RT/core/utility.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - General utilities for the StyleRT library. -*/ - -window.StyleRT = window.StyleRT || {}; - -// --- DEBUG SYSTEM --- -window.StyleRT.debug = { - - // all debug messages enabled -/* - active_tokens: new Set([ - 'style', 'layout', 'pagination' - ,'selector', 'config', 'error' - ,'term' - ,'scroll' - ]), - - active_tokens: new Set([ - 'term' - ]), -*/ - - active_tokens: new Set([ - ]), - - log: function(token, message) { - if (this.active_tokens.has(token)) { - console.log(`[StyleRT:${token}]`, message); - } - }, - - warn: function(token, message) { - if (this.active_tokens.has(token)) { - console.warn(`[StyleRT:${token}]`, message); - } - }, - - // New: Always log errors regardless of token, but tag them - error: function(token, message) { - console.error(`[StyleRT:${token}] CRITICAL:`, message); - }, - - enable: function(token) { this.active_tokens.add(token); console.log(`Enabled: ${token}`); }, - disable: function(token) { this.active_tokens.delete(token); console.log(`Disabled: ${token}`); } -}; - -// --- UTILITIES --- -window.StyleRT.utility = { - // --- FONT PHYSICS --- - measure_ink_ratio: function(target_font, ref_font = null) { - const debug = window.StyleRT.debug; - debug.log('layout', `Measuring ink ratio for ${target_font}`); - - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - - if (!ref_font) { - const bodyStyle = window.getComputedStyle(document.body); - ref_font = bodyStyle.fontFamily; - } - - const get_metrics = (font) => { - ctx.font = '100px ' + font; - const metrics = ctx.measureText('M'); - return { - ascent: metrics.actualBoundingBoxAscent, - descent: metrics.actualBoundingBoxDescent - }; - }; - - const ref_m = get_metrics(ref_font); - const target_m = get_metrics(target_font); - - const ratio = ref_m.ascent / target_m.ascent; - // debug.log('layout', `Ink Ratio calculated: ${ratio.toFixed(3)}`); - - return { - ratio: ratio, - baseline_diff: ref_m.descent - target_m.descent - }; - }, - - // --- COLOR PHYSICS --- - is_color_light: function(color_string) { - const debug = window.StyleRT.debug; - - // 1. HSL Check - if (color_string.startsWith('hsl')) { - const numbers = color_string.match(/\d+/g); - if (numbers && numbers.length >= 3) { - const lightness = parseInt(numbers[2]); - return lightness > 50; - } - } - - // 2. RGB Check - const rgb = color_string.match(/\d+/g); - if (!rgb) { - // debug.warn('color_layout', `Failed to parse color: "${color_string}". Defaulting to Light.`); - return true; - } - - const r = parseInt(rgb[0]); - const g = parseInt(rgb[1]); - const b = parseInt(rgb[2]); - const luma = (r * 299 + g * 587 + b * 114) / 1000; - return luma > 128; - }, - - is_block_content: function(element) { - return element.textContent.trim().includes('\n'); - } -}; diff --git a/consumer/release/RT/document/setup.js b/consumer/release/RT/document/setup.js deleted file mode 100644 index 343de0f..0000000 --- a/consumer/release/RT/document/setup.js +++ /dev/null @@ -1,4 +0,0 @@ -window.RT_REPO_ROOT = "../../../../"; -document.write(''); -document.write(''); -document.write(''); diff --git a/consumer/release/RT/document/style_manual.html b/consumer/release/RT/document/style_manual.html deleted file mode 100644 index befc746..0000000 --- a/consumer/release/RT/document/style_manual.html +++ /dev/null @@ -1,354 +0,0 @@ - - - - - RT Style System: Reference Manual - - - - - - - - - - -

Table of Custom Tags

- -

Style Tag Reference

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TagDescription
<RT-article>Article 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-page>Automatically inserted pagination tag.
- -

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 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 just made up." -

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

- - - -

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

-

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

- - -

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 generates a standardized, styled header block with the document title and metadata. -

- -

Attributes

- - -

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

- -

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

- - -

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 one 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/consumer/release/RT/element/TOC.js b/consumer/release/RT/element/TOC.js deleted file mode 100644 index fb6b10a..0000000 --- a/consumer/release/RT/element/TOC.js +++ /dev/null @@ -1,162 +0,0 @@ -/* - 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). - -First heading 1 1 - First heading 2 2 - Next heading 2 2 -Next heading 2 3 - -*/ - -window.StyleRT = window.StyleRT || {}; - -window.StyleRT.TOC = function(){ - const debug = window.StyleRT.debug || { log: function(){} }; - const TOC_seq = document.querySelectorAll('rt-toc'); - - TOC_seq.forEach( (container ,TOC_index) => { - container.style.display = 'block'; - - // 1. Parse attribute: single number N or range A-B - const attr_val = container.getAttribute('level'); - let start_level, end_level; - - if (attr_val) { - const rangeMatch = attr_val.match(/^(\d)-(\d)$/); - if (rangeMatch) { - const a = parseInt(rangeMatch[1]); - const b = parseInt(rangeMatch[2]); - if (a >= 1 && a <= 6 && b >= 1 && b <= 6 && a <= b) { - start_level = a; - end_level = b; - if (debug.log) debug.log('TOC', `TOC #${TOC_index} range: H${a}-H${b}`); - } else { - if (debug.log) debug.log('TOC', `Invalid range "${attr_val}" → implicit mode`); - } - } else { - const single = parseInt(attr_val); - if (!isNaN(single) && single >= 1 && single <= 6) { - start_level = single; - end_level = single; - if (debug.log) debug.log('TOC', `TOC #${TOC_index} single level: H${single}`); - } else { - if (debug.log) debug.log('TOC', `Invalid level "${attr_val}" → implicit mode`); - } - } - } - - // 2. Implicit mode (no attribute or invalid) - if (start_level === undefined || end_level === undefined) { - let context_level = 0; - 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; - } - const target_level = Math.min(context_level + 1, 6); - start_level = target_level; - end_level = target_level; - if (debug.log) debug.log('TOC', `TOC #${TOC_index} implicit target: H${target_level}`); - } - - // 3. Collect all matching headings until a higher-level heading stops us - const headings = []; - 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 if we hit a heading that is a parent of the lowest level we collect - if (found_level < start_level) break; - - // Collect if within the requested range - if (found_level >= start_level && found_level <= end_level) { - // Ensure it has an id - if (!next_el.id) { - next_el.id = `TOC-ref-${TOC_index}-${found_level}-${headings.length}`; - } - headings.push({ el: next_el, level: found_level }); - } - } - next_el = next_el.nextElementSibling; - } - - // 4. Build the container (title + list) - container.innerHTML = ''; - const title = document.createElement('h1'); - title.textContent = start_level === 1 ? 'Table of Contents' : 'Section Contents'; - title.style.textAlign = 'center'; - container.appendChild(title); - - if (headings.length === 0) return; // nothing to show - - // Top-level list - const topList = document.createElement('ul'); - topList.style.listStyle = 'none'; - topList.style.paddingLeft = '0'; - container.appendChild(topList); - - // Stack of