From: Thomas Walker Lynch Date: Thu, 25 Jun 2026 12:38:14 +0000 (+0000) Subject: checkpoint X-Git-Url: https://git.reasoningtechnology.com/RT-Manuscript_locator.js?a=commitdiff_plain;h=13bc9df67db59efd637f829ca4b7f3167877d857;p=RT-Style checkpoint --- diff --git a/.gitignore b/.gitignore index 010247a..670a22b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ -# Protect against accidental local .gitignore deletion + +# no archive or temporary files +*.tar +*.tgz +*.zip +*. +temp.* **/scratchpad/* !**/scratchpad/.gitignore diff --git a/developer/authored/Manuscript.copy/Core/loader.js b/developer/authored/Manuscript.copy/Core/loader.js index 34218dc..83a420b 100644 --- a/developer/authored/Manuscript.copy/Core/loader.js +++ b/developer/authored/Manuscript.copy/Core/loader.js @@ -8,10 +8,10 @@ window.RT.load = function(module_path){ // Strict enforcement of the PascalCase namespace if (target_module === 'Theme') { - let saved_theme = localStorage.getItem('RT_theme_preference'); + let saved_theme = localStorage.getItem('RT·theme_preference'); if (!saved_theme) { saved_theme = 'dark_gold'; - localStorage.setItem('RT_theme_preference', saved_theme); + localStorage.setItem('RT·theme_preference', saved_theme); } target_module = 'Theme/' + saved_theme; } diff --git a/developer/authored/Manuscript.copy/Document/manual.html b/developer/authored/Manuscript.copy/Document/manual.html index fd9fd54..35ce1ac 100644 --- a/developer/authored/Manuscript.copy/Document/manual.html +++ b/developer/authored/Manuscript.copy/Document/manual.html @@ -10,18 +10,18 @@ - + - + - - + - +

Layout Environments

@@ -37,15 +37,15 @@ - <RT⋅article> + <RT·article> Standard technical document layout with dynamic pagination. - <RT⋅memo> + <RT·memo> Strict print layout (6.5 inch width, serif typography, monochrome). - <RT⋅book> + <RT·book> Multi chapter compilation layout (Upcoming). @@ -53,7 +53,7 @@

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

@@ -66,19 +66,19 @@ - <RT⋅title> + <RT·title> Constructs the standardized title block and metadata header. - <RT⋅TOC> + <RT·TOC> Compiles an automatic table of contents by scanning heading depths. - <RT⋅term-index> + <RT·term-index> Compiles an alphabetized glossary of terms defined within the document. - <RT⋅endnotes> + <RT·endnotes> Container for extracted bibliographic citations. @@ -94,35 +94,35 @@ - <RT⋅term> + <RT·term> Standard technical term. Decorates first occurrence and establishes an anchor. - <RT⋅term-em> + <RT·term-em> Forces visual emphasis for a term subsequent to its first occurrence. - <RT⋅neologism> + <RT·neologism> Project specific vocabulary. Styled distinctly from conventional terms. - <RT⋅neologism-em> + <RT·neologism-em> Forces visual emphasis for a neologism subsequent to its first occurrence. - <RT⋅code> + <RT·code> Code span or pre formatted code block with theme aware borders. - <RT⋅math> + <RT·math> Inline or block mathematics evaluated by MathJax. - <RT⋅symbol> + <RT·symbol> Technical symbol wrapper enforcing strict font weight and character spacing. - <RT⋅constraint> + <RT·constraint> Highlights architectural limits or hard requirements in a distinct block. @@ -138,23 +138,23 @@ - <RT-counter⋅make> + <RT·Counter··make> Declares an empty named counter sequence (e.g., figure, equation). - <RT-counter⋅step> + <RT·Counter··step> Advances the counter from empty or increments to the next ordinal address. - <RT-counter⋅indent> + <RT·Counter··indent> Pushes a new structural depth onto the tracking stack. - <RT-counter⋅snapshot> + <RT·Counter··snapshot> Deep copies the active count and styling parameters to a dictionary key. - <RT-counter⋅read> + <RT·Counter··read> Recalls a saved count or format parameter from the snapshot dictionary. @@ -170,19 +170,19 @@ - <RT⋅crossref> + <RT·crossref> Context aware internal anchor link. - <RT⋅ref> + <RT·ref> Dynamic reference evaluating to a structural target. - <RT⋅cite> + <RT·cite> Bibliographic citation marker mapping to the endnotes block. - <RT⋅footnote> + <RT·footnote> Inline text extracted and appended to the bottom of the active page. @@ -198,11 +198,11 @@ - <RT⋅page> + <RT·page> Automatically generated boundary container. Do not author manually. - <RT⋅page-break> + <RT·page-break> Explicit directive forcing subsequent content to the next page container. @@ -210,12 +210,12 @@

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. + 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. + The <RT·book> container is reserved for multi chapter compilations. It introduces tags designed exclusively for macro level document orchestration.

Book Specific Tags

