// 2. Establish the Debug System
-window.RT.debug = {
+window.RT.Debug = {
active_tokens: new Set([
'scroll'
]),
};
// 3. Establish the Utilities
-window.RT.utility = {
+window.RT.Utility = {
- string: {
+ String: {
to_roman: function(num) {
if (num < 1) return num.toString();
const lookup = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1};
}
},
- dom: {
+ Dom: {
measure_outer_height: function(el) {
const wasInDOM = el.parentNode !== null;
if (!wasInDOM) document.body.appendChild(el);
}
},
- font: {
+ Font: {
measure_ink_ratio: function(target_font, ref_font = null) {
- const debug = window.RT.debug;
+ const debug = window.RT.Debug;
debug.log('layout', `Measuring ink ratio for ${target_font}`);
const canvas = document.createElement('canvas');
}
},
- color: {
+ Color: {
extract_l: function(color_string) {
const str = String(color_string).trim();
window.RT.Module = window.RT.Module || new Set();
(function(){
- const debug = window.RT.debug || { log: function(){} };
+ const debug = window.RT.Debug || { log: function(){} };
let target_y = 0;
let is_reload = false;
function execute_pagination_and_scroll(){
debug.log('scroll' ,`Pagination layout starting.`);
if(window.RT.paginate_by_element) window.RT.paginate_by_element();
- if(window.RT.page) window.RT.page();
let final_target = target_y;
let use_hash = false;
function process_elements_and_layout() {
debug.log('lifecycle', 'Processing registered elements.');
- if (window.RT.theme) {
- window.RT.theme();
- }
-
if (window.RT.Element && Array.isArray(window.RT.Element)) {
while (window.RT.Element.length > 0) {
const element_fn = window.RT.Element.shift();
window.RT.theme_library = window.RT.theme_library || {};
window.RT.theme = (function() {
+
const dictionary = {
meta: { is_dark: false, name: "" },
surface: { 0: "", 1: "", 2: "", 3: "", input: "", code: "", select: "" },
border: { faint: "", regular: "", strong: "" },
state: { success: "", warning: "", error: "", info: "" },
syntax: { keyword: "", string: "", func: "", comment: "" },
- page: { width: "", min_height: "", padding: "", margin: "", bg_color: "", border_color: "", text_color: "", shadow: "" }
+ page: { width: "", min_height: "", padding: "", margin: "", bg_color: "", border_color: "", text_color: "", shadow: "" },
};
function resolve_path(path_array) {
}
function apply_and_validate_theme(new_theme, fallback_color) {
- const debug = window.RT.debug || { error: function(){} };
+ const debug = window.RT.Debug || { error: function(){} };
// Pass 1: Walk the structure of the active dictionary
function walk_current(curr, source, path) {
const fallback = args[1] || "#FF00FF";
if (!window.RT.theme_library.hasOwnProperty(theme_name)) {
- window.RT.debug.error('theme', `Load aborted: Theme '${theme_name}' is not in the theme_library.`);
+ window.RT.Debug.error('theme', `Load aborted: Theme '${theme_name}' is not in the theme_library.`);
return false;
}
return true;
}
- window.RT.debug.error('theme', 'Invalid command passed to theme dictionary: ' + command);
+ window.RT.Debug.error('theme', 'Invalid command passed to theme dictionary: ' + command);
};
})();
/*
immediate.js
- We have four scenarios
+ There are 4 variations for RT-Style-locator.js:
- 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
+ URL_only - used by websites
+ indirect - used by Harmony projects, except for RT-style
+ immediate - used by RT-style in the distribution (authored, consummer, staged)
+ direct - used by RT-style project outside of the distribution, e.g. the main document directory
*/
window.RT = window.RT || {};
(function() {
window.RT.dirpr_library = "..";
document.write('<script src="' + window.RT.dirpr_library + '/Core/RT-Style_make.js"><\/script>');
-
- // 2. Inject a secondary script block for the core dependencies
- document.write(
- '<script>' +
- 'window.RT.load("Element/theme_selector");' +
- '<\/script>'
- );
})();
window.RT = window.RT || {};
window.RT.TOC = function(){
- const debug = window.RT.debug || { log: function(){} };
+ const debug = window.RT.Debug || { log: function(){} };
const TOC_seq = document.querySelectorAll('rt·toc');
TOC_seq.forEach( (container ,TOC_index) => {
window.RT = window.RT || {};
window.RT.chapter = function(){
- const debug = window.RT.debug || { log: function(){} };
+ const debug = window.RT.Debug || { log: function(){} };
document.querySelectorAll('RT·chapter').forEach( (el ,index) => {
if(debug.log) debug.log('chapter' ,`Processing chapter ${index + 1}`);
*/
function code() {
const RT = window.RT;
- const U = RT.utility;
- const debug = RT.debug;
+ const U = RT.Utility;
+ const debug = RT.Debug;
debug.log('code', 'Starting render cycle.');
- const metrics = U.measure_ink_ratio('monospace');
+ const metrics = U.Font.measure_ink_ratio('monospace');
document.querySelectorAll('rt·code').forEach((el) => {
el.style.fontFamily = 'monospace';
const computed = window.getComputedStyle(el);
const accent = computed.getPropertyValue('--RT·accent').trim() || 'gold';
- const is_block = U.is_block_content(el);
+ const is_block = U.Dom.is_block_content(el);
const parentColor = computed.color;
- const is_text_light = U.is_color_light(parentColor);
+ const is_text_light = U.Color.is_light(parentColor);
const alpha = is_block ? 0.08 : 0.15;
const overlay = is_text_light ? `rgba(255,255,255,${alpha})` : `rgba(0,0,0,${alpha})`;
window.RT.constraint = function(){
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 ${window.RT.theme('read', 'state', 'warning')}`;
+ el.style.backgroundColor = window.RT.theme('read', 'surface', '1');
el.style.padding = '1rem';
el.style.margin = '1.5rem 0';
- el.style.color = 'var(--RT·content-main)';
+ el.style.color = window.RT.theme('read', 'content', 'main');
});
};
window.RT.crossref = function(){
document.querySelectorAll('rt·crossref').forEach( (el) => {
- el.style.color = 'var(--RT·brand-link)';
+ el.style.color = window.RT.theme('read', 'brand', 'link');
el.style.textDecoration = 'underline';
el.style.cursor = 'pointer';
el.style.fontWeight = '500';
-
- // Note: To make this fully context-aware across soft limits,
- // this module will eventually need to hook into the page
- // registry built by paginate_by_element.js.
});
};
+
cite.innerHTML = `<a href="#note-${refNum}" id="cite-${refNum}">[${refNum}]</a>`;
cite.style.cursor = 'pointer';
- cite.style.color = 'var(--RT·brand-link)';
+ cite.style.color = window.RT.theme('read', 'brand', 'link');
cite.style.textDecoration = 'none';
// Append the corresponding entry into the endnotes list
// 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 ${window.RT.theme('read', 'surface', '3')}`;
endnoteContainer.style.paddingTop = '1rem';
};
window.RT.term = function() {
const RT = window.RT;
- const debug = RT.debug || {
+ const debug = RT.Debug || {
log: function() {}
,warn: function() {}
,error: function() {}
// Track seen terms so only the first occurrence is decorated
const seen_terms_dpa = new Set();
+ // Inside the apply_style function
const apply_style = (el, is_neologism_b) => {
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)';
- el.style.paddingRight = '0.1em'; // Compensation for italic slant
+ ? window.RT.theme('read', 'brand', 'secondary')
+ : window.RT.theme('read', 'brand', 'primary');
+ el.style.paddingRight = '0.1em';
el.style.display = 'inline';
};
window.RT = window.RT || {};
window.RT.title = function() {
- const debug = window.RT.debug || { log: function(){} };
+ const debug = window.RT.Debug || { log: function(){} };
document.querySelectorAll('rt·title').forEach(el => {
const title = el.getAttribute('title') || 'Untitled Document';
if (typeof RT[name] === 'function') {
RT.Element.push(RT[name]);
} else {
- RT.debug.warn('layout', 'Required element function missing: RT.' + name);
+ RT.Debug.warn('layout', 'Required element function missing: RT.' + name);
}
});
}
+++ /dev/null
-/*
- Page Layout: Fixed Glow
- Standard: Theme 1.0
- Description: A variable-height container with a glowing border effect that matches the active theme.
-*/
-(function(){
- const RT = window.RT = window.RT || {};
-
- RT.page = function() {
- RT.config = RT.config || {};
-
- // Default Configuration
- const defaults = {
- width: "100%"
- ,min_height: "15rem" // Replaces fixed height
- ,padding: "3rem"
- ,margin: "4rem auto"
-
- ,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))"
- };
-
- RT.config.page = Object.assign({}, defaults, RT.config.page || {});
-
- const conf = RT.config.page;
- const style_id = 'RT·page-fixed-glow';
-
- if (!document.getElementById(style_id)) {
- const style_el = document.createElement('style');
- style_el.id = style_id;
-
- style_el.textContent = `
- /* Reset page counter on the article container */
- RT·article {
- counter-reset: RT·page-counter;
- }
-
- RT·page {
- display: block;
- position: relative;
- box-sizing: border-box;
- overflow: hidden;
-
- /* Dimensions */
- width: ${conf.width};
- min-height: ${conf.min_height};
- margin: ${conf.margin};
- padding: ${conf.padding};
-
- /* Theming */
- background-color: ${conf.bg_color};
- border: 1px solid ${conf.border_color};
-
- /* The "Glow" Effect */
- filter: ${conf.shadow};
-
- /* Counter Increment */
- counter-increment: RT·page-counter;
- }
-
- /* Page Numbering */
- RT·page::after {
- content: "Page " counter(RT·page-counter);
- position: absolute;
- bottom: 1.5rem;
- right: 3rem;
-
- font-family: "Noto Sans", sans-serif;
- font-size: 0.9rem;
- font-weight: bold;
-
- color: ${conf.text_color};
- opacity: 0.8;
- pointer-events: none;
- }
- `;
- document.head.appendChild(style_el);
- }
- };
-})();
window.RT.paginate_by_element = function () {
const RT = window.RT;
- const debug = RT.debug || { log: function(){}, error: function(){} };
+ const debug = RT.Debug || { log: function(){}, error: function(){} };
const page_conf = (RT.config && RT.config.page) ? RT.config.page : {};
const page_height_limit = page_conf.height_limit || 1000;
func: "oklch(0.45 0.12 35)",
comment: "oklch(0.60 0.02 90)"
},
+ page: {
+ width: "6.5in",
+ min_height: "9in",
+ padding: "0.5in 1in",
+ margin: "20px auto",
+ bg_color: "oklch(0.95 0.02 90)",
+ border_color: "oklch(0.85 0.02 90)",
+ text_color: "oklch(0.20 0.02 25)",
+ shadow: "0 4px 15px rgba(0,0,0,0.1)"
+ },
custom_css: `
rt-article p, rt-article li { text-shadow: 0px 0px 0.5px rgba(0,0,0, 0.2); }
.MathJax, .MathJax_Display, .mjx-chtml {
func: "oklch(0.80 0.12 85)",
comment: "oklch(0.55 0.02 90)"
},
+ page: {
+ width: "6.5in",
+ min_height: "9in",
+ padding: "0.5in 1in",
+ margin: "20px auto",
+ bg_color: "oklch(0.95 0.02 90)",
+ border_color: "oklch(0.85 0.02 90)",
+ text_color: "oklch(0.20 0.02 25)",
+ shadow: "0 4px 15px rgba(0,0,0,0.1)"
+ },
custom_css: `
img.rt-diagram { filter: invert(1) hue-rotate(180deg); }
`
func: "oklch(0.50 0.10 320)",
comment: "oklch(0.65 0.02 80)"
},
- custom_css: ``
+ page: {
+ width: "6.5in",
+ min_height: "9in",
+ padding: "0.5in 1in",
+ margin: "20px auto",
+ bg_color: "oklch(0.95 0.02 90)",
+ border_color: "oklch(0.85 0.02 90)",
+ text_color: "oklch(0.20 0.02 25)",
+ shadow: "0 4px 15px rgba(0,0,0,0.1)"
+ },
};