.
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 4 Aug 2026 15:21:16 +0000 (15:21 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 4 Aug 2026 15:21:16 +0000 (15:21 +0000)
developer/authored/Manuscript.copy/Element/chapter.js [deleted file]
developer/authored/Manuscript.copy/Element/section.js [new file with mode: 0644]
developer/authored/Manuscript.copy/Element/title.js
developer/authored/Manuscript.copy/Layout/article_tech_ref.js
tester/authored/TOC/RT-Manuscript_locator.js [new file with mode: 0644]
tester/authored/TOC/test_0.html [new file with mode: 0644]

diff --git a/developer/authored/Manuscript.copy/Element/chapter.js b/developer/authored/Manuscript.copy/Element/chapter.js
deleted file mode 100644 (file)
index 7b3b4ab..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-(function() {
-  if (!window.RT) return;
-
-  const apply_style = function(h1, config) {
-    // Styling can be inherited or explicitly enforced here.
-    // If you want chapters to have a distinct layout footprint, apply it.
-    h1.style.color = config.brand_primary;
-  };
-
-  RT.Element.add(function() {
-    const config = window.RT.layout_config || {};
-    document.querySelectorAll('RT·chapter').forEach((el) => {
-      const brk = document.createElement('RT·page-break');
-      const h1 = document.createElement('h1');
-      h1.innerHTML = el.innerHTML;
-      if (el.className) h1.className = el.className;
-      h1.classList.add('RT·chapter');
-
-      Array.from(el.attributes).forEach((attr) => {
-        if (attr.name !== 'class') h1.setAttribute(attr.name, attr.value);
-      });
-
-      apply_style(h1, config);
-      el.parentNode.insertBefore(brk, el);
-      el.replaceWith(h1);
-    });
-  });
-})();
diff --git a/developer/authored/Manuscript.copy/Element/section.js b/developer/authored/Manuscript.copy/Element/section.js
new file mode 100644 (file)
index 0000000..cb156fc
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+  Element/section.js
+  Processes <RT·section> tags.
+  Extracts <RT·name> payloads, manages outline numbering, and injects the formatted title.
+*/
+
+(function() {
+
+  if (!window.RT) return;
+
+  const apply_style = function(title_node ,depth ,config) {
+    // Top-level sections start large; scale down based on nesting depth
+    const base_size = 2.25;
+    const size = Math.max(1.1 ,base_size - (depth * 0.35));
+
+    title_node.style.fontSize = size + 'em';
+    title_node.style.fontWeight = '600';
+    title_node.style.color = config.brand_primary || '#000';
+    title_node.style.marginTop = depth === 0 ? '3rem' : '2rem';
+    title_node.style.marginBottom = '1rem';
+    title_node.style.lineHeight = '1.2';
+    
+    if(depth === 0) {
+      title_node.style.borderBottom = '1px solid ' + (config.border_faint || '#ccc');
+      title_node.style.paddingBottom = '0.5rem';
+    }
+  };
+
+  RT.Element.add(function() {
+    const debug = window.RT.Debug || { log: function(){} };
+    if (debug.log) debug.log('section' ,'Processing scoped sections');
+
+    const config = window.RT.layout_config || {};
+    const section_seq = document.querySelectorAll('RT·section, rt·section');
+
+    if (section_seq.length === 0) return;
+
+    const article = document.querySelector('RT·article, rt·article, RT·memo, rt·memo');
+    if (article && !document.querySelector('rt·counter·make[counter="RT_section"]')) {
+      const make = document.createElement('rt·counter·make');
+      make.setAttribute('counter' ,'RT_section');
+      make.setAttribute('style' ,'outline');
+      make.setAttribute('mode' ,'scoped');
+      make.setAttribute('on-first-step' ,'0');
+      article.insertBefore(make ,article.firstChild);
+    }
+
+    let section_idx = 0;
+
+    section_seq.forEach(section => {
+      section.style.display = 'block';
+
+      let depth = 0;
+      let curr = section.parentElement;
+      while (curr) {
+        if (curr.tagName && curr.tagName.toLowerCase() === 'rt·section') {
+          depth++;
+        }
+        curr = curr.parentElement;
+      }
+
+      const names = [];
+      const children = Array.from(section.children);
+      children.forEach(child => {
+        if (child.tagName && child.tagName.toLowerCase() === 'rt·name') {
+          names.push(child.innerHTML.trim());
+          child.remove();
+        }
+      });
+
+      const title_text = names.length > 0 ? names.join('<br>') : '•';
+
+      const step = document.createElement('rt·counter·step');
+      step.setAttribute('counter' ,'RT_section');
+
+      const snap_id = 'section_snap_' + section_idx++;
+      const snap = document.createElement('rt·counter·snapshot');
+      snap.setAttribute('counter' ,'RT_section');
+      snap.setAttribute('snapshot' ,snap_id);
+
+      const title_node = document.createElement('div');
+      title_node.className = 'RT·section-title';
+      
+      // Map identifier for TOC routing
+      if (!section.id) section.id = snap_id; 
+
+      const read = document.createElement('rt·counter·read');
+      read.setAttribute('snapshot' ,snap_id);
+      
+      const title_content = document.createElement('span');
+      title_content.style.marginLeft = '1rem';
+      title_content.innerHTML = title_text;
+
+      title_node.appendChild(read);
+      title_node.appendChild(title_content);
+
+      apply_style(title_node ,depth ,config);
+
+      section.insertBefore(title_node ,section.firstChild);
+      section.insertBefore(snap ,section.firstChild);
+      section.insertBefore(step ,section.firstChild);
+    });
+  });
+
+})();
index 23afa23..c95ef75 100644 (file)
 /*
-  Element/title.js
-  Processes <RT·title> tags and isolates internal styling logic.
+  Element/TOC.js
+  Processes <RT·TOC> tags.
+  Iterates nested <RT·section> boundaries, evaluates tree depth, 
+  and duplicates the title payload for automated navigation.
 */
 
-(function(){
-
-  if(!window.RT) return;
-
-  const apply_style = function(container ,h1 ,meta ,copy_div ,config){
-    container.style.textAlign = 'center';
-    container.style.marginBottom = '3rem';
-    container.style.marginTop = '2rem';
-    container.style.borderBottom = '1px solid ' + config.border_default;
-    container.style.paddingBottom = '1.5rem';
-
-    h1.style.margin = '0 0 0.8rem 0';
-    h1.style.border = 'none';
-    h1.style.padding = '0';
-    h1.style.color = config.brand_primary;
-    h1.style.fontSize = '2.5em';
-    h1.style.lineHeight = '1.1';
-    h1.style.letterSpacing = '-0.03em';
-
-    if(meta){
-      meta.style.color = config.content_muted;
-      meta.style.fontStyle = 'italic';
-      meta.style.fontSize = '1.1em';
-      meta.style.fontFamily = '"Georgia", "Times New Roman", serif';
-    }
-
-    if(copy_div){
-      copy_div.style.color = config.content_muted;
-      copy_div.style.fontSize = '0.9em';
-      copy_div.style.marginTop = '0.5rem';
-    }
+(function() {
+
+  if (!window.RT) return;
+
+  const apply_style = function(a ,config) {
+    a.style.textDecoration = 'none';
+    a.style.color = 'inherit';
+    a.style.display = 'block';
+
+    a.onmouseover = () => a.style.color = config.brand_primary || '#000';
+    a.onmouseout  = () => a.style.color = 'inherit';
   };
 
-  RT.Element.add(function(){
-    const config = window.RT.layout_config || {};
-    const nodes = document.querySelectorAll('rt·title, RT·title');
+  RT.Element.add( function() {
+    const debug = window.RT.Debug || { log: function(){} };
+    if (debug.log) debug.log('TOC' ,'Generating Table of Contents from nested sections');
     
-    for(let i = 0; i < nodes.length; i++){
-      const el = nodes[i];
-      const title = el.getAttribute('title') || 'Untitled Document';
-      const author = el.getAttribute('author');
-      const date = el.getAttribute('date');
-      const copyright = el.getAttribute('copyright');
-
-      const container = document.createElement('div');
-      const h1 = document.createElement('h1');
-      h1.textContent = title;
-      container.appendChild(h1);
-
-      let meta = null;
-      if(author || date){
-        meta = document.createElement('div');
-        const parts = [];
-        if(author) parts.push(`<span style="font-weight:600; color:${config.brand_secondary}">${author}</span>`);
-        if(date) parts.push(date);
-        meta.innerHTML = parts.join(' &nbsp;&mdash;&nbsp; ');
-        container.appendChild(meta);
-      }
+    const config = window.RT.layout_config || {};
+    const TOC_seq = document.querySelectorAll('rt·toc, RT·TOC');
+
+    TOC_seq.forEach( (container ,TOC_index) => {
+      container.style.display = 'block';
 
-      let copy_div = null;
-      if(copyright){
-        copy_div = document.createElement('div');
-        copy_div.innerHTML = `&copy; ${copyright}`; 
-        container.appendChild(copy_div);
+      const attr_val = container.getAttribute('level');
+      let start_level = 1;
+      let end_level = 6; 
+      
+      if (attr_val) {
+        const rangeMatch = attr_val.match(/^(\d)-(\d)$/);
+        if (rangeMatch) {
+          start_level = parseInt(rangeMatch[1]);
+          end_level   = parseInt(rangeMatch[2]);
+        } else {
+          const single = parseInt(attr_val);
+          if (!isNaN(single)) {
+            start_level = single;
+            end_level   = single;
+          } 
+        }
       }
 
-      apply_style(container ,h1 ,meta ,copy_div ,config);
-      el.replaceWith(container);
-    }
+      const sections = [];
+      const all_sections = document.querySelectorAll('rt·section, RT·section');
+      
+      all_sections.forEach(section => {
+        let depth = 0;
+        let curr = section.parentElement;
+        
+        while (curr) {
+          if (curr.tagName && curr.tagName.toLowerCase() === 'rt·section') {
+            depth++;
+          }
+          curr = curr.parentElement;
+        }
+        
+        const level = depth + 1;
+        if (level >= start_level && level <= end_level) {
+          let title_node = null;
+          for (let i = 0; i < section.children.length; i++) {
+             if (section.children[i].className === 'RT·section-title') {
+                 title_node = section.children[i];
+                 break;
+             }
+          }
+          
+          if (title_node) {
+            sections.push({ 
+               id: section.id
+               ,level: level
+               ,html: title_node.innerHTML 
+            });
+          }
+        }
+      });
+
+      container.innerHTML = '';
+      const title = document.createElement('div');
+      title.className = 'RT·TOC-title';
+      title.textContent = start_level === 1 ? 'Table of Contents' : 'Section Contents';
+      title.style.textAlign = 'center';
+      title.style.fontWeight = '600';
+      title.style.fontSize = '1.5em';
+      title.style.marginBottom = '1.5rem';
+      title.style.color = config.brand_primary || '#000';
+      container.appendChild(title);
+
+      if (sections.length === 0) return; 
+
+      const topList = document.createElement('ul');
+      topList.style.listStyle = 'none';
+      topList.style.paddingLeft = '0';
+      topList.style.marginBottom = '0';
+      container.appendChild(topList);
+
+      const listStack = [topList];
+
+      for (const item of sections) {
+        const depth = item.level - start_level;   
+
+        while (listStack.length - 1 > depth) {
+          listStack.pop();
+        }
+
+        while (listStack.length - 1 < depth) {
+          const parentList = listStack[listStack.length - 1];
+          const lastLi = parentList.lastElementChild;
+
+          if (lastLi) {
+            const subList = document.createElement('ul');
+            subList.style.listStyle = 'none';
+            subList.style.paddingLeft = '1.5rem';
+            subList.style.marginBottom = '0';
+            lastLi.appendChild(subList);
+            listStack.push(subList);
+          } else {
+            break;
+          }
+        }
+
+        const li = document.createElement('li');
+        li.style.marginBottom = '0';
+        li.style.marginTop = depth === 0 ? '1.25rem' : '0.25rem';
+
+        const a = document.createElement('a');
+        a.href = `#${item.id}`;
+        a.innerHTML = item.html; 
+        
+        apply_style(a ,config);
+
+        li.appendChild(a);
+        listStack[listStack.length - 1].appendChild(li);
+      }
+    });
   });
 
 })();
index 8efc845..e62388a 100644 (file)
@@ -10,7 +10,7 @@
   window.RT.layout_config = {};
 
   const required_elements = [
-    'chapter'
+    'section'
     ,'code'
     ,'endnote'
     ,'grid'
diff --git a/tester/authored/TOC/RT-Manuscript_locator.js b/tester/authored/TOC/RT-Manuscript_locator.js
new file mode 100644 (file)
index 0000000..4a1b936
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  direct.js
+
+
+  We have four scenarios
+
+  immediate - used in the RT-style distribution itself (authored, consummer, staged)
+  direct - used in the RT-style project itself, but not in the distribution
+  indirect - the version all Harmony projects use
+  URL_only - always pulls style through a URL, a webserver must be present
+  
+*/
+
+window.RT = window.RT || {};
+
+(function() {
+  const project_name = "RT-Style"; 
+  const path = window.location.pathname;
+  const project_root_index = path.indexOf('/' + project_name + '/');
+  
+  if (project_root_index !== -1) {
+    // substring(0, x) excludes the trailing slash. We must prepend it to the payload.
+    const absolute_project_root = path.substring(0, project_root_index + project_name.length + 1);
+    window.RT.dirpr_library = absolute_project_root + "/consumer/Manuscript";
+  } else {
+    // Fallback for when served via local Python HTTP daemon from the project root
+    window.RT.dirpr_library = "../consumer/made/Manuscript";
+  }
+  
+  document.write(
+      '<script src="'
+      + window.RT.dirpr_library
+      + '/Core/RT-Manuscript_make.js"'
+      + '><\/script>'
+  );
+
+})();
diff --git a/tester/authored/TOC/test_0.html b/tester/authored/TOC/test_0.html
new file mode 100644 (file)
index 0000000..c2673a3
--- /dev/null
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8">
+    <title>Test 0: Table of Contents</title>
+    <!-- Adjust the locator path relative to the specific tester/authored subdirectory -->
+    <script src="RT-Manuscript_locator.js"></script>
+    <script>
+      window.RT.theme_preference('inverse_wheat');
+      window.RT.load('Layout/paginate');
+      window.RT.load('Layout/article_tech_ref');
+      window.RT.load('Element/theme_selector');
+    </script>
+  </head>
+  <body>
+    <RT·theme-selector></RT·theme-selector>
+    <RT·article>
+      <RT·title 
+        title="TOC Execution and Section Scoping" 
+        author="Thomas Walker Lynch" 
+        date="2026-08-04 14:57Z">
+      </RT·title>
+
+      <RT·TOC level="1-3"></RT·TOC>
+
+      <RT·section>
+        <RT·name>System Architecture</RT·name>
+        <p>This evaluates the primary execution scope and top-level numbering sequence.</p>
+
+        <RT·section>
+          <RT·name>Memory Hierarchy</RT·name>
+          <p>First nested scope. The state machine must append the depth index.</p>
+          
+          <RT·section>
+            <RT·name>L1 Cache Mechanics</RT·name>
+            <p>Second nested scope. Evaluates terminal TOC depth bounds if configured for level 1-2.</p>
+          </RT·section>
+          
+          <RT·section>
+            <RT·name>L2 Shared Resources</RT·name>
+            <p>Sibling to the L1 scope. Validates sequential incrementing at identical depth.</p>
+          </RT·section>
+        </RT·section>
+        
+        <RT·section>
+          <RT·name>Out-of-Order Execution</RT·name>
+          <p>Returns to the first nested depth to validate boundary exit and state popping.</p>
+        </RT·section>
+      </RT·section>
+
+      <RT·section>
+        <RT·name>Pipeline Mechanics</RT·name>
+        <p>Second primary execution scope. Validates milestone incrementing across the outer boundary.</p>
+        
+        <RT·section>
+          <RT·name>Branch Prediction</RT·name>
+          <p>Nested evaluation.</p>
+          
+          <RT·section>
+            <RT·name>Speculative States</RT·name>
+            <p>Deep nested evaluation.</p>
+          </RT·section>
+        </RT·section>
+      </RT·section>
+
+    </RT·article>
+  </body>
+</html>