Render the paper from the TeX source
Browse filesFiles changed (2)
- index.html+89-52
- tex2html.jsAdded+870
10 unmodified lines111213141516171819206 unmodified lines27282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919210 unmodified lines<script>window.MathJax = {tex: { inlineMath: [['\\(', '\\)']], displayMath: [['\\[', '\\]']] },chtml: { matchFontHeight: false }};</script><script defer src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml.js"></script><style>:root {--bg: #fbfaf7; --surface: #ffffff; --text: #1d1c1a; --muted: #5f5b55;6 unmodified lines* { box-sizing: border-box; }html, body { margin: 0; background: var(--bg); color: var(--text); }body { font: 18px/1.65 "Source Serif 4", Georgia, serif; }.wrap { max-width: 980px; margin: 0 auto; padding: 56px 16px 80px; }.eyebrow, .btn, .meta, footer, .status, .section-label, th { font-family: Inter, system-ui, sans-serif; }.eyebrow { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 14px; }h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; font-weight: 600; margin: 0 0 12px; letter-spacing: -.01em; }.subtitle { font-size: clamp(18px, 2.6vw, 22px); color: var(--muted); margin: 0 0 22px; font-style: italic; }.meta { font-size: 15px; color: var(--muted); margin: 0 0 28px; }.meta strong { color: var(--text); font-weight: 500; }.meta a { color: var(--accent); }.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }.btn { display: inline-flex; align-items: center; padding: 10px 16px; border-radius: 8px; font-size: 15px; font-weight: 500; text-decoration: none; border: 1px solid var(--rule); color: var(--text); background: var(--surface); }.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }.btn:hover { border-color: var(--accent); }.section-label { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 12px; }article .abstract { background: var(--accent-soft); border-radius: 10px; padding: 4px 24px 8px; margin-bottom: 28px; }article .abstract h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-family: Inter, system-ui, sans-serif; margin: 20px 0 10px; }article p { margin: 0 0 1em; }.pdf-frame { width: 100%; height: 85vh; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }pre.cite { font: 13.5px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--accent-soft); padding: 16px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 0; }.cite-block { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule); }footer { margin-top: 40px; font-size: 13.5px; color: var(--muted); }</style></head><body><main class="wrap"><p class="eyebrow">Encryptid Systems · Preprint</p><h1>Transfractal Dynamics</h1><p class="subtitle">Logarithmic-Quotient Operators, Phase Geometry, Julia Sets and Discrete Exterior Calculus</p><p class="meta"><strong>Gregory Disney-Leugers</strong> (Encryptid Systems) · 10 November 2026 · Companion preprint: <a href="https://huggingface.co/spaces/EncryptidSystems/Multi-Radix-Geometry">Multi-Radix Geometry</a></p><div class="actions"><a class="btn primary" href="Transfractal_Dynamics.pdf" download>Download PDF</a><a class="btn" href="Transfractal_Dynamics.tex" download>LaTeX source</a></div><article><div class="abstract"><h2>Abstract</h2><p>We study the iteration of logarithmic-quotient operators \(T_\sigma=(\Log(T_1+\sigma)+2\pi ik_1)/(\Log(T_2+\sigma)+2\pi ik_2)\), where \(T_1,T_2\) are built from elementary and special functions by arithmetic and composition and \(\sigma\in\mathbb{C}\) is a bias parameter. These maps are holomorphic off a closed set of measure zero that contains cuts, logarithmic singularities and poles, and they are not meromorphic. The paper has four parts.</p><p>The first part develops the dynamics in tensor form on the seed plane: the Fatou and Julia sets, Denjoy–Wolff on simply connected invariant components, phase locking at attracting cycles with rate exactly the modulus of the multiplier, the phase-curvature identity \(|\nabla\arg z_n|=|z_n'|/|z_n|\) with the flat pull-back cylinder metric and its cone points and cylindrical ends, the collapse layer, phase currents, the logarithmic divergence \(\pi\sum m_j^2\) of the phase energy, closed-form bias targeting of fixed points, harmonic dependence of the attracting phase on \(\sigma\), the Koenigs flow, a damped sine-Gordon continuum model, a four-class taxonomy, and the reading of the iteration as a weight-tied network with conformal back-propagation and an exact Koenigs readout.</p><p>The second part treats the Julia set of the Lambert–sine operator L-A. It contains the ray \((-\infty,-1/e]\) and the point \(0\), it is perfect, and it carries an infinite hierarchy of conformal copies of its germ at \(0\). At the constants \(c=e^{i\pi e}\), \(s=-\sin 1\) and six bias values we prove attracting cycles in explicit discs, unbounded basins, invariant Cantor repellers of dimension greater than \(1/2\), infinitely many arcs ending at \(0\), and the equality of the Julia set with the basin boundary in an explicit far field, where the Julia set is a countable union of analytic arcs. Every part of the Julia set of positive area or of dimension greater than one lies in an explicit strip of width \(O(\ln\ln|z|)\).</p><p>The third part shows that the operator is not meromorphic off any countable set and is of linear, not exponential, growth at its essential singularity.</p><p>The fourth part proves that pull-back along the iteration commutes with the exterior derivative and intertwines the de Rham map with transport of chains, that the discrete Whitney pull-back is a cochain map, that the phase pass counts zeros exactly, and that passes decay geometrically on basins; three negative theorems show that pull-back does not preserve Whitney spaces, that discrete pull-backs do not compose, and that pull-back does not commute with the weak exterior derivative across a cut.</p></div><iframe class="pdf-frame" src="Transfractal_Dynamics.pdf" title="Transfractal Dynamics PDF"></iframe></article><div class="cite-block"><p class="section-label">Cite</p><pre class="cite">@misc{disneyleugers2026transfractal,title = {Transfractal Dynamics: Logarithmic-Quotient Operators,Phase Geometry, Julia Sets and Discrete Exterior Calculus},author = {Disney-Leugers, Gregory},year = {2026},month = nov,note = {Encryptid Systems preprint},howpublished = {\url{https://huggingface.co/spaces/EncryptidSystems/Transfractal-Dynamics}}}</pre></div><footer>© 2026 Gregory Disney-Leugers, Encryptid Systems. The PDF is the typeset paper.</footer></main></body></html>10 unmodified lines1112131415161718192021226 unmodified lines293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812910 unmodified lines<script>window.MathJax = {tex: { inlineMath: [['\\(', '\\)']], displayMath: [['\\[', '\\]']] },chtml: { matchFontHeight: false },startup: { typeset: false }};</script><script defer src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml.js"></script><script src="tex2html.js"></script><style>:root {--bg: #fbfaf7; --surface: #ffffff; --text: #1d1c1a; --muted: #5f5b55;6 unmodified lines* { box-sizing: border-box; }html, body { margin: 0; background: var(--bg); color: var(--text); }body { font: 18px/1.65 "Source Serif 4", Georgia, serif; }.bar, .btn, .meta, footer, .status, .toc-label, .sec-no, .marker, .eq-no, .thm-head, .proof-head, figcaption, dt {font-family: Inter, system-ui, sans-serif;}.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; max-width: 860px; margin: 0 auto; padding: 22px 20px 0; }.btn { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; text-decoration: none; border: 1px solid var(--rule); color: var(--text); background: var(--surface); }.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }main { max-width: 860px; margin: 0 auto; padding: 12px 20px 72px; }.paper-title h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; font-weight: 600; margin: 18px 0 8px; }.by, .date { margin: 0; color: var(--muted); font-size: 16px; }.abstract { background: var(--accent-soft); border-radius: 10px; padding: 4px 22px 8px; margin: 28px 0; }.abstract h2, .toc-label { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }h2 { font-size: 1.45rem; line-height: 1.25; margin: 2.2em 0 .6em; }h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }p { margin: 0 0 .9em; }a { color: var(--accent); }.sec-no { color: var(--muted); font-weight: 600; font-size: .85em; }.toc { margin: 28px 0 36px; }.toc > ol { margin: 0; padding-left: 1.2em; }.toc ol ol { margin: .15em 0 .4em; }.toc a { color: var(--text); text-decoration: none; }.toc a:hover { color: var(--accent); }.thm { background: var(--thm); border-radius: 8px; padding: 10px 16px 4px; margin: 1em 0; }.thm.plain { font-style: italic; }.thm.plain .thm-head, .thm .note, .thm .li-body .thm { font-style: normal; }.thm-head { font-style: normal; }.thm.plain em { font-style: normal; }.proof { margin: .4em 0 1.2em; }.qed { float: right; font-style: normal; }ol.enum, ul { margin: .3em 0 .6em; padding: 0; list-style: none; }ol.enum > li, ul > li { display: flex; gap: .55em; margin: .15em 0; }.marker { min-width: 1.8em; font-style: normal; }.li-body { flex: 1; min-width: 0; }.li-body > p { margin: 0 0 .35em; }dl.desc { margin: .4em 0 .8em; }dl.desc dt { font-weight: 600; margin-top: .45em; }.eq { display: flex; align-items: center; gap: 12px; margin: .8em 0; overflow-x: auto; }.eq-body { flex: 1; }.eq-no { color: var(--muted); font-size: .9rem; }.table-wrap { overflow-x: auto; margin: 1em 0; }table { border-collapse: collapse; width: 100%; font-size: .78rem; line-height: 1.35; }.footnotesize table, .table-wrap.footnotesize table { font-size: .68rem; }td { padding: 3px 8px; vertical-align: top; }tr.rule-before td { border-top: 1px solid var(--text); }tr.rule-after td { border-bottom: 1px solid var(--text); }figure { margin: 1.4em 0; }.figs { display: flex; gap: 8px; }.figs img { width: 32%; height: auto; }figcaption { font-size: .92rem; color: var(--muted); margin-top: .4em; }.bib dl { display: grid; grid-template-columns: 3em 1fr; gap: .35em .6em; }.bib dt { color: var(--muted); }.bib dd { margin: 0; }footer { max-width: 860px; margin: 0 auto; padding: 0 20px 48px; color: var(--muted); font-size: 13.5px; }pre.cite { font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--accent-soft); padding: 16px; border-radius: 8px; overflow-x: auto; }mjx-container { overflow-x: auto; overflow-y: hidden; max-width: 100%; }</style></head><body><div class="bar"><a class="btn primary" href="Transfractal_Dynamics.pdf" download>PDF</a><a class="btn" href="Transfractal_Dynamics.tex" download>TeX</a><a class="btn" href="https://huggingface.co/spaces/EncryptidSystems/Multi-Radix-Geometry">Multi-Radix Geometry</a></div><main id="paper"><p class="status">Rendering the paper…</p></main><footer><pre class="cite">@misc{disneyleugers2026transfractal,title = {Transfractal Dynamics},author = {Disney-Leugers, Gregory},year = {2026},month = nov,note = {Encryptid Systems preprint},howpublished = {\url{https://huggingface.co/spaces/EncryptidSystems/Transfractal-Dynamics}}}</pre><p>© 2026 Gregory Disney-Leugers, Encryptid Systems. Rendered in the browser from the LaTeX source.</p></footer><script>(function () {var paper = document.getElementById('paper');function fail(msg) {paper.innerHTML = '<p class="status">' + msg + ' <a href="Transfractal_Dynamics.pdf">Download the PDF</a>.</p>';}fetch('Transfractal_Dynamics.tex').then(function (r) { if (!r.ok) throw new Error(String(r.status)); return r.text(); }).then(function (tex) {var out = window.tex2html(tex);paper.innerHTML = out.html;var ready = function () {return MathJax.startup.promise.then(function () {return MathJax.typesetPromise([paper]);});};if (window.MathJax && MathJax.startup && MathJax.startup.promise) return ready();return new Promise(function (res) { window.addEventListener('load', res); }).then(ready);}).catch(function (e) { console.error(e); fail('The paper could not be rendered.'); });})();</script></body></html>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870// Render the paper TeX in the browser. Math is left for MathJax.(function (root) { 'use strict';
var ESC = { '&': '&', '<': '<', '>': '>', '"': '"' }; function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return ESC[c]; }); }
var MACROS = { C: '\\mathbb{C}', R: '\\mathbb{R}', Z: '\\mathbb{Z}', N: '\\mathbb{N}', Chat: '\\widehat{\\mathbb{C}}', Log: '\\operatorname{Log}', Arg: '\\operatorname{Arg}', Fat: '\\mathcal{F}', Jul: '\\mathcal{J}', Tcl: '\\mathcal{T}', Reg: '\\mathcal{R}', Sing: '\\Sigma', dd: '\\,\\mathrm{d}', Lie: '\\mathcal{L}' };
var THM = { theorem: ['Theorem', 'plain'], proposition: ['Proposition', 'plain'], lemma: ['Lemma', 'plain'], corollary: ['Corollary', 'plain'], definition: ['Definition', 'definition'], example: ['Example', 'definition'], remark: ['Remark', 'remark'] };
function expandMacros(s) { return s.replace(/\\([A-Za-z]+)/g, function (m, name) { return Object.prototype.hasOwnProperty.call(MACROS, name) ? MACROS[name] : m; }); }
function stripComments(s) { var out = ''; for (var i = 0; i < s.length; i++) { if (s[i] === '\\') { out += s[i]; if (i + 1 < s.length) out += s[++i]; continue; } if (s[i] === '%') { while (i < s.length && s[i] !== '\n') i++; out += '\n'; continue; } out += s[i]; } return out; }
function readBrace(s, i) { if (s[i] !== '{') throw new Error('expected { at ' + i + ': ' + JSON.stringify(s.slice(i, i + 60))); var depth = 0; for (var j = i; j < s.length; j++) { if (s[j] === '\\') { j++; continue; } if (s[j] === '{') depth++; else if (s[j] === '}') { depth--; if (depth === 0) return { text: s.slice(i + 1, j), end: j + 1 }; } } throw new Error('unclosed { at ' + i); }
function readBracket(s, i) { if (s[i] !== '[') return null; var depth = 0, brace = 0; for (var j = i; j < s.length; j++) { if (s[j] === '\\') { j++; continue; } if (s[j] === '{') brace++; else if (s[j] === '}') brace--; else if (brace === 0 && s[j] === '[') depth++; else if (brace === 0 && s[j] === ']') { depth--; if (depth === 0) return { text: s.slice(i + 1, j), end: j + 1 }; } } throw new Error('unclosed [ at ' + i); }
function grab(s, name) { var token = '\\' + name + '{'; var i = s.indexOf(token); if (i < 0) return ''; return readBrace(s, i + token.length - 1).text; }
function extractAll(src) { var math = []; var out = ''; var i = 0; function push(info) { var n = math.length; math.push(info); return '\uE000' + n + '\uE001'; } while (i < src.length) { if (src.startsWith('\\begin{equation', i)) { var star = src.startsWith('\\begin{equation*}', i); var open = star ? '\\begin{equation*}' : '\\begin{equation}'; var close = star ? '\\end{equation*}' : '\\end{equation}'; var start = i + open.length; var end = src.indexOf(close, start); if (end < 0) throw new Error('unclosed equation'); var body = src.slice(start, end); var id = null; body = body.replace(/\\label\{([^}]*)\}/, function (_, lab) { id = lab; return ''; }); out += push({ display: true, tex: expandMacros(body.trim()), id: id, numbered: !star }); i = end + close.length; continue; } if (src.startsWith('\\[', i)) { var endD = src.indexOf('\\]', i + 2); if (endD < 0) throw new Error('unclosed \\['); out += push({ display: true, tex: expandMacros(src.slice(i + 2, endD).trim()), id: null, numbered: false }); i = endD + 2; continue; } if (src[i] === '\\') { out += src[i]; if (i + 1 < src.length) out += src[++i]; i++; continue; } if (src[i] === '$') { var j = i + 1; while (j < src.length) { if (src[j] === '\\') { j += 2; continue; } if (src[j] === '$') break; j++; } if (j >= src.length) throw new Error('unclosed $'); out += push({ display: false, tex: expandMacros(src.slice(i + 1, j)), id: null, numbered: false }); i = j + 1; continue; } out += src[i]; i++; } return { text: out, math: math }; }
function findEnd(s, i, name) { var depth = 1; var open = '\\begin{' + name + '}'; var close = '\\end{' + name + '}'; var j = i; while (j < s.length) { if (s.startsWith(open, j)) { depth++; j += open.length; continue; } if (s.startsWith(close, j)) { depth--; if (depth === 0) return { body: s.slice(i, j), end: j + close.length }; j += close.length; continue; } if (s[j] === '\\') { j += 2; continue; } j++; } throw new Error('missing \\end{' + name + '}'); }
function readBegin(s, i) { var m = /^\\begin\{([^}]+)\}/.exec(s.slice(i)); if (!m) throw new Error('bad begin at ' + i); var j = i + m[0].length; var opt = null; if (s[j] === '[') { var b = readBracket(s, j); opt = b.text; j = b.end; } return { name: m[1], opt: opt, next: j }; }
function takeLabel(s) { var m = /^\s*\\label\{([^}]*)\}/.exec(s); if (!m) return { id: null, rest: s }; return { id: m[1], rest: s.slice(m[0].length) }; }
function splitItems(s) { var items = []; var buf = ''; var env = 0; var brace = 0; var started = false; function push() { if (!started) return; var raw = buf; var label = null; var t = raw.replace(/^\s+/, ''); if (t[0] === '[') { var b = readBracket(t, 0); label = b.text; t = t.slice(b.end); } items.push({ label: label, text: t }); buf = ''; } for (var i = 0; i < s.length; i++) { if (s[i] === '\\' && env === 0 && brace === 0 && s.startsWith('\\item', i) && !/[a-zA-Z]/.test(s[i + 5] || '')) { push(); started = true; i += 4; continue; } if (s.startsWith('\\begin{', i)) env++; else if (s.startsWith('\\end{', i)) env--; if (s[i] === '\\') { buf += s[i]; if (i + 1 < s.length) buf += s[++i]; continue; } if (s[i] === '{') brace++; else if (s[i] === '}') brace--; buf += s[i]; } push(); return items; }
function splitRows(s) { var rows = []; var cur = ''; var brace = 0; for (var i = 0; i < s.length; i++) { if (s[i] === '\\' && s[i + 1] === '\\' && brace === 0) { rows.push(cur); cur = ''; i++; continue; } if (s[i] === '\\') { cur += s[i]; if (i + 1 < s.length) cur += s[++i]; continue; } if (s[i] === '{') brace++; else if (s[i] === '}') brace--; cur += s[i]; } if (cur.trim()) rows.push(cur); return rows; }
function splitCells(s) { var cells = []; var cur = ''; var brace = 0; for (var i = 0; i < s.length; i++) { if (s[i] === '&' && brace === 0) { cells.push(cur); cur = ''; continue; } if (s[i] === '\\') { cur += s[i]; if (i + 1 < s.length) cur += s[++i]; continue; } if (s[i] === '{') brace++; else if (s[i] === '}') brace--; cur += s[i]; } cells.push(cur); return cells; }
function parseTabular(body) { var rows = []; splitRows(body).forEach(function (raw) { var rule = false; var t = raw.trim(); if (!t) return; if (t === '\\hline') { if (rows.length) rows[rows.length - 1].ruleAfter = true; else rows.push({ ruleBefore: true, cells: [], ruleAfter: false }); return; } if (t.startsWith('\\hline')) { rule = true; t = t.replace(/^\\hline\s*/, ''); } if (!t) { if (rows.length && rule) rows[rows.length - 1].ruleAfter = true; return; } var cells = splitCells(t).map(function (c) { var m = /^\\multicolumn\{(\d+)\}\{[^}]*\}\{([\s\S]*)\}$/.exec(c.trim()); if (m) return { span: +m[1], text: m[2] }; return { span: 1, text: c.trim() }; }); rows.push({ ruleBefore: rule, ruleAfter: false, cells: cells }); }); return rows; }
function listKind(name, opt) { if (name === 'itemize') return 'bullet'; if (name === 'description') return 'desc'; var spec = ''; if (opt) { var m = /label\s*=\s*([^,\]]+)/.exec(opt); if (m) spec = m[1].trim(); } return spec || 'decimal'; }
function roman(n) { var map = [[100, 'c'], [90, 'xc'], [50, 'l'], [40, 'xl'], [10, 'x'], [9, 'ix'], [5, 'v'], [4, 'iv'], [1, 'i']]; var s = ''; map.forEach(function (pair) { while (n >= pair[0]) { s += pair[1]; n -= pair[0]; } }); return s; }
function formatMarker(spec, n) { if (spec === 'decimal') return n + '.'; if (spec === 'bullet' || spec === 'desc') return ''; return spec .replace(/\\alph\*/g, String.fromCharCode(96 + n)) .replace(/\\Alph\*/g, String.fromCharCode(64 + n)) .replace(/\\roman\*/g, roman(n)) .replace(/\\Roman\*/g, roman(n).toUpperCase()) .replace(/\\arabic\*/g, String(n)); }
function parseContent(s, depth) { var blocks = []; var buf = ''; var i = 0; var pendingSize = ''; function flush() { if (buf.trim()) blocks.push({ type: 'p', text: buf.trim() }); buf = ''; } while (i < s.length) { var start = i; if (s[i] === '\n') { var j = i + 1; while (s[j] === ' ' || s[j] === '\t') j++; if (s[j] === '\n') { flush(); i = j + 1; continue; } } if (s.startsWith('\\begin{', i)) { flush(); var b = readBegin(s, i); var found = findEnd(s, b.next, b.name); blocks.push(makeEnv(b.name, b.opt, found.body, depth, pendingSize)); pendingSize = ''; i = found.end; if (i === start) throw new Error('env did not advance'); continue; } var sec = /^\\(subsubsection|subsection|section|paragraph|maketitle|tableofcontents|clearpage)\b\*?/.exec(s.slice(i)); if (sec) { flush(); var name = sec[1]; var k = i + sec[0].length; if (name === 'maketitle') blocks.push({ type: 'maketitle' }); else if (name === 'tableofcontents') blocks.push({ type: 'toc' }); else if (name === 'clearpage') { /* skip */ } else if (name === 'paragraph') { var title = readBrace(s, k); buf = '\uE010' + title.text + '\uE011 '; k = title.end; } else { var titleS = readBrace(s, k); k = titleS.end; var id = null; var lab = /^\s*\\label\{([^}]*)\}/.exec(s.slice(k)); if (lab) { id = lab[1]; k = k + lab[0].length; } var level = name === 'section' ? 1 : name === 'subsection' ? 2 : 3; blocks.push({ type: 'section', level: level, title: titleS.text, id: id }); } i = k; if (i === start) throw new Error('command did not advance: ' + name); continue; } if (s.startsWith('\\small', i) && !/[a-zA-Z]/.test(s[i + 6] || '')) { pendingSize = 'small'; i += 6; continue; } if (s.startsWith('\\footnotesize', i)) { pendingSize = 'footnotesize'; i += 13; continue; } buf += s[i]; i++; } flush(); return blocks; }
function makeEnv(name, opt, body, depth, size) { if (THM[name]) { var labelled = takeLabel(body); return { type: 'thm', kind: name, opt: opt, id: labelled.id, body: parseContent(labelled.rest, depth) }; } if (name === 'proof') return { type: 'proof', body: parseContent(body, depth) }; if (name === 'abstract') return { type: 'abstract', body: parseContent(body, depth) }; if (name === 'center') return { type: 'center', body: parseContent(body, depth), size: size || '' }; if (name === 'enumerate' || name === 'itemize' || name === 'description') { return { type: 'list', kind: listKind(name, opt), depth: depth + 1, items: splitItems(body).map(function (it) { return { label: it.label, body: parseContent(it.text, depth + 1) }; }) }; } if (name === 'tabular') { var spec = ''; var rest = body; if (rest.trimStart().startsWith('{')) { var lead = rest.length - rest.trimStart().length; var specArg = readBrace(rest.trimStart(), 0); spec = specArg.text; rest = rest.trimStart().slice(specArg.end); if (lead) { /* spec already sliced from trimmed string */ } } return { type: 'table', rows: parseTabular(rest), size: size || '', spec: spec }; } if (name === 'figure') return parseFigure(body); if (name === 'thebibliography') return { type: 'bib', items: parseBib(body) }; throw new Error('unknown environment: ' + name); }
function parseFigure(body) { var imgs = []; var re = /\\includegraphics(?:\[[^\]]*\])?\{([^}]*)\}/g; var m; while ((m = re.exec(body))) imgs.push(m[1]); var cap = ''; var c = /\\caption\{/.exec(body); if (c) cap = readBrace(body, c.index + '\\caption'.length).text; var id = null; var lab = /\\label\{([^}]*)\}/.exec(body); if (lab) id = lab[1]; return { type: 'figure', imgs: imgs, caption: cap, id: id }; }
function parseBib(body) { var parts = body.split(/\\bibitem\{/); var items = []; parts.slice(1).forEach(function (part) { var end = part.indexOf('}'); items.push({ key: part.slice(0, end), text: part.slice(end + 1).trim() }); }); return items; }
function assignMath(s, state) { if (!s) return; var re = /\uE000(\d+)\uE001/g; var m; while ((m = re.exec(s))) { var info = state.math[+m[1]]; if (info && info.display && info.numbered && info.num == null) { info.num = ++state.eq; if (info.id) state.labels[info.id] = String(info.num); } } }
function walk(nodes, state) { nodes.forEach(function (n) { if (n.type === 'section') { if (n.level === 1) { state.sec++; state.sub = 0; state.thm = 0; n.num = String(state.sec); } else if (n.level === 2) { state.sub++; n.num = state.sec + '.' + state.sub; } else n.num = ''; n.anchor = n.id || ('sec-' + (n.num || n.title)); if (n.id) state.labels[n.id] = n.num || n.title; assignMath(n.title, state); } else if (n.type === 'p') assignMath(n.text, state); else if (n.type === 'thm') { state.thm++; n.num = state.sec + '.' + state.thm; if (n.id) state.labels[n.id] = n.num; assignMath(n.opt || '', state); walk(n.body, state); } else if (n.type === 'proof' || n.type === 'abstract' || n.type === 'center') walk(n.body, state); else if (n.type === 'list') n.items.forEach(function (it) { assignMath(it.label || '', state); walk(it.body, state); }); else if (n.type === 'table') n.rows.forEach(function (row) { (row.cells || []).forEach(function (cell) { assignMath(cell.text, state); }); }); else if (n.type === 'figure') { state.fig++; n.num = String(state.fig); if (n.id) state.labels[n.id] = n.num; assignMath(n.caption, state); } else if (n.type === 'bib') n.items.forEach(function (it, idx) { it.num = idx + 1; state.cites[it.key] = it.num; assignMath(it.text, state); }); }); }
function mathSpan(info) { if (!info) return ''; var open = info.display ? '\\[' : '\\('; var close = info.display ? '\\]' : '\\)'; return open + esc(info.tex) + close; }
function inline(s, state) { var out = ''; var i = 0; while (i < s.length) { if (s.charCodeAt(i) === 0xE000) { var j = s.indexOf('\uE001', i); out += mathSpan(state.math[+s.slice(i + 1, j)]); i = j + 1; continue; } if (s.charCodeAt(i) === 0xE010) { var j2 = s.indexOf('\uE011', i); out += '<strong class="runin">' + inline(s.slice(i + 1, j2), state) + '</strong> '; i = j2 + 1; continue; } if (s.startsWith('``', i)) { out += '\u201c'; i += 2; continue; } if (s.startsWith("''", i)) { out += '\u201d'; i += 2; continue; } if (s.startsWith('---', i)) { out += '\u2014'; i += 3; continue; } if (s.startsWith('--', i)) { out += '\u2013'; i += 2; continue; } if (s[i] === '~') { out += '\u00a0'; i++; continue; } if (s[i] === '\\') { var acc = s[i + 1]; if (acc && "'`^\"~".indexOf(acc) >= 0) { var k = i + 2; var ch = ''; if (s[k] === '{') { var g = readBrace(s, k); ch = g.text; k = g.end; } else { ch = s[k] || ''; k++; } var mark = { "'": '\u0301', '`': '\u0300', '^': '\u0302', '"': '\u0308', '~': '\u0303' }[acc]; out += esc(ch).replace(/^(.)/, function (_, c) { return c + mark; }); i = k; continue; } if (s.startsWith('\\c{', i)) { var ced = readBrace(s, i + 2); out += esc(ced.text) + '\u0327'; i = ced.end; continue; } var word = /^\\([a-zA-Z]+)\s*/.exec(s.slice(i)); if (!word) { var n = s[i + 1]; if (n === '\\') out += '<br>'; else if (n === ' ' || n === ',' || n === '/') out += n === ',' ? '\u2009' : (n === ' ' ? ' ' : ''); else if (n === '&') out += '&'; else if (n === '%') out += '%'; else if (n === '#') out += '#'; else if (n === '_') out += '_'; else if (n === '$') out += '$'; else if (n === '{' || n === '}') out += n; else out += esc(n || ''); i += 2; continue; } var cmd = word[1]; var p = i + word[0].length; if (cmd === 'emph' || cmd === 'textit' || cmd === 'textsc') { var a1 = readBrace(s, p); out += '<em>' + inline(a1.text, state) + '</em>'; i = a1.end; continue; } if (cmd === 'textbf' || cmd === 'textup') { var a2 = readBrace(s, p); out += '<strong>' + inline(a2.text, state) + '</strong>'; i = a2.end; continue; } if (cmd === 'texttt') { var a3 = readBrace(s, p); out += '<code>' + inline(a3.text, state) + '</code>'; i = a3.end; continue; } if (cmd === 'ref') { var r = readBrace(s, p); var num = state.labels[r.text]; out += '<a class="ref" href="#' + esc(r.text) + '">' + esc(num || r.text) + '</a>'; i = r.end; continue; } if (cmd === 'eqref') { var e = readBrace(s, p); var en = state.labels[e.text]; out += '(<a class="ref" href="#' + esc(e.text) + '">' + esc(en || e.text) + '</a>)'; i = e.end; continue; } if (cmd === 'cite') { var note = ''; if (s[p] === '[') { var br = readBracket(s, p); note = br.text; p = br.end; } var c = readBrace(s, p); var keys = c.text.split(/\s*,\s*/); var bits = keys.map(function (key) { var cn = state.cites[key]; return '<a class="ref" href="#bib-' + esc(key) + '">' + esc(cn || key) + '</a>'; }); out += '[' + bits.join(', ') + (note ? ', ' + inline(note, state) : '') + ']'; i = c.end; continue; } if (cmd === 'S') { out += '\u00a7'; i = p; continue; } if (cmd === 'label') { var lb = readBrace(s, p); out += '<span id="' + esc(lb.text) + '"></span>'; i = lb.end; continue; } if (cmd === 'qedhere') { out += '<span class="qed">\u220e</span>'; i = p; continue; } if (cmd === 'noindent' || cmd === 'leavevmode' || cmd === 'centering' || cmd === 'small' || cmd === 'footnotesize' || cmd === 'normalsize' || cmd === 'clearpage' || cmd === 'hfill' || cmd === 'qquad' || cmd === 'quad' || cmd === 'hspace' || cmd === 'vspace') { if (cmd === 'hspace' || cmd === 'vspace') { if (s[p] === '{') p = readBrace(s, p).end; } if (cmd === 'quad') out += '\u2003'; if (cmd === 'qquad') out += '\u2003\u2003'; i = p; continue; } if (MACROS[cmd]) { out += '\\(' + esc(MACROS[cmd]) + '\\)'; i = p; continue; } if (s[p] === '{') { var unk = readBrace(s, p); state.unknown[cmd] = (state.unknown[cmd] || 0) + 1; out += inline(unk.text, state); i = unk.end; continue; } state.unknown[cmd] = (state.unknown[cmd] || 0) + 1; i = p; continue; } if (s[i] === '{') { var grp = readBrace(s, i); var inner = grp.text; var font = /^(?:\\(em|it|bf|rm|sc|tt|bfseries|itshape|rmfamily|sffamily))\s*/.exec(inner); if (font) { var rest = inner.slice(font[0].length); var tag = (font[1] === 'bf' || font[1] === 'bfseries') ? 'strong' : 'em'; if (font[1] === 'rm' || font[1] === 'rmfamily' || font[1] === 'upshape') out += inline(rest, state); else out += '<' + tag + '>' + inline(rest, state) + '</' + tag + '>'; } else out += inline(inner, state); i = grp.end; continue; } out += esc(s[i]); i++; } return out; }
function renderBlocks(nodes, state, mergeFirst) { var html = ''; nodes.forEach(function (n, idx) { html += renderNode(n, state, mergeFirst && idx === 0); }); return html; }
function renderParas(text, state) { var re = /\uE000(\d+)\uE001/g; var html = ''; var last = 0; var buf = ''; var m; function flush() { var t = buf.replace(/\s*\n\s*/g, ' ').trim(); if (t) html += '<p>' + inline(t, state) + '</p>'; buf = ''; } while ((m = re.exec(text))) { var info = state.math[+m[1]]; if (info && info.display) { buf += text.slice(last, m.index); flush(); html += renderEq(info, state); } else { buf += text.slice(last, m.index) + m[0]; } last = m.index + m[0].length; } buf += text.slice(last); flush(); return html; }
function renderEq(info) { var id = info.id ? ' id="' + esc(info.id) + '"' : ''; var no = info.numbered ? '<span class="eq-no">(' + info.num + ')</span>' : ''; return '<div class="eq"' + id + '>' + no + '<div class="eq-body">\\[' + esc(info.tex) + '\\]</div></div>'; }
function renderNode(n, state, mergeHead) { if (n.type === 'maketitle') { return '<header class="paper-title"><h1>' + inline(state.title, state) + '</h1>' + '<p class="by">' + inline(state.author, state) + '</p>' + '<p class="date">' + inline(state.date, state) + '</p></header>'; } if (n.type === 'toc') return renderToc(state.tocNodes, state); if (n.type === 'section') { var tag = n.level === 1 ? 'h2' : n.level === 2 ? 'h3' : 'h4'; var num = n.num ? '<span class="sec-no">' + esc(n.num) + '</span> ' : ''; return '<' + tag + ' id="' + esc(n.anchor) + '">' + num + inline(n.title, state) + '</' + tag + '>'; } if (n.type === 'p') return renderParas(n.text, state); if (n.type === 'abstract') { return '<div class="abstract"><h2>Abstract</h2>' + renderBlocks(n.body, state) + '</div>'; } if (n.type === 'thm') { var meta = THM[n.kind]; var head = '<span class="thm-head"><strong>' + meta[0] + ' ' + esc(n.num) + '</strong>'; if (n.opt) head += ' <span class="note">(' + inline(n.opt, state) + ')</span>'; head += '.</span> '; return '<div class="thm ' + meta[1] + '"' + (n.id ? ' id="' + esc(n.id) + '"' : '') + '>' + mergeBody(head, n.body, state) + '</div>'; } if (n.type === 'proof') { var bodyHtml = mergeBody('<span class="proof-head"><em>Proof.</em></span> ', n.body, state); if (bodyHtml.indexOf('class="qed"') < 0) bodyHtml = bodyHtml.replace(/<\/p>\s*$/, ' <span class="qed">\u220e</span></p>'); if (bodyHtml.indexOf('class="qed"') < 0) bodyHtml += '<p class="qed-row"><span class="qed">\u220e</span></p>'; return '<div class="proof">' + bodyHtml + '</div>'; } if (n.type === 'center') { return '<div class="center ' + esc(n.size) + '">' + renderBlocks(n.body, state) + '</div>'; } if (n.type === 'list') return renderList(n, state); if (n.type === 'table') return renderTable(n, state); if (n.type === 'figure') { var imgs = n.imgs.map(function (src) { return '<img src="' + esc(src) + '" alt="" onerror="this.remove()">'; }).join(''); var id = n.id ? ' id="' + esc(n.id) + '"' : ''; return '<figure' + id + '><div class="figs">' + imgs + '</div><figcaption><strong>Figure ' + esc(n.num) + '.</strong> ' + inline(n.caption, state) + '</figcaption></figure>'; } if (n.type === 'bib') { var rows = n.items.map(function (it) { return '<dt id="bib-' + esc(it.key) + '">[' + it.num + ']</dt><dd>' + inline(it.text.replace(/\s*\n\s*/g, ' '), state) + '</dd>'; }).join(''); return '<section class="bib" id="references"><h2>References</h2><dl>' + rows + '</dl></section>'; } return ''; }
function mergeBody(head, blocks, state) { if (!blocks.length) return '<p>' + head + '</p>'; if (blocks[0].type !== 'p') return '<p>' + head + '</p>' + renderBlocks(blocks, state); var first = blocks[0].text; var re = /\uE000(\d+)\uE001/; var m = re.exec(first); var html; if (m && m.index === 0 && state.math[+m[1]] && state.math[+m[1]].display) { html = '<p>' + head + '</p>' + renderParas(first, state); } else { var collapsed = first.replace(/\s*\n\s*/g, ' ').trim(); var displayAt = collapsed.search(/\uE000(\d+)\uE001/); html = renderParas(collapsed, state).replace('<p>', '<p>' + head); } return html + renderBlocks(blocks.slice(1), state); }
function renderList(n, state) { if (n.kind === 'desc') { return '<dl class="desc">' + n.items.map(function (it) { return '<dt>' + inline(it.label || '', state) + '</dt><dd>' + renderBlocks(it.body, state) + '</dd>'; }).join('') + '</dl>'; } if (n.kind === 'bullet') { return '<ul>' + n.items.map(function (it) { return '<li><div class="li-body">' + renderBlocks(it.body, state) + '</div></li>'; }).join('') + '</ul>'; } return '<ol class="enum">' + n.items.map(function (it, idx) { return '<li><span class="marker">' + esc(formatMarker(n.kind, idx + 1)) + '</span><div class="li-body">' + renderBlocks(it.body, state) + '</div></li>'; }).join('') + '</ol>'; }
function renderTable(n, state) { var body = n.rows.map(function (row) { if (!row.cells || !row.cells.length) return ''; var cls = (row.ruleBefore ? ' rule-before' : '') + (row.ruleAfter ? ' rule-after' : ''); var cells = row.cells.map(function (cell) { var span = cell.span > 1 ? ' colspan="' + cell.span + '"' : ''; return '<td' + span + '>' + inline(cell.text, state) + '</td>'; }).join(''); return '<tr class="' + cls.trim() + '">' + cells + '</tr>'; }).join(''); return '<div class="table-wrap ' + esc(n.size) + '"><table>' + body + '</table></div>'; }
function renderToc(nodes, state) { var html = '<nav class="toc"><p class="toc-label">Contents</p><ol>'; var open = false; var started = false; nodes.forEach(function (n) { if (n.type !== 'section' || n.level > 2) return; if (n.level === 1) { if (open) html += '</ol></li>'; else if (started) html += '</li>'; html += '<li><a href="#' + esc(n.anchor) + '"><span class="sec-no">' + esc(n.num) + '</span> ' + inline(n.title, state) + '</a>'; open = false; started = true; } else { if (!open) { html += '<ol>'; open = true; } html += '<li><a href="#' + esc(n.anchor) + '"><span class="sec-no">' + esc(n.num) + '</span> ' + inline(n.title, state) + '</a></li>'; } }); if (open) html += '</ol></li>'; else html += '</li>'; return html + '</ol></nav>'; }
function convert(tex) { var extracted = extractAll(stripComments(tex)); var text = extracted.text; var doc = text.split('\\begin{document}'); if (doc.length < 2) throw new Error('missing \\begin{document}'); var body = doc[1].split('\\end{document}')[0]; var state = { math: extracted.math, labels: {}, cites: {}, unknown: {}, title: grab(text, 'title'), author: grab(text, 'author'), date: grab(text, 'date'), sec: 0, sub: 0, thm: 0, eq: 0, fig: 0, tocNodes: null }; var nodes = parseContent(body, 0); state.tocNodes = nodes; walk(nodes, state); return { html: renderBlocks(nodes, state), unknown: state.unknown, labels: state.labels, counts: { display: extracted.math.filter(function (m) { return m.display; }).length, inline: extracted.math.filter(function (m) { return !m.display; }).length } }; }
root.tex2html = convert; if (typeof module !== 'undefined') module.exports = convert;})(typeof window !== 'undefined' ? window : globalThis);index.html+89-52
tex2html.jsAdded+870