@@ -228,7 +228,7 @@ - <RT⋅chapter> + <RT·chapter> Chapter heading. Implies a page break, inherits standard H1 typography, and registers as a top level division in the TOC. @@ -244,12 +244,12 @@ - <RT⋅theme-selector> + <RT·theme-selector> Floating interactive widget permitting real time swapping of visual themes. -
+ diff --git a/developer/authored/Manuscript.copy/Element/TOC.js b/developer/authored/Manuscript.copy/Element/TOC.js index 2f3bc6f..c790536 100644 --- a/developer/authored/Manuscript.copy/Element/TOC.js +++ b/developer/authored/Manuscript.copy/Element/TOC.js @@ -1,5 +1,5 @@ /* - Processes tags. + Processes tags. Populates each with headings found below it. Attributes: @@ -22,7 +22,7 @@ window.RT = window.RT || {}; window.RT.TOC = function(){ const debug = window.RT.debug || { log: function(){} }; - const TOC_seq = document.querySelectorAll('rt-toc'); + const TOC_seq = document.querySelectorAll('rt·toc'); TOC_seq.forEach( (container ,TOC_index) => { container.style.display = 'block'; @@ -151,7 +151,7 @@ window.RT.TOC = function(){ a.style.color = 'inherit'; a.style.display = 'block'; - a.onmouseover = () => a.style.color = 'var(--rt-brand-primary)'; + a.onmouseover = () => a.style.color = 'var(--RT·brand-primary)'; a.onmouseout = () => a.style.color = 'inherit'; li.appendChild(a); diff --git a/developer/authored/Manuscript.copy/Element/chapter.js b/developer/authored/Manuscript.copy/Element/chapter.js index 42ba956..8e0e38e 100644 --- a/developer/authored/Manuscript.copy/Element/chapter.js +++ b/developer/authored/Manuscript.copy/Element/chapter.js @@ -1,16 +1,16 @@ /* - Processes tags. - Transforms the tag into an followed by an

with the RT-chapter class. + Processes tags. + Transforms the tag into an followed by an

with the RT·chapter class. */ window.RT = window.RT || {}; window.RT.chapter = function(){ const debug = window.RT.debug || { log: function(){} }; - document.querySelectorAll('RT-chapter').forEach( (el ,index) => { + document.querySelectorAll('RT·chapter').forEach( (el ,index) => { if(debug.log) debug.log('chapter' ,`Processing chapter ${index + 1}`); - const brk = document.createElement('RT-page-break'); + const brk = document.createElement('RT·page-break'); const h1 = document.createElement('h1'); h1.innerHTML = el.innerHTML; @@ -18,7 +18,7 @@ window.RT.chapter = function(){ if(el.className){ h1.className = el.className; } - h1.classList.add('RT-chapter'); + h1.classList.add('RT·chapter'); Array.from(el.attributes).forEach( (attr) => { if(attr.name !== 'class'){ diff --git a/developer/authored/Manuscript.copy/Element/code.js b/developer/authored/Manuscript.copy/Element/code.js index 0a97f16..79a8a3b 100644 --- a/developer/authored/Manuscript.copy/Element/code.js +++ b/developer/authored/Manuscript.copy/Element/code.js @@ -1,5 +1,5 @@ /* - Processes tags. + Processes tags. Uses the central config or CSS variables from the theme. Removes common indent from lines of code. @@ -13,11 +13,11 @@ function code() { const metrics = U.measure_ink_ratio('monospace'); - document.querySelectorAll('rt-code').forEach((el) => { + document.querySelectorAll('rt·code').forEach((el) => { el.style.fontFamily = 'monospace'; const computed = window.getComputedStyle(el); - const accent = computed.getPropertyValue('--rt-accent').trim() || 'gold'; + const accent = computed.getPropertyValue('--RT·accent').trim() || 'gold'; const is_block = U.is_block_content(el); const parentColor = computed.color; diff --git a/developer/authored/Manuscript.copy/Element/constraint.js b/developer/authored/Manuscript.copy/Element/constraint.js index c33b7b0..a2b1747 100644 --- a/developer/authored/Manuscript.copy/Element/constraint.js +++ b/developer/authored/Manuscript.copy/Element/constraint.js @@ -2,12 +2,12 @@ window.RT = window.RT || {}; window.RT.constraint = function(){ - document.querySelectorAll('rt-constraint').forEach( (el) => { + document.querySelectorAll('rt·constraint').forEach( (el) => { el.style.display = 'block'; - el.style.borderLeft = '4px solid var(--rt-state-warning)'; - el.style.backgroundColor = 'var(--rt-surface-1)'; + el.style.borderLeft = '4px solid var(--RT·state-warning)'; + el.style.backgroundColor = 'var(--RT·surface-1)'; el.style.padding = '1rem'; el.style.margin = '1.5rem 0'; - el.style.color = 'var(--rt-content-main)'; + el.style.color = 'var(--RT·content-main)'; }); }; diff --git a/developer/authored/Manuscript.copy/Element/counter.js b/developer/authored/Manuscript.copy/Element/counter.js index f3693db..b4b0485 100644 --- a/developer/authored/Manuscript.copy/Element/counter.js +++ b/developer/authored/Manuscript.copy/Element/counter.js @@ -99,7 +99,7 @@ window.RT.counter_do_count = function (root_node) { const tag = node.tagName.toLowerCase(); let pushed_name = null; - if (tag === 'rt-counter_make') { + if (tag === 'RT·Counter··make') { const name = node.getAttribute('counter'); if (name) { const style = node.getAttribute('style') || 'Natural'; @@ -119,14 +119,14 @@ window.RT.counter_do_count = function (root_node) { count: '' }; } - } else if (tag === 'rt-counter_indent') { + } 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') { + } 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]; @@ -150,7 +150,7 @@ window.RT.counter_do_count = function (root_node) { state.count = count_str; } - } else if (tag === 'rt-counter_snapshot') { + } else if (tag === 'RT·Counter··snapshot') { const counter_name = node.getAttribute('counter'); const snapshot_name = node.getAttribute('snapshot'); @@ -159,7 +159,7 @@ window.RT.counter_do_count = function (root_node) { const depth = state.stack.length - 1; 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.`); + 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); } @@ -186,7 +186,7 @@ window.RT.counter_do_snapshot = function (root_node) { }; window.RT.counter_do_read = function (root_node) { - const reads = root_node.querySelectorAll('rt-counter_read'); + 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'; @@ -196,7 +196,7 @@ window.RT.counter_do_read = function (root_node) { 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.`); + console.error(`RT-Style Layout Error: failed. No snapshot named '${snapshot_name}' found in the dictionary.`); } } }; diff --git a/developer/authored/Manuscript.copy/Element/crossref.js b/developer/authored/Manuscript.copy/Element/crossref.js index aaea2bc..c7c5f86 100644 --- a/developer/authored/Manuscript.copy/Element/crossref.js +++ b/developer/authored/Manuscript.copy/Element/crossref.js @@ -2,8 +2,8 @@ window.RT = window.RT || {}; window.RT.crossref = function(){ - document.querySelectorAll('rt-crossref').forEach( (el) => { - el.style.color = 'var(--rt-brand-link)'; + document.querySelectorAll('rt·crossref').forEach( (el) => { + el.style.color = 'var(--RT·brand-link)'; el.style.textDecoration = 'underline'; el.style.cursor = 'pointer'; el.style.fontWeight = '500'; diff --git a/developer/authored/Manuscript.copy/Element/endnote.js b/developer/authored/Manuscript.copy/Element/endnote.js index dd887b3..fa78943 100644 --- a/developer/authored/Manuscript.copy/Element/endnote.js +++ b/developer/authored/Manuscript.copy/Element/endnote.js @@ -1,10 +1,10 @@ window.RT = window.RT || {}; -window.RT.end_note = function(){ - const citations = document.querySelectorAll('rt-cite'); +window.RT.endnote = function(){ + const citations = document.querySelectorAll('rt·cite'); if(citations.length === 0) return; - const article = document.querySelector('rt-article'); + const article = document.querySelector('rt·article'); if(!article) return; // 1. Ensure the H1 is a direct child of the article so the TOC can see it @@ -17,9 +17,9 @@ window.RT.end_note = function(){ } // 2. Locate or generate the endnotes list container - let endnoteContainer = document.querySelector('rt-endnotes'); + let endnoteContainer = document.querySelector('rt·endnotes'); if(!endnoteContainer) { - endnoteContainer = document.createElement('rt-endnotes'); + endnoteContainer = document.createElement('rt·endnotes'); article.appendChild(endnoteContainer); } @@ -37,7 +37,7 @@ window.RT.end_note = function(){ cite.innerHTML = `[${refNum}]`; cite.style.cursor = 'pointer'; - cite.style.color = 'var(--rt-brand-link)'; + cite.style.color = 'var(--RT·brand-link)'; cite.style.textDecoration = 'none'; // Append the corresponding entry into the endnotes list @@ -50,6 +50,6 @@ window.RT.end_note = function(){ // Style the container endnoteContainer.style.display = 'block'; endnoteContainer.style.marginTop = '1rem'; - endnoteContainer.style.borderTop = '1px solid var(--rt-surface-3)'; + endnoteContainer.style.borderTop = '1px solid var(--RT·surface-3)'; endnoteContainer.style.paddingTop = '1rem'; }; diff --git a/developer/authored/Manuscript.copy/Element/math.js b/developer/authored/Manuscript.copy/Element/math.js index 51d86a7..44ccdde 100644 --- a/developer/authored/Manuscript.copy/Element/math.js +++ b/developer/authored/Manuscript.copy/Element/math.js @@ -1,11 +1,11 @@ /* - Processes tags. + Processes tags. JavaScript: math() - HTML Tag: (parsed as rt-math) + HTML Tag: (parsed as rt·math) */ function math(){ - // querySelector treats 'rt-math' as case-insensitive for the tag - document.querySelectorAll('rt-math').forEach(el => { + // querySelector treats 'rt·math' as case-insensitive for the tag + document.querySelectorAll('rt·math').forEach(el => { if (el.textContent.startsWith('$')) return; const is_block = el.parentElement.tagName === 'DIV' || diff --git a/developer/authored/Manuscript.copy/Element/symbol.js b/developer/authored/Manuscript.copy/Element/symbol.js index 7199fda..f6bbd1a 100644 --- a/developer/authored/Manuscript.copy/Element/symbol.js +++ b/developer/authored/Manuscript.copy/Element/symbol.js @@ -2,7 +2,7 @@ window.RT = window.RT || {}; window.RT.symbol = function(){ - document.querySelectorAll('rt-symbol').forEach( (el) => { + document.querySelectorAll('rt·symbol').forEach( (el) => { el.style.fontFamily = '"Courier New", Courier, monospace'; el.style.fontWeight = '600'; el.style.padding = '0 0.1em'; diff --git a/developer/authored/Manuscript.copy/Element/term.js b/developer/authored/Manuscript.copy/Element/term.js index 1cc779c..ac2a375 100644 --- a/developer/authored/Manuscript.copy/Element/term.js +++ b/developer/authored/Manuscript.copy/Element/term.js @@ -1,7 +1,7 @@ /* - Processes and tags. + Processes and tags. - Styles only the first occurrence of a unique term/neologism. - - The "-em" variants (e.g., ) are always styled. + - The "-em" variants (e.g., ) are always styled. - Automatically generates IDs for first occurrences for future indexing. */ @@ -26,8 +26,8 @@ window.RT.term = function() { el.style.fontStyle = 'italic'; el.style.fontWeight = is_neologism_b ? '600' : '500'; el.style.color = is_neologism_b - ? 'var(--rt-brand-secondary)' - : 'var(--rt-brand-primary)'; + ? 'var(--RT·brand-secondary)' + : 'var(--RT·brand-primary)'; el.style.paddingRight = '0.1em'; // Compensation for italic slant el.style.display = 'inline'; }; @@ -41,10 +41,10 @@ window.RT.term = function() { }; const selector_s = [ - 'rt-term' - ,'rt-term-em' - ,'rt-neologism' - ,'rt-neologism-em' + 'rt·term' + ,'rt·term-em' + ,'rt·neologism' + ,'rt·neologism-em' ].join(','); const tags_dpa = document.querySelectorAll(selector_s); diff --git a/developer/authored/Manuscript.copy/Element/theme_selector.js b/developer/authored/Manuscript.copy/Element/theme_selector.js index 05759d2..3e94b49 100644 --- a/developer/authored/Manuscript.copy/Element/theme_selector.js +++ b/developer/authored/Manuscript.copy/Element/theme_selector.js @@ -1,27 +1,40 @@ -class ThemeSelector extends HTMLElement{ - connectedCallback(){ +window.RT = window.RT || {}; + +window.RT.theme_selector = function(){ + document.querySelectorAll('rt·theme-selector').forEach( (el) => { let current_theme = localStorage.getItem('RT_theme_preference'); if(!current_theme){ current_theme = 'dark_gold'; } - this.innerHTML = ` -
- Theme Selection
-
- -
+ const container = document.createElement('div'); + container.style.position = 'fixed'; + container.style.top = '10px'; + container.style.right = '10px'; + container.style.zIndex = '1000'; + container.style.background = '#222'; + container.style.padding = '10px'; + container.style.border = '1px solid #555'; + container.style.color = 'white'; + container.style.fontFamily = 'sans-serif'; + + container.innerHTML = ` + Theme Selection
+
+ `; - this.addEventListener( 'change' ,(e) => { - localStorage.setItem('RT_theme_preference' ,e.target.value); - location.reload(); - } ); - } -} + container.addEventListener( 'change' ,(e) => { + if(e.target.name === 'RT·theme') { + localStorage.setItem('RT_theme_preference' ,e.target.value); + location.reload(); + } + }); -customElements.define('rt-theme-selector' ,ThemeSelector); + el.replaceWith(container); + }); +}; diff --git a/developer/authored/Manuscript.copy/Element/title.js b/developer/authored/Manuscript.copy/Element/title.js index bfb8d4e..d3cf4bd 100644 --- a/developer/authored/Manuscript.copy/Element/title.js +++ b/developer/authored/Manuscript.copy/Element/title.js @@ -1,16 +1,16 @@ /* - Processes tags. + Processes tags. Generates a standard document header block. Usage: - + */ window.RT = window.RT || {}; window.RT.title = function() { const debug = window.RT.debug || { log: function(){} }; - document.querySelectorAll('rt-title').forEach(el => { + document.querySelectorAll('rt·title').forEach(el => { const title = el.getAttribute('title') || 'Untitled Document'; const author = el.getAttribute('author'); const date = el.getAttribute('date'); @@ -23,7 +23,7 @@ window.RT.title = function() { container.style.textAlign = 'center'; container.style.marginBottom = '3rem'; container.style.marginTop = '2rem'; - container.style.borderBottom = '1px solid var(--rt-border-default)'; + container.style.borderBottom = '1px solid var(--RT·border-default)'; container.style.paddingBottom = '1.5rem'; // Main Title (H1) @@ -32,7 +32,7 @@ window.RT.title = function() { 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.color = 'var(--RT·brand-primary)'; h1.style.fontSize = '2.5em'; h1.style.lineHeight = '1.1'; h1.style.letterSpacing = '-0.03em'; @@ -42,13 +42,13 @@ window.RT.title = function() { // Metadata Row (Author | Date) if (author || date) { const meta = document.createElement('div'); - meta.style.color = 'var(--rt-content-muted)'; + 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 (author) parts.push(`${author}`); if (date) parts.push(date); meta.innerHTML = parts.join('  —  '); @@ -58,7 +58,7 @@ window.RT.title = function() { // Copyright Row if (copyright) { const copy_div = document.createElement('div'); - copy_div.style.color = 'var(--rt-content-muted)'; + copy_div.style.color = 'var(--RT·content-muted)'; copy_div.style.fontSize = '0.9em'; copy_div.style.marginTop = '0.5rem'; // Automatically injects the copyright symbol diff --git a/developer/authored/Manuscript.copy/Layout/article_tech_ref.js b/developer/authored/Manuscript.copy/Layout/article_tech_ref.js index 46e2243..0a7ee04 100644 --- a/developer/authored/Manuscript.copy/Layout/article_tech_ref.js +++ b/developer/authored/Manuscript.copy/Layout/article_tech_ref.js @@ -1,69 +1,81 @@ -// debug messages don't work here, because core/utility isn't loaded until after the function runs. (function(){ const RT = window.RT = window.RT || {}; const debug = RT.debug || { log: function(){} }; - debug.log('scroll', "1. Initializing script."); + // --- Shared State --- + let target_y = 0; + let is_reload = false; + let is_layout_locked = true; + let scroll_timer; - // 1. Intercept native history restoration immediately - if ('scrollRestoration' in history) { - history.scrollRestoration = 'manual'; - debug.log('scroll', "2. history.scrollRestoration set to manual."); - } + // ========================================== + // FUNCTION DEFINITIONS + // ========================================== - // 2. Read coordinate from memory before any layout shifts occur - const raw_target = sessionStorage.getItem('RT_saved_y'); - const target_y = raw_target !== null ? parseInt(raw_target, 10) : 0; - - // 3. Determine if the execution is a page reload - let is_reload = false; - if (window.performance) { - const nav_entries = performance.getEntriesByType("navigation"); - if (nav_entries.length > 0) { - is_reload = (nav_entries[0].type === "reload"); - } else if (performance.navigation) { - is_reload = (performance.navigation.type === 1); + function configure_history(){ + if ('scrollRestoration' in history) { + history.scrollRestoration = 'manual'; + debug.log('scroll' ,"2. history.scrollRestoration set to manual."); } } - debug.log('scroll', `3. Target Y: ${target_y} | Is Reload: ${is_reload}`); + function capture_scroll_target(){ + const raw_target = sessionStorage.getItem('RT_saved_y'); + target_y = raw_target !== null ? parseInt(raw_target ,10) : 0; + + if (window.performance) { + const nav_entries = performance.getEntriesByType("navigation"); + if (nav_entries.length > 0) { + is_reload = (nav_entries[0].type === "reload"); + } else if (performance.navigation) { + is_reload = (performance.navigation.type === 1); + } + } + debug.log('scroll' ,`3. Target Y: ${target_y} | Is Reload: ${is_reload}`); + } - // 4. The Lock - let is_layout_locked = true; + function load_elements(){ + debug.log('scroll' ,"4. Loading module dependencies."); + RT.load('Element/counter'); + RT.load('Element/chapter'); + RT.load('Element/endnote'); + RT.load('Element/math'); + RT.load('Element/code'); + RT.load('Element/term'); + RT.load('Element/TOC'); + RT.load('Element/title'); + RT.load('Element/symbol'); + RT.load('Element/constraint'); + RT.load('Element/crossref'); + + RT.load('Layout/paginate_by_element'); + RT.load('Layout/page_fixed_glow'); + } - // Helper to ensure we only signal completion once - function unlock_layout() { - if (!is_layout_locked) return; - is_layout_locked = false; - debug.log('scroll', "10. Layout fully unlocked. Emitting completion signal."); - document.dispatchEvent(new Event("RT_layout_complete")); + function apply_style_rule(selector ,rules){ + document.querySelectorAll(selector).forEach( (el) => { + for (let prop in rules) { + if (typeof rules[prop] === 'string' && rules[prop].indexOf('!important') !== -1) { + const kebab_prop = prop.replace(/[A-Z]/g ,m => "-" + m.toLowerCase()); + const value = rules[prop].replace(' !important' ,''); + el.style.setProperty(kebab_prop ,value ,'important'); + } else { + el.style[prop] = rules[prop]; + } + } + }); } - // 5. Declare Dependencies - RT.load('Element/counter'); - RT.load('Element/chapter'); - RT.load('Element/endnote'); - RT.load('Element/math'); - RT.load('Element/code'); - RT.load('Element/term'); - RT.load('Element/TOC'); - RT.load('Element/title'); - RT.load('Element/symbol'); - RT.load('Element/constraint'); - RT.load('Element/crossref'); - - RT.load('Layout/paginate_by_element'); - RT.load('Layout/page_fixed_glow'); - - // 6. The Typography Layout - RT.article = function(){ + function apply_style(){ + debug.log('scroll' ,"5. Applying typography styles."); + RT.config = RT.config || {}; RT.config.article = { - font_family: '"Noto Sans", "Segoe UI", "Helvetica Neue", sans-serif' + font_family: "'Noto Sans JP', Arial, sans-serif" ,line_height: "1.8" ,font_size: "16px" ,font_weight: "400" - ,max_width: "820px" + ,max_width: "46.875rem" ,margin: "0 auto" }; @@ -71,130 +83,61 @@ RT.config.article.font_weight = "600"; } - const conf = RT.config.article; - const article_seq = document.querySelectorAll("RT-article"); - - if(article_seq.length === 0) return; - - for(let i = 0; i < article_seq.length; i++){ - let style = article_seq[i].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)"; - } - window.RT = window.RT || {}; window.RT.config = window.RT.config || {}; window.RT.config.page = window.RT.config.page || {}; window.RT.config.page.height_limit = 900; - const style_node = document.createElement("style"); - style_node.innerHTML = ` - body, html, rt-article { - overflow-anchor: none !important; - } - - rt-article { - font-family: 'Noto Sans JP', Arial, sans-serif; - background-color: var(--rt-surface-0); - color: var(--rt-content-main); - max-width: 46.875rem !important; - box-sizing: border-box !important; - } - - rt-article:not(:has(rt-page)) { - padding: 3rem !important; - } - - rt-article:has(rt-page) { - padding: 0 !important; - } - - rt-article rt-page { - position: relative; - display: block; - padding: 3rem; - margin: 1.25rem auto; - background-color: var(--rt-surface-0); - box-shadow: 0 0 0.625rem var(--rt-brand-primary); - } - - rt-article h1 { - font-size: 1.5rem; - text-align: center; - color: var(--rt-brand-primary); - font-weight: 500; - margin-top: 1.5rem; - line-height: 1.15; - } - rt-article h2 { - font-size: 1.25rem; - color: var(--rt-brand-secondary); - text-align: left; - margin-top: 2rem; - margin-left: 0; - } - rt-article h3 { - font-size: 1.125rem; - color: var(--rt-brand-tertiary); - text-align: left; - margin-top: 1.5rem; - margin-left: 4ch; - } - rt-article h4 { - font-size: 1.05rem; - color: var(--rt-content-main); - font-weight: 600; - text-align: left; - margin-top: 1.25rem; - margin-left: 8ch; - } - - rt-article p, - rt-article ul, - rt-article ol { - color: var(--rt-content-main); - text-align: justify; - margin-bottom: 1rem; - margin-left: 0; - } - rt-article li { - margin-bottom: 0.5rem; - } - - rt-article rt-code { - font-family: 'Courier New', Courier, monospace; - background-color: var(--rt-surface-code); - padding: 0.125rem 0.25rem; - color: var(--rt-content-main); - } + const conf = RT.config.article; - rt-article img { - max-width: 100%; - height: auto; - display: block; - margin: 1.5rem auto; - } - `; - document.head.appendChild(style_node); - }; +apply_style_rule('body, html, RT·article' ,{ overflowAnchor: "none !important" }); + + apply_style_rule('RT·article', { + display: "block", + fontFamily: conf.font_family, + fontSize: conf.font_size, + lineHeight: conf.line_height, + fontWeight: conf.font_weight, + maxWidth: conf.max_width + " !important", + margin: conf.margin, + backgroundColor: RT.config.theme.surface_0, + color: RT.config.theme.content_main, + boxSizing: "border-box !important" + }); + + apply_style_rule('RT·article:not(:has(RT·page))' ,{ padding: "3rem !important" }); + apply_style_rule('RT·article:has(RT·page)' ,{ padding: "0 !important" }); + + apply_style_rule('RT·article RT·page' ,{ + position: "relative", + display: "block", + padding: "3rem", + margin: "1.25rem auto", + backgroundColor: RT.config.theme.surface_0, + boxShadow: `0 0 0.625rem ${RT.config.theme.brand_primary}` + }); + + apply_style_rule('RT·article h1' ,{ fontSize: "1.5rem", textAlign: "center", color: RT.config.theme.brand_primary, fontWeight: "500", marginTop: "1.5rem", lineHeight: "1.15" }); + apply_style_rule('RT·article h2' ,{ fontSize: "1.25rem", color: RT.config.theme.brand_secondary, textAlign: "left", marginTop: "2rem", marginLeft: "0" }); + apply_style_rule('RT·article h3' ,{ fontSize: "1.125rem", color: RT.config.theme.brand_tertiary, textAlign: "left", marginTop: "1.5rem", marginLeft: "4ch" }); + apply_style_rule('RT·article h4' ,{ fontSize: "1.05rem", color: RT.config.theme.content_main, fontWeight: "600", textAlign: "left", marginTop: "1.25rem", marginLeft: "8ch" }); + apply_style_rule('RT·article p, RT·article ul, RT·article ol' ,{ color: RT.config.theme.content_main, textAlign: "justify", marginBottom: "1rem", marginLeft: "0" }); + apply_style_rule('RT·article li' ,{ marginBottom: "0.5rem" }); + apply_style_rule('RT·article RT·code' ,{ fontFamily: "'Courier New', Courier, monospace", backgroundColor: RT.config.theme.surface_code, padding: "0.125rem 0.25rem", color: RT.config.theme.content_main }); + apply_style_rule('RT·article img' ,{ maxWidth: "100%", height: "auto", display: "block", margin: "1.5rem auto" }); + } - // 7. The Execution Sequence - function run_semantics(){ - debug.log('scroll' ,`4. run_semantics starting.`); + function process_custom_elements(){ + debug.log('scroll' ,`7. Processing custom elements.`); + if(RT.theme) RT.theme(); if(RT.endnote) RT.endnote(); - RT.article(); + if(RT.counter_do_count){ RT.counter_do_count(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(); @@ -204,21 +147,21 @@ if(RT.crossref) RT.crossref(); if( window.MathJax && MathJax.Hub && MathJax.Hub.Queue ){ - MathJax.Hub.Queue( ["Typeset" ,MathJax.Hub] ,run_layout ); + MathJax.Hub.Queue( ["Typeset" ,MathJax.Hub] ,execute_pagination_and_scroll ); }else{ - run_layout(); + execute_pagination_and_scroll(); } } - function run_layout() { - debug.log('scroll', `5. run_layout starting.`); + function execute_pagination_and_scroll(){ + debug.log('scroll' ,`8. Pagination layout starting.`); if(RT.chapter) RT.chapter(); if(RT.TOC) RT.TOC(); if(RT.paginate_by_element) RT.paginate_by_element(); if(RT.page) RT.page(); - debug.log('scroll', `6. Pagination complete.`); + debug.log('scroll' ,`9. Pagination complete.`); let final_target = target_y; let use_hash = false; @@ -230,14 +173,13 @@ } } - debug.log('scroll', `7. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`); - enforce_scroll(final_target, use_hash, 0); + debug.log('scroll' ,`10. Commencing viewport enforce loop. Mode: ${use_hash ? 'HASH' : 'Y-COORDINATE'}`); + enforce_scroll(final_target ,use_hash ,0); } - // 8. The Enforcer Logic - function enforce_scroll(target, use_hash, attempts) { + function enforce_scroll(target ,use_hash ,attempts){ if (attempts > 15) { - debug.log('scroll', "8. Scroll enforcement timed out. Unlocking."); + debug.log('scroll' ,"11. Scroll enforcement timed out. Unlocking."); unlock_layout(); return; } @@ -246,54 +188,68 @@ const hash_target = document.getElementById(window.location.hash.substring(1)); if (hash_target) { hash_target.scrollIntoView(); - debug.log('scroll', `8a. Attempt ${attempts}: Scrolled to Hash Target. Y is now ${window.scrollY}`); } } else { - window.scrollTo(0, target); - debug.log('scroll', `8b. Attempt ${attempts}: Scrolled to Y=${target}. Current Y is ${window.scrollY}`); + window.scrollTo(0 ,target); } - let is_successful = false; - if (use_hash) { - is_successful = true; - } else { - is_successful = (Math.abs(window.scrollY - target) < 5 || target === 0); - } + let is_successful = use_hash ? true : (Math.abs(window.scrollY - target) < 5 || target === 0); if (is_successful && document.body.scrollHeight > 1000) { - debug.log('scroll', `9. Viewport anchored successfully.`); - + debug.log('scroll' ,`12. Viewport anchored successfully.`); setTimeout(() => { if (!use_hash && Math.abs(window.scrollY - target) >= 5) { - debug.log('scroll', `9a. Browser late-stage rebellion detected. Re-enforcing.`); - enforce_scroll(target, use_hash, attempts + 1); + debug.log('scroll' ,`12a. Browser late-stage rebellion detected. Re-enforcing.`); + enforce_scroll(target ,use_hash ,attempts + 1); } else { unlock_layout(); } }, 100); } else { - setTimeout(() => enforce_scroll(target, use_hash, attempts + 1), 50); + setTimeout(() => enforce_scroll(target ,use_hash ,attempts + 1) ,50); } } - // 9. The Ledger - let scroll_timer; - window.addEventListener('scroll', () => { - if (is_layout_locked) return; - clearTimeout(scroll_timer); - scroll_timer = setTimeout(() => { - sessionStorage.setItem('RT_saved_y', window.scrollY); - debug.log('scroll', `X. User stopped scrolling. Saved Y: ${window.scrollY}`); - }, 200); - }, { passive: true }); - - window.addEventListener('beforeunload', () => { - is_layout_locked = true; - debug.log('scroll', "Y. Page unloading. Scroll listener locked."); - }); + function unlock_layout(){ + if (!is_layout_locked) return; + is_layout_locked = false; + debug.log('scroll' ,"13. Layout fully unlocked. Emitting completion signal."); + document.dispatchEvent(new Event("RT_layout_complete")); + } - // 10. Bind to DOM Ready - document.addEventListener('DOMContentLoaded', run_semantics); + function bind_window_events(){ + debug.log('scroll' ,"6. Binding passive lifecycle events."); + + window.addEventListener('scroll' ,() => { + if (is_layout_locked) return; + clearTimeout(scroll_timer); + scroll_timer = setTimeout(() => { + sessionStorage.setItem('RT_saved_y' ,window.scrollY); + debug.log('scroll' ,`X. User stopped scrolling. Saved Y: ${window.scrollY}`); + }, 200); + }, { passive: true }); + + window.addEventListener('beforeunload' ,() => { + is_layout_locked = true; + debug.log('scroll' ,"Y. Page unloading. Scroll listener locked."); + }); + } -})(); + // ========================================== + // THE EXECUTION OUTLINE + // ========================================== + debug.log('scroll' ,"1. Initializing script."); + + // Synchronous tasks (execute immediately while head parses) + configure_history(); + capture_scroll_target(); + load_elements(); + bind_window_events(); + + // Asynchronous tasks (wait for body elements to exist) + document.addEventListener('DOMContentLoaded', () => { + process_custom_elements(); // 1. Build the final DOM structure + apply_style(); // 2. Paint the assembled structure + }); +})(); diff --git a/developer/authored/Manuscript.copy/Layout/memo_State.js b/developer/authored/Manuscript.copy/Layout/memo_State.js index 51a178e..29629d6 100644 --- a/developer/authored/Manuscript.copy/Layout/memo_State.js +++ b/developer/authored/Manuscript.copy/Layout/memo_State.js @@ -5,8 +5,8 @@ - - + + */ @@ -31,7 +31,7 @@ body.style.color = "black"; // Target the new semantic tag - const memo_seq = document.querySelectorAll("RT-memo"); + const memo_seq = document.querySelectorAll("RT·memo"); if(memo_seq.length === 0) return; for(let i = 0; i < memo_seq.length; i++){ diff --git a/developer/authored/Manuscript.copy/Layout/page_fixed_glow.js b/developer/authored/Manuscript.copy/Layout/page_fixed_glow.js index 6ef8819..be1c1be 100644 --- a/developer/authored/Manuscript.copy/Layout/page_fixed_glow.js +++ b/developer/authored/Manuscript.copy/Layout/page_fixed_glow.js @@ -16,17 +16,17 @@ ,padding: "3rem" ,margin: "4rem auto" - ,bg_color: "var(--rt-surface-0)" - ,border_color: "var(--rt-brand-primary)" - ,text_color: "var(--rt-brand-primary)" + ,bg_color: "var(--RT·surface-0)" + ,border_color: "var(--RT·brand-primary)" + ,text_color: "var(--RT·brand-primary)" - ,shadow: "drop-shadow(0px 0px 15px var(--rt-brand-primary))" + ,shadow: "drop-shadow(0px 0px 15px var(--RT·brand-primary))" }; RT.config.page = Object.assign({}, defaults, RT.config.page || {}); const conf = RT.config.page; - const style_id = 'rt-page-fixed-glow'; + const style_id = 'RT·page-fixed-glow'; if (!document.getElementById(style_id)) { const style_el = document.createElement('style'); @@ -34,11 +34,11 @@ style_el.textContent = ` /* Reset page counter on the article container */ - rt-article { - counter-reset: rt-page-counter; + RT·article { + counter-reset: RT·page-counter; } - rt-page { + RT·page { display: block; position: relative; box-sizing: border-box; @@ -58,12 +58,12 @@ filter: ${conf.shadow}; /* Counter Increment */ - counter-increment: rt-page-counter; + counter-increment: RT·page-counter; } /* Page Numbering */ - rt-page::after { - content: "Page " counter(rt-page-counter); + RT·page::after { + content: "Page " counter(RT·page-counter); position: absolute; bottom: 1.5rem; right: 3rem; diff --git a/developer/authored/Manuscript.copy/Layout/paginate_by_element.js b/developer/authored/Manuscript.copy/Layout/paginate_by_element.js index aca2122..2a0014b 100644 --- a/developer/authored/Manuscript.copy/Layout/paginate_by_element.js +++ b/developer/authored/Manuscript.copy/Layout/paginate_by_element.js @@ -21,7 +21,7 @@ window.RT.paginate_by_element = function () { function getMeasureContainer() { if (measureContainer && measureContainer.parentNode) return measureContainer; - const article = document.querySelector('RT-article'); + const article = document.querySelector('RT·article'); if (!article) { const temp = document.createElement('div'); temp.style.visibility = 'hidden'; @@ -56,9 +56,9 @@ window.RT.paginate_by_element = function () { // ========================================================= // STEP 1: PREPARE FOOTNOTES (Strip and tag) // ========================================================= - const article_seq = document.querySelectorAll('RT-article'); + const article_seq = document.querySelectorAll('RT·article'); if (article_seq.length === 0) { - debug.error('pagination', 'No elements found. Pagination aborted.'); + debug.error('pagination', 'No elements found. Pagination aborted.'); return; } @@ -68,7 +68,7 @@ window.RT.paginate_by_element = function () { Array.from(article_seq).forEach(article => { // Bulletproof extraction: immune to XML/HTML case-sensitivity parsing quirks const all_nodes = Array.from(article.querySelectorAll('*')); - const raw_footnotes = all_nodes.filter(node => node.tagName.toLowerCase() === 'rt-footnote'); + const raw_footnotes = all_nodes.filter(node => node.tagName.toLowerCase() === 'RT·footnote'); raw_footnotes.forEach(fn => { const id = footnote_counter++; @@ -81,7 +81,7 @@ window.RT.paginate_by_element = function () { } // Replace with a zero-height marker that rides along with the text - const marker = document.createElement('rt-fn-marker'); + const marker = document.createElement('RT·fn-marker'); marker.setAttribute('data-id', id); if (fn.parentNode) { @@ -246,7 +246,7 @@ window.RT.paginate_by_element = function () { // ========================================================= function paginateArticle(article) { const raw_element_seq = Array.from(article.children).filter(el => - !['SCRIPT', 'STYLE', 'RT-PAGE'].includes(el.tagName) + !['SCRIPT', 'STYLE', 'RT·PAGE'].includes(el.tagName) ); if (raw_element_seq.length === 0) return; @@ -275,7 +275,7 @@ window.RT.paginate_by_element = function () { } } else { if (current_batch_seq.length === 0) { - const frame = document.createElement('rt-scroll-frame'); + const frame = document.createElement('RT·scroll-frame'); frame.style.display = 'block'; frame.style.overflowY = 'auto'; frame.style.maxHeight = page_height_limit + 'px'; @@ -295,7 +295,7 @@ window.RT.paginate_by_element = function () { // --- Ordinary (non-splittable) element --- const h = getElHeight(el); - const is_RT_page_break = el.tagName && el.tagName.toLowerCase() === 'rt-page-break'; + const is_RT_page_break = el.tagName && el.tagName.toLowerCase() === 'RT·page-break'; if( (is_RT_page_break || current_h + h > page_height_limit) && current_batch_seq.length > 0 ){ let backtrack_seq = []; @@ -329,12 +329,12 @@ window.RT.paginate_by_element = function () { page_seq.push(current_batch_seq); } - // Rebuild article with wrappers + // Rebuild article with wrappers article.innerHTML = ''; let p = 0; while (p < page_seq.length) { const batch = page_seq[p]; - const page_el = document.createElement('rt-page'); + const page_el = document.createElement('RT·page'); page_el.id = `page-${p + 1}`; batch.forEach(item => page_el.appendChild(item)); article.appendChild(page_el); @@ -349,19 +349,19 @@ window.RT.paginate_by_element = function () { // STEP 3: RESOLVE FOOTNOTES & EXPAND PAGES // ========================================================= Array.from(article_seq).forEach(article => { - const rendered_pages = article.querySelectorAll('rt-page'); + const rendered_pages = article.querySelectorAll('RT·page'); Array.from(rendered_pages).forEach(page => { // Bulletproof extraction for the markers const all_page_nodes = Array.from(page.querySelectorAll('*')); - const markers = all_page_nodes.filter(node => node.tagName.toLowerCase() === 'rt-fn-marker'); + const markers = all_page_nodes.filter(node => node.tagName.toLowerCase() === 'RT·fn-marker'); if (markers.length === 0) return; // Construct the footer block for this page const fn_container = document.createElement('div'); - fn_container.className = 'rt-footnote-container'; - fn_container.style.borderTop = '1px solid var(--rt-border-default)'; + fn_container.className = 'RT·footnote-container'; + fn_container.style.borderTop = '1px solid var(--RT·border-default)'; fn_container.style.marginTop = '2rem'; fn_container.style.paddingTop = '1rem'; fn_container.style.fontSize = '0.9em'; @@ -372,7 +372,7 @@ window.RT.paginate_by_element = function () { // Replace the invisible marker with the visible naked superscript link const sup = document.createElement('sup'); - sup.innerHTML = `${id}`; + sup.innerHTML = `${id}`; if (marker.parentNode) { marker.parentNode.replaceChild(sup, marker); diff --git a/tester/authored/Counter/test_cdot.html b/tester/authored/Counter/test_cdot.html new file mode 100644 index 0000000..c9ae387 --- /dev/null +++ b/tester/authored/Counter/test_cdot.html @@ -0,0 +1,103 @@ + + + + + + + + Comprehensive RT· Namespace Test + + + + + +

Hello!

+ + Chapter 1: The Setup + + Chapter 2: The Execution + + + diff --git a/tester/authored/Counter/test_mdot.html b/tester/authored/Counter/test_mdot.html new file mode 100644 index 0000000..62260bf --- /dev/null +++ b/tester/authored/Counter/test_mdot.html @@ -0,0 +1,92 @@ + + + + + Comprehensive RT⋅ Namespace Test + + + + + +

Hello!

+ + Chapter 1: The Setup + + Chapter 2: The Execution + + + diff --git a/tester/authored/Counter/test_period.html b/tester/authored/Counter/test_period.html new file mode 100644 index 0000000..47a0612 --- /dev/null +++ b/tester/authored/Counter/test_period.html @@ -0,0 +1,92 @@ + + + + + Comprehensive RT. Namespace Test + + + + + +

Hello!

+ + Chapter 1: The Setup + + Chapter 2: The Execution + + + diff --git a/tester/authored/Counter/test_underscore.html b/tester/authored/Counter/test_underscore.html new file mode 100644 index 0000000..4c68e0f --- /dev/null +++ b/tester/authored/Counter/test_underscore.html @@ -0,0 +1,92 @@ + + + + + Comprehensive RT_ Namespace Test + + + + + +

Hello!

+ + Chapter 1: The Setup + + Chapter 2: The Execution + + +