omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / apps / interplane-forge / research / build.om
| 1 | om2 |
| 2 | note build.om: the INTERPLANE research pages as one seeded Omega program. A filter: stdin is one mode |
| 3 | note line, then the registry (research/registry/catalog.tsv); stdout is one document. No scripts are emitted. |
| 4 | note Mode line: M <tab> mode [<tab> slug]. Modes: index css json bib txt slugs work wjson wbib. |
| 5 | note Registry lines are tab-separated facts (README.md "Registry"). Every field is escaped for the |
| 6 | note document it goes into (HTML, JSON, BibTeX, a URL query). Exit 0 on success, 1 when stdout fails, |
| 7 | note 2 for an unknown mode, 3 when the slug names no work. |
| 8 | global ib uchar 262144 |
| 9 | global ibl ulong 1 |
| 10 | global ob uchar 2097152 |
| 11 | global obl ulong 1 |
| 12 | note mgr: 1 when the mode is merge, whose raw catalog has no J line until merge writes it. |
| 13 | global mgr ulong 1 |
| 14 | text tamp "&" |
| 15 | text tlt "<" |
| 16 | text tgt ">" |
| 17 | text tquo """ |
| 18 | text tapo "'" |
| 19 | text thex "0123456789ABCDEF" |
| 20 | text mindex "index" |
| 21 | text mcss "css" |
| 22 | text mjson "json" |
| 23 | text mbib "bib" |
| 24 | text mtxt "txt" |
| 25 | text mslugs "slugs" |
| 26 | text mwork "work" |
| 27 | text mwjson "wjson" |
| 28 | text mwbib "wbib" |
| 29 | text korcid "orcid" |
| 30 | text kname "name" |
| 31 | text kbio "bio" |
| 32 | text kalso "also-published-as" |
| 33 | text kedu "education" |
| 34 | text kcheck "checked" |
| 35 | text kowork "orcid-works" |
| 36 | text ksite "site" |
| 37 | text rsup "isSupplementTo" |
| 38 | text rref "references" |
| 39 | text rder "isDerivedFrom" |
| 40 | text psup "supplements" |
| 41 | text pref "cites" |
| 42 | text pder "is derived from" |
| 43 | text rsby "isSupplementedBy" |
| 44 | text psby "is supplemented by" |
| 45 | text ridt "isIdenticalTo" |
| 46 | text pidt "is identical to" |
| 47 | text rpub "isPublishedIn" |
| 48 | text ppub "is published in" |
| 49 | text phttps "https://" |
| 50 | text h1 "<!doctype html><html lang='en' data-theme='dark'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1'><title>" |
| 51 | text h2 "</title><link rel='stylesheet' href='/assets/tokens.css'><link rel='stylesheet' href='/assets/research.css'><link rel='alternate' type='application/json' href='" |
| 52 | text h3 "'></head><body>\n<header class='top'><a class='wm' href='/'>INTERPLANE</a><nav><a href='/galaxy'>Galaxy</a><a href='/explore'>Explore</a><a class='on' href='/research'>Research</a><a href='/open/'>Open builds</a><a href='/salvage/'>Bring your build</a></nav></header>\n<main>\n" |
| 53 | text hfoot "</main>\n<footer class='foot'><p>DOIs are minted by Zenodo. Everything else here is built from the research registry in the Interplane forge repository by a seeded Omega program. No scripts run on this page.</p><p><a href='/research.json'>JSON</a><a href='/research.bib'>BibTeX</a><a href='/research.txt'>Guide for agents</a></p></footer></body></html>\n" |
| 54 | text ititle "Research on INTERPLANE" |
| 55 | text ijson "/research.json" |
| 56 | text i01 "<section class='hero'><p class='eyebrow'>Research</p><h1>Ask the research.</h1><p class='sub'>" |
| 57 | text i02 " works and " |
| 58 | text i03 " versions by " |
| 59 | text i04 ", each with its full text. Ask a question: an agent on my Spark answers from the papers and names the ones it used.</p>\n" |
| 60 | text iform "<form class='ask' action='/research/ask' method='get'><input class='q' type='text' name='q' maxlength='300' required placeholder='What does the Turing measure?' aria-label='Your question'><button class='btn' type='submit'>Ask</button></form>\n" |
| 61 | text itry "<p class='try'>Try <a href='/research/ask?q=What+is+a+Turing+and+how+is+it+measured%3F'>What is a Turing and how is it measured?</a><a href='/research/ask?q=How+does+the+Spark+run+a+model+with+no+CUDA+libraries%3F'>How does the Spark run a model with no CUDA libraries?</a><a href='/research/ask?q=What+separates+a+hive+from+a+swarm+of+agents%3F'>What separates a hive from a swarm of agents?</a></p></section>\n" |
| 62 | text a01 "<section class='card who' id='author'><p class='eyebrow'>Author</p><h2>" |
| 63 | text a02 "</h2><p class='orcid'><span class='idb'>ORCID iD</span><a href='https://orcid.org/" |
| 64 | text a03 "'>https://orcid.org/" |
| 65 | text a04 "</a></p><p class='sub'>" |
| 66 | text a05 "</p><p class='meta'>Also published as " |
| 67 | text a06 ". " |
| 68 | text a07 ".</p><dl class='stats'><div><dt>Works</dt><dd>" |
| 69 | text a08 "</dd></div><div><dt>Versions</dt><dd>" |
| 70 | text a09 "</dd></div><div><dt>On the ORCID record</dt><dd>" |
| 71 | text a10 " of " |
| 72 | text a11 "</dd></div><div><dt>Checked</dt><dd>" |
| 73 | text a12 "</dd></div></dl></section>\n" |
| 74 | text t01 "<section class='thread' id='t-" |
| 75 | text t02 "'><div class='th'><p class='eyebrow'>Thread</p><h2>" |
| 76 | text t03 "</h2><p class='sub'>" |
| 77 | text t04 "</p></div><ol class='works'>\n" |
| 78 | text t05 "</ol></section>\n" |
| 79 | text w01 "<li><a class='wt' href='/research/" |
| 80 | text w02 "'>" |
| 81 | text w03 "</a><p class='ws'>" |
| 82 | text w04 "</p><p class='wmeta'><span>" |
| 83 | text w05 "</span><span>" |
| 84 | text w06 "</span><span>version " |
| 85 | text w07 "</span><span>" |
| 86 | text w08 " versions</span><a class='doi' href='https://doi.org/" |
| 87 | text w08b "</span><a class='doi' href='https://doi.org/" |
| 88 | text w09 "</a>" |
| 89 | text wok "<span class='ok'>On the ORCID record</span>" |
| 90 | text wno "<span class='warn'>Not on the ORCID record yet</span>" |
| 91 | text w10 "</p></li>\n" |
| 92 | text c01 "<section class='card' id='connections'><p class='eyebrow'>Lineage</p><h2>How the work connects</h2><p class='sub'>Each line is a relation recorded in the published metadata of the first work.</p><ul class='edges'>\n" |
| 93 | text c02 "<li><a href='/research/" |
| 94 | text c03 "</a><span class='rel'>" |
| 95 | text c04 "</span><a href='/research/" |
| 96 | text c05 "</a></li>\n" |
| 97 | text c06 "</ul></section>\n" |
| 98 | text p01 "<article class='work'><p class='eyebrow'><a href='/research#t-" |
| 99 | text p02 "</a></p><h1>" |
| 100 | text p03 "</h1><p class='by'>" |
| 101 | text p04 "</p><p class='lead'>" |
| 102 | text p05 "</p><p class='acts'><a class='btn' href='https://doi.org/" |
| 103 | text p06 "'>Read at the DOI</a><a class='btn ghost' href='/research/" |
| 104 | text p07 ".bib'>BibTeX</a><a class='btn ghost' href='/research/" |
| 105 | text p08 ".json'>JSON</a></p>\n" |
| 106 | text p09 "<section class='card'><h2>Ask about this work</h2><form class='ask' action='/research/ask' method='get'><input class='q' type='text' name='q' maxlength='300' required aria-label='Your question' value='" |
| 107 | text p10 "'><button class='btn' type='submit'>Ask</button></form><p class='try'>Or <a href='/research/ask?q=What+evidence+supports+" |
| 108 | text p11 "%3F'>what evidence supports it?</a><a href='/research/ask?q=What+are+the+stated+limits+of+" |
| 109 | text p12 "%3F'>what are its stated limits?</a></p></section>\n" |
| 110 | text pq1 "What does " |
| 111 | text pq2 " claim?" |
| 112 | text p13 "<section class='card'><h2>Abstract</h2><p class='abs'>" |
| 113 | text p14 "</p></section>\n<section class='card'><h2>Cite</h2><p class='cite'>" |
| 114 | text p15 "</p><dl class='ids'><div><dt>DOI, all versions</dt><dd><a href='https://doi.org/" |
| 115 | text p16 "</a></dd></div><div><dt>DOI, this version</dt><dd><a href='https://doi.org/" |
| 116 | text p17 "</a></dd></div><div><dt>License</dt><dd>" |
| 117 | text p18 "</dd></div><div><dt>ORCID record</dt><dd>" |
| 118 | text p19 "</dd></div></dl></section>\n" |
| 119 | text pyes "listed" |
| 120 | text pnot "not listed yet" |
| 121 | text v01 "<section class='card'><h2>Versions</h2><ol class='vers'>\n" |
| 122 | text v02 "<li><span class='vn'>" |
| 123 | text v03 "</span><span>" |
| 124 | text v04 "</span><a class='doi' href='https://doi.org/" |
| 125 | text v05 "</a></li>\n" |
| 126 | text v06 "</ol></section>\n" |
| 127 | text e01 "<section class='card'><h2>Connected work</h2><ul class='edges'>\n" |
| 128 | text e02 "<li><span class='rel'>This work " |
| 129 | text e03 "<li><a href='/research/" |
| 130 | text e04 "</a><span class='rel'>" |
| 131 | text e05 " this work</span></li>\n" |
| 132 | text e06 "<li><span class='rel'>" |
| 133 | text e07 "</span><a href='" |
| 134 | text f01 "<section class='card'><h2>Files</h2><ul class='files'>\n" |
| 135 | text f02 "<li><a href='" |
| 136 | text f03 "</a><span>" |
| 137 | text f04 " bytes</span></li>\n" |
| 138 | text k01 "<section class='card'><h2>Keywords</h2><p class='kw'>" |
| 139 | text k02 "<span>" |
| 140 | text k03 "</span>" |
| 141 | text k04 "</p></section>\n" |
| 142 | text tsend "</ul></section>\n" |
| 143 | text pend "</article>\n" |
| 144 | text tspan "</span>" |
| 145 | text tdot ". " |
| 146 | text tsp " " |
| 147 | text tcomma ", " |
| 148 | text tparo " (" |
| 149 | text tparc "). " |
| 150 | text tdoiu "https://doi.org/" |
| 151 | text tresu "https://interplane.io/research/" |
| 152 | note ---- JSON texts |
| 153 | text j01 "{\"schema\":\"interplane/research/1\",\"author\":{\"name\":\"" |
| 154 | text j02 "\",\"orcid\":\"https://orcid.org/" |
| 155 | text j03 "\",\"also_published_as\":\"" |
| 156 | text j04 "\"},\"checked\":\"" |
| 157 | text j05 "\",\"ask\":\"https://interplane.io/research/ask?q=\",\"works\":[" |
| 158 | text j06 "],\"threads\":[" |
| 159 | text j07 "],\"relations\":[" |
| 160 | text j08 "]}\n" |
| 161 | text jw1 "{\"slug\":\"" |
| 162 | text jw2 "\",\"title\":\"" |
| 163 | text jw3 "\",\"thread\":\"" |
| 164 | text jw4 "\",\"date\":\"" |
| 165 | text jw5 "\",\"kind\":\"" |
| 166 | text jw6 "\",\"venue\":\"" |
| 167 | text jw7 "\",\"doi\":\"" |
| 168 | text jw8 "\",\"doi_this_version\":\"" |
| 169 | text jw9 "\",\"version\":\"" |
| 170 | text jw10 "\",\"versions\":" |
| 171 | text jw11 ",\"on_orcid\":" |
| 172 | text jw12 ",\"license\":\"" |
| 173 | text jw13 "\",\"summary\":\"" |
| 174 | text jw14 "\",\"url\":\"https://interplane.io/research/" |
| 175 | text jw15 "\"}" |
| 176 | text jt1 "{\"id\":\"" |
| 177 | text jt2 "\",\"description\":\"" |
| 178 | text je1 "{\"from\":\"" |
| 179 | text je2 "\",\"relation\":\"" |
| 180 | text je3 "\",\"to\":\"" |
| 181 | text jx1 "{\"schema\":\"interplane/research-work/1\",\"work\":" |
| 182 | text jx2 ",\"authors\":\"" |
| 183 | text jx3 "\",\"abstract\":\"" |
| 184 | text jx4 "\",\"keywords\":[" |
| 185 | text jx5 "],\"version_history\":[" |
| 186 | text jx6 "],\"files\":[" |
| 187 | text jx7 "],\"links\":[" |
| 188 | text jx8 "],\"relations\":[" |
| 189 | text jq "\"" |
| 190 | text jv1 "{\"doi\":\"" |
| 191 | text jv2 "\",\"date\":\"" |
| 192 | text jv3 "\",\"version\":\"" |
| 193 | text jf1 "{\"name\":\"" |
| 194 | text jf2 "\",\"bytes\":" |
| 195 | text jf3 ",\"url\":\"" |
| 196 | text jl1 "{\"relation\":\"" |
| 197 | text jl2 "\",\"url\":\"" |
| 198 | text jtrue "true" |
| 199 | text jfalse "false" |
| 200 | text ju00 "\\u00" |
| 201 | note ---- BibTeX and plain text |
| 202 | text b01 "@misc{" |
| 203 | text b01a "@article{" |
| 204 | text b02 ",\n author = {" |
| 205 | text b03 "},\n title = {" |
| 206 | text b04 "},\n year = {" |
| 207 | text b05 "},\n howpublished = {" |
| 208 | text b06 "},\n version = {" |
| 209 | text b07 "},\n doi = {" |
| 210 | text b08 "},\n url = {https://doi.org/" |
| 211 | text b09 "}\n}\n\n" |
| 212 | text kart "journal-article" |
| 213 | text x01 "# Research on INTERPLANE: a guide for agents\n\nAuthor: " |
| 214 | text x02 "\nORCID: https://orcid.org/" |
| 215 | text x03 "\n\nEvery page has a JSON twin. Start at https://interplane.io/research.json (schema interplane/research/1).\nOne work: https://interplane.io/research/<slug>.json. BibTeX: https://interplane.io/research.bib or /research/<slug>.bib.\nAsk a question: GET https://interplane.io/research/ask?q=<your question, at most 300 bytes>. The answer is written by a\nmodel on the author's Spark from the full text of these works; follow the redirect and poll the answer URL (append .json).\nAn answer names the works it used. Check a claim against the work itself before relying on it.\n\nWorks:\n" |
| 216 | text x04 "\n- " |
| 217 | text x05 "\n " |
| 218 | text x06 " | " |
| 219 | text x07 " | https://doi.org/" |
| 220 | text x08 "\n https://interplane.io/research/" |
| 221 | note ---- stylesheet (colours only through the Sovereign Intelligence tokens) |
| 222 | text q01 "*{box-sizing:border-box}html,body{margin:0;background:var(--bg-primary);color:var(--text-primary);font:16px/24px var(--font-sans,Inter,system-ui,sans-serif)}\n" |
| 223 | text q02 "a{color:var(--accent);text-decoration:none;transition:color .15s}a:hover{color:var(--accent-hover)}a:focus-visible,input:focus-visible,button:focus-visible{outline:2px solid var(--focus-ring);outline-offset:2px}\n" |
| 224 | text q03 ".top{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:24px;padding:12px 32px;background:var(--bg-header);border-bottom:1px solid var(--border)}\n" |
| 225 | text q04 ".wm{font-weight:700;letter-spacing:.3em;color:var(--text-primary)}.top nav{display:flex;gap:20px;font-size:14px}.top .on{color:var(--text-primary)}\n" |
| 226 | text q05 "main{max-width:1024px;margin:0 auto;padding:40px 24px 56px;display:flex;flex-direction:column;gap:16px}\n" |
| 227 | text q06 ".eyebrow{margin:0 0 8px;font-size:12px;line-height:16px;font-weight:600;letter-spacing:.2em;text-transform:uppercase;color:var(--accent)}\n" |
| 228 | text q07 "h1{margin:0 0 12px;font-size:36px;line-height:40px;font-weight:700}h2{margin:0 0 8px;font-size:18px;line-height:28px;font-weight:600}\n" |
| 229 | text q08 ".sub{margin:0 0 12px;color:var(--text-secondary)}.meta{margin:0 0 16px;font-size:12px;line-height:16px;color:var(--text-secondary)}\n" |
| 230 | text q09 ".hero{padding:24px 0 8px}.hero h1{font-size:48px;line-height:52px}\n" |
| 231 | text q10 ".ask{display:flex;gap:8px;margin:16px 0 12px}.q{flex:1;min-width:0;padding:12px 16px;border:1px solid var(--border-strong);border-radius:8px;background:var(--fill-input);color:var(--text-primary);font:16px/24px var(--font-sans,Inter,system-ui,sans-serif)}\n" |
| 232 | text q11 ".btn{display:inline-block;padding:12px 20px;border:0;border-radius:8px;background:var(--accent-fill);color:var(--on-accent-fill);font:600 16px/24px var(--font-sans,Inter,system-ui,sans-serif);cursor:pointer;transition:background-color .15s}\n" |
| 233 | text q12 ".btn:hover{background:var(--accent-fill-hover);color:var(--on-accent-fill)}.ghost,.ghost:hover{background:none;border:1px solid var(--border-strong);color:var(--text-primary)}\n" |
| 234 | text q13 ".try{margin:0;font-size:14px;line-height:20px;color:var(--text-secondary);display:flex;flex-wrap:wrap;gap:4px 16px}\n" |
| 235 | text q14 ".card,.thread{background:var(--bg-card);border:1px solid var(--border);border-radius:16px;padding:24px}\n" |
| 236 | text q15 ".orcid{margin:0 0 12px;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;font:14px/20px var(--font-mono,ui-monospace,monospace)}\n" |
| 237 | text q16 ".idb{padding:2px 10px;border:1px solid var(--success-line);border-radius:9999px;background:var(--success-tint);color:var(--success);font:600 12px/16px var(--font-sans,Inter,system-ui,sans-serif)}\n" |
| 238 | text q17 ".stats{display:grid;grid-template-columns:repeat(4,auto);gap:12px;margin:0}.stats dt{font-size:12px;line-height:16px;color:var(--text-secondary)}.stats dd{margin:0;font:600 20px/28px var(--font-mono,ui-monospace,monospace)}\n" |
| 239 | text q18 ".works,.vers,.edges,.files{list-style:none;margin:0;padding:0}.works li{padding:16px 0;border-top:1px solid var(--border-faint)}.works li:last-child{padding-bottom:0}\n" |
| 240 | text q19 ".wt{font-size:16px;line-height:24px;font-weight:600;color:var(--text-primary)}.wt:hover{color:var(--accent)}.ws{margin:4px 0 8px;color:var(--text-secondary);font-size:14px;line-height:20px}\n" |
| 241 | text q20 ".wmeta,.by{margin:0;display:flex;flex-wrap:wrap;gap:4px 16px;font:12px/16px var(--font-mono,ui-monospace,monospace);color:var(--text-secondary)}.by{margin:0 0 16px;font-size:14px;line-height:20px}\n" |
| 242 | text q21 ".ok{color:var(--success)}.warn{color:var(--warning)}.doi{overflow-wrap:anywhere}\n" |
| 243 | text q22 ".edges li,.vers li,.files li{display:flex;flex-wrap:wrap;gap:4px 12px;padding:8px 0;border-top:1px solid var(--border-faint);font-size:14px;line-height:20px}\n" |
| 244 | text q23 ".rel{color:var(--text-secondary)}.vn{font-weight:600}.vers li,.files li{font-family:var(--font-mono,ui-monospace,monospace);font-size:12px;line-height:16px}\n" |
| 245 | text q24 ".work h1{font-size:36px;line-height:40px}.lead{margin:0 0 16px;font-size:18px;line-height:28px}.acts{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 8px}\n" |
| 246 | text q25 ".work{display:flex;flex-direction:column;gap:16px}.work>.eyebrow,.work>h1,.work>.by,.work>.lead,.work>.acts{margin-bottom:0}\n" |
| 247 | text q26 ".abs{margin:0;color:var(--text-secondary);overflow-wrap:anywhere}.cite{margin:0 0 16px;padding:12px;border:1px solid var(--border);border-radius:8px;background:var(--fill-input);font:12px/16px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}\n" |
| 248 | text q27 ".ids{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:0}.ids dt{font-size:12px;line-height:16px;color:var(--text-secondary)}.ids dd{margin:0;font:12px/16px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}\n" |
| 249 | text q28 ".kw{margin:0;display:flex;flex-wrap:wrap;gap:8px}.kw span{padding:2px 10px;border:1px solid var(--border);border-radius:9999px;font-size:12px;line-height:16px;color:var(--text-secondary)}\n" |
| 250 | text q29 ".foot{max-width:1024px;margin:0 auto;padding:0 24px 40px;font-size:12px;line-height:16px;color:var(--text-secondary)}.foot p{margin:0 0 8px}.foot a{margin-right:16px}\n" |
| 251 | text q30 ".answer{white-space:pre-wrap;margin:0 0 16px;overflow-wrap:anywhere}.wait{color:var(--text-secondary)}\n" |
| 252 | text q31 "@media (max-width:700px){.top{gap:8px 12px;padding:12px 16px;flex-wrap:wrap}.top nav{flex-wrap:wrap;gap:6px 16px}main{padding:24px 16px 40px}.hero h1{font-size:36px;line-height:40px}.ask{flex-direction:column}.stats{grid-template-columns:repeat(2,auto)}.ids{grid-template-columns:1fr}.card,.thread{padding:16px}}\n" |
| 253 | note ---- output buffer: a byte past the end is dropped, never written |
| 254 | fn emb c uchar to void |
| 255 | o = get obl 0 |
| 256 | if lt o 2097152 |
| 257 | put ob o c |
| 258 | put obl 0 add o 1 |
| 259 | else |
| 260 | exit 4 |
| 261 | end |
| 262 | end |
| 263 | fn em t view uchar * to void |
| 264 | n = len t |
| 265 | i = ulong 0 |
| 266 | while lt i n bound 65536 |
| 267 | emb get t i |
| 268 | i = add i 1 |
| 269 | end |
| 270 | end |
| 271 | fn emn v ulong to void |
| 272 | d = new uchar 20 0 |
| 273 | n = ulong 0 |
| 274 | x = v |
| 275 | if eq x 0 |
| 276 | emb 48 |
| 277 | end |
| 278 | while gt x 0 bound 20 |
| 279 | put d n uchar add 48 rem x 10 |
| 280 | x = div x 10 |
| 281 | n = add n 1 |
| 282 | end |
| 283 | while gt n 0 bound 20 |
| 284 | n = sub n 1 |
| 285 | emb get d n |
| 286 | end |
| 287 | end |
| 288 | note cut: the end of a..b after at most cap bytes, never inside a UTF-8 character |
| 289 | fn cut a ulong b ulong cap ulong to ulong |
| 290 | if le b a |
| 291 | ret a |
| 292 | end |
| 293 | if le sub b a cap |
| 294 | ret b |
| 295 | end |
| 296 | e = add a cap |
| 297 | k = ulong 0 |
| 298 | while lt k 3 bound 3 |
| 299 | if gt e a |
| 300 | u = get ib e |
| 301 | if ge u 128 |
| 302 | if lt u 192 |
| 303 | e = sub e 1 |
| 304 | end |
| 305 | end |
| 306 | end |
| 307 | k = add k 1 |
| 308 | end |
| 309 | ret e |
| 310 | end |
| 311 | note emh: a..b of the input, HTML-escaped, at most cap input bytes |
| 312 | fn emh a ulong b ulong cap ulong to void |
| 313 | e = cut a b cap |
| 314 | i = a |
| 315 | while lt i e bound 262144 |
| 316 | c = get ib i |
| 317 | if eq c 38 |
| 318 | em tamp |
| 319 | else |
| 320 | if eq c 60 |
| 321 | em tlt |
| 322 | else |
| 323 | if eq c 62 |
| 324 | em tgt |
| 325 | else |
| 326 | if eq c 34 |
| 327 | em tquo |
| 328 | else |
| 329 | if eq c 39 |
| 330 | em tapo |
| 331 | else |
| 332 | if ge c 32 |
| 333 | emb c |
| 334 | end |
| 335 | end |
| 336 | end |
| 337 | end |
| 338 | end |
| 339 | end |
| 340 | i = add i 1 |
| 341 | end |
| 342 | end |
| 343 | note emj: a..b as the inside of a JSON string |
| 344 | fn emj a ulong b ulong cap ulong to void |
| 345 | e = cut a b cap |
| 346 | i = a |
| 347 | while lt i e bound 262144 |
| 348 | c = get ib i |
| 349 | if or eq c 34 eq c 92 |
| 350 | emb 92 |
| 351 | emb c |
| 352 | else |
| 353 | if lt c 32 |
| 354 | em ju00 |
| 355 | emb get thex ulong shr c 4 |
| 356 | emb get thex ulong and c 15 |
| 357 | else |
| 358 | emb c |
| 359 | end |
| 360 | end |
| 361 | i = add i 1 |
| 362 | end |
| 363 | end |
| 364 | note emq: a..b as part of a URL query: letters, digits and -._~ stay, a space is +, the rest %XX |
| 365 | fn emq a ulong b ulong cap ulong to void |
| 366 | e = cut a b cap |
| 367 | i = a |
| 368 | while lt i e bound 262144 |
| 369 | c = get ib i |
| 370 | ok = false |
| 371 | if and ge c 48 le c 57 |
| 372 | ok = true |
| 373 | end |
| 374 | if and ge c 65 le c 90 |
| 375 | ok = true |
| 376 | end |
| 377 | if and ge c 97 le c 122 |
| 378 | ok = true |
| 379 | end |
| 380 | if or or eq c 45 eq c 46 or eq c 95 eq c 126 |
| 381 | ok = true |
| 382 | end |
| 383 | if ok |
| 384 | emb c |
| 385 | else |
| 386 | if eq c 32 |
| 387 | emb 43 |
| 388 | else |
| 389 | emb 37 |
| 390 | emb get thex ulong shr c 4 |
| 391 | emb get thex ulong and c 15 |
| 392 | end |
| 393 | end |
| 394 | i = add i 1 |
| 395 | end |
| 396 | end |
| 397 | note emx: a..b for a BibTeX value: braces/backslashes/carets/tildes neutralized, & % # _ $ escaped |
| 398 | fn emx a ulong b ulong cap ulong to void |
| 399 | e = cut a b cap |
| 400 | i = a |
| 401 | while lt i e bound 262144 |
| 402 | c = get ib i |
| 403 | if or or or eq c 123 eq c 125 eq c 92 or eq c 94 eq c 126 |
| 404 | c = uchar 32 |
| 405 | end |
| 406 | if or or eq c 38 eq c 37 or or eq c 35 eq c 95 eq c 36 |
| 407 | emb 92 |
| 408 | end |
| 409 | if ge c 32 |
| 410 | emb c |
| 411 | end |
| 412 | i = add i 1 |
| 413 | end |
| 414 | end |
| 415 | note emr: a..b as plain text (control bytes dropped) |
| 416 | fn emr a ulong b ulong cap ulong to void |
| 417 | e = cut a b cap |
| 418 | i = a |
| 419 | while lt i e bound 262144 |
| 420 | c = get ib i |
| 421 | if ge c 32 |
| 422 | emb c |
| 423 | end |
| 424 | i = add i 1 |
| 425 | end |
| 426 | end |
| 427 | note ---- input scanning: every index stays inside 0..ibl |
| 428 | fn find a ulong e ulong c uchar to ulong |
| 429 | i = a |
| 430 | while lt i e bound 262144 |
| 431 | if eq get ib i c |
| 432 | ret i |
| 433 | end |
| 434 | i = add i 1 |
| 435 | end |
| 436 | ret e |
| 437 | end |
| 438 | fn eol a ulong to ulong |
| 439 | ret find a get ibl 0 10 |
| 440 | end |
| 441 | note nextl: start of the first line at or after p that is "ty <tab> ...", or ibl |
| 442 | fn nextl p ulong ty uchar to ulong |
| 443 | lim = get ibl 0 |
| 444 | s = p |
| 445 | while lt s lim bound 262144 |
| 446 | if eq get ib s ty |
| 447 | if lt add s 1 lim |
| 448 | if eq get ib add s 1 9 |
| 449 | ret s |
| 450 | end |
| 451 | end |
| 452 | end |
| 453 | s = add eol s 1 |
| 454 | end |
| 455 | ret lim |
| 456 | end |
| 457 | note fld: start of field k (0 based) of the line s..e; e when the line has fewer fields |
| 458 | fn fld s ulong e ulong k ulong to ulong |
| 459 | p = s |
| 460 | j = ulong 0 |
| 461 | while lt j k bound 16 |
| 462 | p = find p e 9 |
| 463 | if lt p e |
| 464 | p = add p 1 |
| 465 | end |
| 466 | j = add j 1 |
| 467 | end |
| 468 | ret p |
| 469 | end |
| 470 | note fe: end of the field that starts at a in the line ending at e |
| 471 | fn fe a ulong e ulong to ulong |
| 472 | ret find a e 9 |
| 473 | end |
| 474 | fn feqt a ulong b ulong t view uchar * to bool |
| 475 | n = len t |
| 476 | if lt b a |
| 477 | ret false |
| 478 | end |
| 479 | if ne sub b a n |
| 480 | ret false |
| 481 | end |
| 482 | i = ulong 0 |
| 483 | while lt i n bound 256 |
| 484 | if ne get ib add a i get t i |
| 485 | ret false |
| 486 | end |
| 487 | i = add i 1 |
| 488 | end |
| 489 | ret true |
| 490 | end |
| 491 | fn feqr a ulong b ulong c ulong d ulong to bool |
| 492 | if or lt b a lt d c |
| 493 | ret false |
| 494 | end |
| 495 | n = sub b a |
| 496 | if ne n sub d c |
| 497 | ret false |
| 498 | end |
| 499 | i = ulong 0 |
| 500 | while lt i n bound 262144 |
| 501 | if ne get ib add a i get ib add c i |
| 502 | ret false |
| 503 | end |
| 504 | i = add i 1 |
| 505 | end |
| 506 | ret true |
| 507 | end |
| 508 | fn pnum a ulong b ulong to ulong |
| 509 | v = ulong 0 |
| 510 | i = a |
| 511 | while lt i b bound 262144 |
| 512 | c = get ib i |
| 513 | if and ge c 48 le c 57 |
| 514 | v = add mul v 10 ulong sub c 48 |
| 515 | end |
| 516 | i = add i 1 |
| 517 | end |
| 518 | ret v |
| 519 | end |
| 520 | fn cnt ty uchar to ulong |
| 521 | lim = get ibl 0 |
| 522 | n = ulong 0 |
| 523 | s = nextl 0 ty |
| 524 | while lt s lim bound 262144 |
| 525 | n = add n 1 |
| 526 | s = nextl add eol s 1 ty |
| 527 | end |
| 528 | ret n |
| 529 | end |
| 530 | note slugok: a..b is 1 to 64 bytes of a-z, 0-9 and - |
| 531 | fn slugok a ulong b ulong to bool |
| 532 | if or le b a gt sub b a 64 |
| 533 | ret false |
| 534 | end |
| 535 | i = a |
| 536 | while lt i b bound 64 |
| 537 | c = get ib i |
| 538 | ok = false |
| 539 | if and ge c 97 le c 122 |
| 540 | ok = true |
| 541 | end |
| 542 | if and ge c 48 le c 57 |
| 543 | ok = true |
| 544 | end |
| 545 | if eq c 45 |
| 546 | ok = true |
| 547 | end |
| 548 | if not ok |
| 549 | ret false |
| 550 | end |
| 551 | i = add i 1 |
| 552 | end |
| 553 | ret true |
| 554 | end |
| 555 | note wline: start of the W line whose slug is a..b, or ibl |
| 556 | fn wline a ulong b ulong to ulong |
| 557 | lim = get ibl 0 |
| 558 | s = nextl 0 87 |
| 559 | while lt s lim bound 262144 |
| 560 | e = eol s |
| 561 | f = fld s e 1 |
| 562 | if feqr f fe f e a b |
| 563 | ret s |
| 564 | end |
| 565 | s = nextl add e 1 87 |
| 566 | end |
| 567 | ret lim |
| 568 | end |
| 569 | note sline: start of the first line of type ty whose field 1 is a..b, at or after p; or ibl |
| 570 | fn sline p ulong ty uchar a ulong b ulong to ulong |
| 571 | lim = get ibl 0 |
| 572 | s = nextl p ty |
| 573 | while lt s lim bound 262144 |
| 574 | e = eol s |
| 575 | f = fld s e 1 |
| 576 | if feqr f fe f e a b |
| 577 | ret s |
| 578 | end |
| 579 | s = nextl add e 1 ty |
| 580 | end |
| 581 | ret lim |
| 582 | end |
| 583 | note oval: start of the value of author fact t (an O line), or ibl |
| 584 | fn oval t view uchar * to ulong |
| 585 | lim = get ibl 0 |
| 586 | s = nextl 0 79 |
| 587 | while lt s lim bound 262144 |
| 588 | e = eol s |
| 589 | f = fld s e 1 |
| 590 | if feqt f fe f e t |
| 591 | ret fld s e 2 |
| 592 | end |
| 593 | s = nextl add e 1 79 |
| 594 | end |
| 595 | ret lim |
| 596 | end |
| 597 | note emo: the value of author fact t, HTML-escaped; nothing when the fact is absent |
| 598 | fn emo t view uchar * cap ulong to void |
| 599 | v = oval t |
| 600 | if lt v get ibl 0 |
| 601 | emh v eol v cap |
| 602 | end |
| 603 | end |
| 604 | fn emoj t view uchar * cap ulong to void |
| 605 | v = oval t |
| 606 | if lt v get ibl 0 |
| 607 | emj v eol v cap |
| 608 | end |
| 609 | end |
| 610 | fn emor t view uchar * cap ulong to void |
| 611 | v = oval t |
| 612 | if lt v get ibl 0 |
| 613 | emr v eol v cap |
| 614 | end |
| 615 | end |
| 616 | note wf: field k of the W line s, as start; its end is fe of that start |
| 617 | fn wf s ulong k ulong to ulong |
| 618 | ret fld s eol s k |
| 619 | end |
| 620 | note emwh / emwj: field k of the W line s, escaped for HTML or JSON |
| 621 | fn emwh s ulong k ulong cap ulong to void |
| 622 | a = wf s k |
| 623 | emh a fe a eol s cap |
| 624 | end |
| 625 | fn emwj s ulong k ulong cap ulong to void |
| 626 | a = wf s k |
| 627 | emj a fe a eol s cap |
| 628 | end |
| 629 | note emsub: field 2 of the first line of type ty for the work of W line s (its summary, authors, abstract) |
| 630 | fn subv s ulong ty uchar to ulong |
| 631 | a = wf s 1 |
| 632 | l = sline 0 ty a fe a eol s |
| 633 | if ge l get ibl 0 |
| 634 | ret get ibl 0 |
| 635 | end |
| 636 | ret fld l eol l 2 |
| 637 | end |
| 638 | fn emsubh s ulong ty uchar cap ulong to void |
| 639 | v = subv s ty |
| 640 | if lt v get ibl 0 |
| 641 | emh v eol v cap |
| 642 | end |
| 643 | end |
| 644 | fn emsubj s ulong ty uchar cap ulong to void |
| 645 | v = subv s ty |
| 646 | if lt v get ibl 0 |
| 647 | emj v eol v cap |
| 648 | end |
| 649 | end |
| 650 | note norcid: works whose W line says the ORCID record lists them |
| 651 | fn norcid to ulong |
| 652 | lim = get ibl 0 |
| 653 | n = ulong 0 |
| 654 | s = nextl 0 87 |
| 655 | while lt s lim bound 262144 |
| 656 | a = wf s 10 |
| 657 | if lt a eol s |
| 658 | if eq get ib a 49 |
| 659 | n = add n 1 |
| 660 | end |
| 661 | end |
| 662 | s = nextl add eol s 1 87 |
| 663 | end |
| 664 | ret n |
| 665 | end |
| 666 | note relword: the relation a..b as a plain phrase |
| 667 | fn relword a ulong b ulong to void |
| 668 | if feqt a b rsup |
| 669 | em psup |
| 670 | ret |
| 671 | end |
| 672 | if feqt a b rref |
| 673 | em pref |
| 674 | ret |
| 675 | end |
| 676 | if feqt a b rder |
| 677 | em pder |
| 678 | ret |
| 679 | end |
| 680 | if feqt a b rsby |
| 681 | em psby |
| 682 | ret |
| 683 | end |
| 684 | if feqt a b ridt |
| 685 | em pidt |
| 686 | ret |
| 687 | end |
| 688 | if feqt a b rpub |
| 689 | em ppub |
| 690 | ret |
| 691 | end |
| 692 | emh a b 64 |
| 693 | end |
| 694 | note ishttps: a..b starts with https:// |
| 695 | fn ishttps a ulong b ulong to bool |
| 696 | n = len phttps |
| 697 | if lt sub b a n |
| 698 | ret false |
| 699 | end |
| 700 | ret feqt a add a n phttps |
| 701 | end |
| 702 | text mjsfx ".json" |
| 703 | text tresp "/research/" |
| 704 | note head: the page head. ta..tb is the work title (empty for the hub), ja..jb its slug. |
| 705 | fn head ta ulong tb ulong ja ulong jb ulong to void |
| 706 | em h1 |
| 707 | if gt tb ta |
| 708 | emh ta tb 200 |
| 709 | else |
| 710 | em ititle |
| 711 | end |
| 712 | em h2 |
| 713 | if gt jb ja |
| 714 | em tresp |
| 715 | emh ja jb 64 |
| 716 | em mjsfx |
| 717 | else |
| 718 | em ijson |
| 719 | end |
| 720 | em h3 |
| 721 | end |
| 722 | note ---- the hub |
| 723 | fn workli s ulong to void |
| 724 | if lt majline s get ibl 0 |
| 725 | mawli s |
| 726 | ret |
| 727 | end |
| 728 | e = eol s |
| 729 | em w01 |
| 730 | emwh s 1 64 |
| 731 | em w02 |
| 732 | emwh s 12 400 |
| 733 | em w03 |
| 734 | emsubh s 83 600 |
| 735 | em w04 |
| 736 | emwh s 3 16 |
| 737 | em w05 |
| 738 | emwh s 4 32 |
| 739 | em w06 |
| 740 | emwh s 8 48 |
| 741 | nv = wf s 9 |
| 742 | if gt pnum nv fe nv e 1 |
| 743 | em w07 |
| 744 | emwh s 9 8 |
| 745 | em w08 |
| 746 | else |
| 747 | em w08b |
| 748 | end |
| 749 | emwh s 7 96 |
| 750 | em w02 |
| 751 | emwh s 7 96 |
| 752 | em w09 |
| 753 | oa = wf s 10 |
| 754 | on = false |
| 755 | if lt oa e |
| 756 | if eq get ib oa 49 |
| 757 | on = true |
| 758 | end |
| 759 | end |
| 760 | if on |
| 761 | em wok |
| 762 | else |
| 763 | em wno |
| 764 | end |
| 765 | em w10 |
| 766 | end |
| 767 | fn threads to void |
| 768 | lim = get ibl 0 |
| 769 | h = nextl 0 72 |
| 770 | while lt h lim bound 64 |
| 771 | he = eol h |
| 772 | ia = fld h he 1 |
| 773 | ib2 = fe ia he |
| 774 | em t01 |
| 775 | emh ia ib2 32 |
| 776 | em t02 |
| 777 | ta = fld h he 2 |
| 778 | emh ta fe ta he 120 |
| 779 | em t03 |
| 780 | ba = fld h he 3 |
| 781 | emh ba fe ba he 300 |
| 782 | em t04 |
| 783 | s = nextl 0 87 |
| 784 | while lt s lim bound 4096 |
| 785 | ws = wf s 2 |
| 786 | if feqr ws fe ws eol s ia ib2 |
| 787 | workli s |
| 788 | end |
| 789 | s = nextl add eol s 1 87 |
| 790 | end |
| 791 | em t05 |
| 792 | h = nextl add he 1 72 |
| 793 | end |
| 794 | end |
| 795 | fn edgeli s ulong to void |
| 796 | e = eol s |
| 797 | fa = fld s e 1 |
| 798 | fb = fe fa e |
| 799 | ra = fld s e 2 |
| 800 | ta = fld s e 3 |
| 801 | tb = fe ta e |
| 802 | wa = wline fa fb |
| 803 | wb = wline ta tb |
| 804 | if or ge wa get ibl 0 ge wb get ibl 0 |
| 805 | ret |
| 806 | end |
| 807 | em c02 |
| 808 | emh fa fb 64 |
| 809 | em w02 |
| 810 | emwh wa 12 400 |
| 811 | em c03 |
| 812 | relword ra fe ra e |
| 813 | em c04 |
| 814 | emh ta tb 64 |
| 815 | em w02 |
| 816 | emwh wb 12 400 |
| 817 | em c05 |
| 818 | end |
| 819 | fn edges to void |
| 820 | lim = get ibl 0 |
| 821 | if ge nextl 0 69 lim |
| 822 | ret |
| 823 | end |
| 824 | em c01 |
| 825 | s = nextl 0 69 |
| 826 | while lt s lim bound 4096 |
| 827 | edgeli s |
| 828 | s = nextl add eol s 1 69 |
| 829 | end |
| 830 | em c06 |
| 831 | end |
| 832 | fn index to void |
| 833 | maindex |
| 834 | end |
| 835 | note ---- one work |
| 836 | fn cite s ulong to void |
| 837 | e = eol s |
| 838 | emsubh s 67 400 |
| 839 | em tparo |
| 840 | da = wf s 3 |
| 841 | emh da cut da fe da e 4 4 |
| 842 | em tparc |
| 843 | emwh s 12 400 |
| 844 | em tdot |
| 845 | emwh s 5 200 |
| 846 | em tdot |
| 847 | em tdoiu |
| 848 | emwh s 6 96 |
| 849 | end |
| 850 | fn wvers s ulong to void |
| 851 | lim = get ibl 0 |
| 852 | a = wf s 1 |
| 853 | b = fe a eol s |
| 854 | em v01 |
| 855 | l = sline 0 86 a b |
| 856 | while lt l lim bound 4096 |
| 857 | ln = eol l |
| 858 | em v02 |
| 859 | va = fld l ln 4 |
| 860 | emh va fe va ln 64 |
| 861 | em v03 |
| 862 | da = fld l ln 3 |
| 863 | emh da fe da ln 16 |
| 864 | em v04 |
| 865 | ua = fld l ln 2 |
| 866 | emh ua fe ua ln 96 |
| 867 | em w02 |
| 868 | emh ua fe ua ln 96 |
| 869 | em v05 |
| 870 | l = sline add ln 1 86 a b |
| 871 | end |
| 872 | em v06 |
| 873 | end |
| 874 | note wedge1: relation line l, when it names the work a..b on either side. first: the section is not |
| 875 | note open yet. 1 when a row was written. |
| 876 | fn wedge1 l ulong a ulong b ulong first bool to ulong |
| 877 | lim = get ibl 0 |
| 878 | ln = eol l |
| 879 | fa = fld l ln 1 |
| 880 | fb = fe fa ln |
| 881 | ra = fld l ln 2 |
| 882 | ta = fld l ln 3 |
| 883 | tb = fe ta ln |
| 884 | if feqr fa fb a b |
| 885 | o = wline ta tb |
| 886 | if ge o lim |
| 887 | ret 0 |
| 888 | end |
| 889 | if first |
| 890 | em e01 |
| 891 | end |
| 892 | em e02 |
| 893 | relword ra fe ra ln |
| 894 | em c04 |
| 895 | emh ta tb 64 |
| 896 | em w02 |
| 897 | emwh o 12 400 |
| 898 | em c05 |
| 899 | ret 1 |
| 900 | end |
| 901 | if feqr ta tb a b |
| 902 | o = wline fa fb |
| 903 | if ge o lim |
| 904 | ret 0 |
| 905 | end |
| 906 | if first |
| 907 | em e01 |
| 908 | end |
| 909 | em e03 |
| 910 | emh fa fb 64 |
| 911 | em w02 |
| 912 | emwh o 12 400 |
| 913 | em e04 |
| 914 | relword ra fe ra ln |
| 915 | em e05 |
| 916 | ret 1 |
| 917 | end |
| 918 | ret 0 |
| 919 | end |
| 920 | note wlink1: outside link line l (https only). 1 when a row was written. |
| 921 | fn wlink1 l ulong first bool to ulong |
| 922 | ln = eol l |
| 923 | ra = fld l ln 2 |
| 924 | ua = fld l ln 3 |
| 925 | ub = fe ua ln |
| 926 | if not ishttps ua ub |
| 927 | ret 0 |
| 928 | end |
| 929 | if first |
| 930 | em e01 |
| 931 | end |
| 932 | em e06 |
| 933 | relword ra fe ra ln |
| 934 | em e07 |
| 935 | emh ua ub 400 |
| 936 | em w02 |
| 937 | emh ua ub 400 |
| 938 | em c05 |
| 939 | ret 1 |
| 940 | end |
| 941 | fn wedges s ulong to void |
| 942 | lim = get ibl 0 |
| 943 | a = wf s 1 |
| 944 | b = fe a eol s |
| 945 | n = ulong 0 |
| 946 | l = nextl 0 69 |
| 947 | while lt l lim bound 4096 |
| 948 | n = add n wedge1 l a b eq n 0 |
| 949 | l = nextl add eol l 1 69 |
| 950 | end |
| 951 | l = sline 0 76 a b |
| 952 | while lt l lim bound 4096 |
| 953 | n = add n wlink1 l eq n 0 |
| 954 | l = sline add eol l 1 76 a b |
| 955 | end |
| 956 | if gt n 0 |
| 957 | em tsend |
| 958 | end |
| 959 | end |
| 960 | fn wfiles s ulong to void |
| 961 | lim = get ibl 0 |
| 962 | a = wf s 1 |
| 963 | b = fe a eol s |
| 964 | l = sline 0 70 a b |
| 965 | if ge l lim |
| 966 | ret |
| 967 | end |
| 968 | em f01 |
| 969 | while lt l lim bound 4096 |
| 970 | ln = eol l |
| 971 | na = fld l ln 2 |
| 972 | ba = fld l ln 3 |
| 973 | ua = fld l ln 4 |
| 974 | ub = fe ua ln |
| 975 | if ishttps ua ub |
| 976 | em f02 |
| 977 | emh ua ub 400 |
| 978 | em w02 |
| 979 | emh na fe na ln 200 |
| 980 | em f03 |
| 981 | emn pnum ba fe ba ln |
| 982 | em f04 |
| 983 | end |
| 984 | l = sline add ln 1 70 a b |
| 985 | end |
| 986 | em tsend |
| 987 | end |
| 988 | fn wkeys s ulong to void |
| 989 | lim = get ibl 0 |
| 990 | a = wf s 1 |
| 991 | b = fe a eol s |
| 992 | l = sline 0 75 a b |
| 993 | if ge l lim |
| 994 | ret |
| 995 | end |
| 996 | em k01 |
| 997 | while lt l lim bound 4096 |
| 998 | ln = eol l |
| 999 | ka = fld l ln 2 |
| 1000 | em k02 |
| 1001 | emh ka fe ka ln 80 |
| 1002 | em k03 |
| 1003 | l = sline add ln 1 75 a b |
| 1004 | end |
| 1005 | em k04 |
| 1006 | end |
| 1007 | note thtitle: the title of thread id a..b |
| 1008 | fn thtitle a ulong b ulong to void |
| 1009 | lim = get ibl 0 |
| 1010 | h = sline 0 72 a b |
| 1011 | if lt h lim |
| 1012 | ta = fld h eol h 2 |
| 1013 | emh ta fe ta eol h 120 |
| 1014 | end |
| 1015 | end |
| 1016 | fn work s ulong to void |
| 1017 | if lt majline s get ibl 0 |
| 1018 | mawork s |
| 1019 | ret |
| 1020 | end |
| 1021 | e = eol s |
| 1022 | sa = wf s 1 |
| 1023 | sb = fe sa e |
| 1024 | ta = wf s 12 |
| 1025 | tb = fe ta e |
| 1026 | head ta tb sa sb |
| 1027 | em p01 |
| 1028 | ha = wf s 2 |
| 1029 | emh ha fe ha e 32 |
| 1030 | em w02 |
| 1031 | thtitle ha fe ha e |
| 1032 | em p02 |
| 1033 | emh ta tb 400 |
| 1034 | em p03 |
| 1035 | em k02 |
| 1036 | emsubh s 67 400 |
| 1037 | em w05 |
| 1038 | emwh s 3 16 |
| 1039 | em w05 |
| 1040 | emwh s 4 32 |
| 1041 | em w05 |
| 1042 | emwh s 5 200 |
| 1043 | em tspan |
| 1044 | em p04 |
| 1045 | emsubh s 83 600 |
| 1046 | em p05 |
| 1047 | emwh s 7 96 |
| 1048 | em p06 |
| 1049 | emh sa sb 64 |
| 1050 | em p07 |
| 1051 | emh sa sb 64 |
| 1052 | em p08 |
| 1053 | em p09 |
| 1054 | em pq1 |
| 1055 | emh ta cut ta tb 140 140 |
| 1056 | em pq2 |
| 1057 | em p10 |
| 1058 | emq ta cut ta tb 140 140 |
| 1059 | em p11 |
| 1060 | emq ta cut ta tb 140 140 |
| 1061 | em p12 |
| 1062 | em p13 |
| 1063 | emsubh s 65 12000 |
| 1064 | em p14 |
| 1065 | cite s |
| 1066 | em p15 |
| 1067 | emwh s 6 96 |
| 1068 | em w02 |
| 1069 | emwh s 6 96 |
| 1070 | em p16 |
| 1071 | emwh s 7 96 |
| 1072 | em w02 |
| 1073 | emwh s 7 96 |
| 1074 | em p17 |
| 1075 | emwh s 11 32 |
| 1076 | em p18 |
| 1077 | oa = wf s 10 |
| 1078 | on = false |
| 1079 | if lt oa e |
| 1080 | if eq get ib oa 49 |
| 1081 | on = true |
| 1082 | end |
| 1083 | end |
| 1084 | if on |
| 1085 | em pyes |
| 1086 | else |
| 1087 | em pnot |
| 1088 | end |
| 1089 | em p19 |
| 1090 | wvers s |
| 1091 | wedges s |
| 1092 | wfiles s |
| 1093 | wkeys s |
| 1094 | em pend |
| 1095 | em hfoot |
| 1096 | end |
| 1097 | note ---- JSON |
| 1098 | fn jwork s ulong to void |
| 1099 | e = eol s |
| 1100 | em jw1 |
| 1101 | emwj s 1 64 |
| 1102 | em jw2 |
| 1103 | emwj s 12 400 |
| 1104 | em jw3 |
| 1105 | emwj s 2 32 |
| 1106 | em jw4 |
| 1107 | emwj s 3 16 |
| 1108 | em jw5 |
| 1109 | emwj s 4 32 |
| 1110 | em jw6 |
| 1111 | emwj s 5 200 |
| 1112 | em jw7 |
| 1113 | emwj s 6 96 |
| 1114 | em jw8 |
| 1115 | emwj s 7 96 |
| 1116 | em jw9 |
| 1117 | emwj s 8 48 |
| 1118 | em jw10 |
| 1119 | nv = wf s 9 |
| 1120 | emn pnum nv fe nv e |
| 1121 | em jw11 |
| 1122 | oa = wf s 10 |
| 1123 | on = false |
| 1124 | if lt oa e |
| 1125 | if eq get ib oa 49 |
| 1126 | on = true |
| 1127 | end |
| 1128 | end |
| 1129 | if on |
| 1130 | em jtrue |
| 1131 | else |
| 1132 | em jfalse |
| 1133 | end |
| 1134 | em jw12 |
| 1135 | emwj s 11 32 |
| 1136 | em jw13 |
| 1137 | emsubj s 83 600 |
| 1138 | em jw14 |
| 1139 | emwj s 1 64 |
| 1140 | em jw15 |
| 1141 | end |
| 1142 | fn jedge l ulong to void |
| 1143 | ln = eol l |
| 1144 | fa = fld l ln 1 |
| 1145 | ra = fld l ln 2 |
| 1146 | ta = fld l ln 3 |
| 1147 | em je1 |
| 1148 | emj fa fe fa ln 64 |
| 1149 | em je2 |
| 1150 | emj ra fe ra ln 64 |
| 1151 | em je3 |
| 1152 | emj ta fe ta ln 64 |
| 1153 | em jw15 |
| 1154 | end |
| 1155 | fn json to void |
| 1156 | lim = get ibl 0 |
| 1157 | em j01 |
| 1158 | emoj kname 120 |
| 1159 | em j02 |
| 1160 | emoj korcid 32 |
| 1161 | em j03 |
| 1162 | emoj kalso 200 |
| 1163 | em j04 |
| 1164 | emoj kcheck 16 |
| 1165 | em j05 |
| 1166 | n = ulong 0 |
| 1167 | s = nextl 0 87 |
| 1168 | while lt s lim bound 4096 |
| 1169 | if gt n 0 |
| 1170 | emb 44 |
| 1171 | end |
| 1172 | jwork s |
| 1173 | n = add n 1 |
| 1174 | s = nextl add eol s 1 87 |
| 1175 | end |
| 1176 | em j06 |
| 1177 | n = ulong 0 |
| 1178 | h = nextl 0 72 |
| 1179 | while lt h lim bound 64 |
| 1180 | he = eol h |
| 1181 | if gt n 0 |
| 1182 | emb 44 |
| 1183 | end |
| 1184 | em jt1 |
| 1185 | a = fld h he 1 |
| 1186 | emj a fe a he 32 |
| 1187 | em jw2 |
| 1188 | a = fld h he 2 |
| 1189 | emj a fe a he 120 |
| 1190 | em jt2 |
| 1191 | a = fld h he 3 |
| 1192 | emj a fe a he 300 |
| 1193 | em jw15 |
| 1194 | n = add n 1 |
| 1195 | h = nextl add he 1 72 |
| 1196 | end |
| 1197 | em j07 |
| 1198 | n = ulong 0 |
| 1199 | l = nextl 0 69 |
| 1200 | while lt l lim bound 4096 |
| 1201 | if gt n 0 |
| 1202 | emb 44 |
| 1203 | end |
| 1204 | jedge l |
| 1205 | n = add n 1 |
| 1206 | l = nextl add eol l 1 69 |
| 1207 | end |
| 1208 | majextra |
| 1209 | em j08 |
| 1210 | end |
| 1211 | fn wjson s ulong to void |
| 1212 | lim = get ibl 0 |
| 1213 | a = wf s 1 |
| 1214 | b = fe a eol s |
| 1215 | em jx1 |
| 1216 | jwork s |
| 1217 | em jx2 |
| 1218 | emsubj s 67 400 |
| 1219 | em jx3 |
| 1220 | emsubj s 65 12000 |
| 1221 | em jx4 |
| 1222 | n = ulong 0 |
| 1223 | l = sline 0 75 a b |
| 1224 | while lt l lim bound 4096 |
| 1225 | ln = eol l |
| 1226 | if gt n 0 |
| 1227 | emb 44 |
| 1228 | end |
| 1229 | em jq |
| 1230 | k = fld l ln 2 |
| 1231 | emj k fe k ln 80 |
| 1232 | em jq |
| 1233 | n = add n 1 |
| 1234 | l = sline add ln 1 75 a b |
| 1235 | end |
| 1236 | em jx5 |
| 1237 | n = ulong 0 |
| 1238 | l = sline 0 86 a b |
| 1239 | while lt l lim bound 4096 |
| 1240 | ln = eol l |
| 1241 | if gt n 0 |
| 1242 | emb 44 |
| 1243 | end |
| 1244 | em jv1 |
| 1245 | k = fld l ln 2 |
| 1246 | emj k fe k ln 96 |
| 1247 | em jv2 |
| 1248 | k = fld l ln 3 |
| 1249 | emj k fe k ln 16 |
| 1250 | em jv3 |
| 1251 | k = fld l ln 4 |
| 1252 | emj k fe k ln 64 |
| 1253 | em jw15 |
| 1254 | n = add n 1 |
| 1255 | l = sline add ln 1 86 a b |
| 1256 | end |
| 1257 | em jx6 |
| 1258 | n = ulong 0 |
| 1259 | l = sline 0 70 a b |
| 1260 | while lt l lim bound 4096 |
| 1261 | ln = eol l |
| 1262 | u = wf l 4 |
| 1263 | if ishttps u fe u ln |
| 1264 | if gt n 0 |
| 1265 | emb 44 |
| 1266 | end |
| 1267 | em jf1 |
| 1268 | k = fld l ln 2 |
| 1269 | emj k fe k ln 200 |
| 1270 | em jf2 |
| 1271 | k = fld l ln 3 |
| 1272 | emn pnum k fe k ln |
| 1273 | em jf3 |
| 1274 | k = fld l ln 4 |
| 1275 | emj k fe k ln 400 |
| 1276 | em jw15 |
| 1277 | n = add n 1 |
| 1278 | end |
| 1279 | l = sline add ln 1 70 a b |
| 1280 | end |
| 1281 | em jx7 |
| 1282 | n = ulong 0 |
| 1283 | l = sline 0 76 a b |
| 1284 | while lt l lim bound 4096 |
| 1285 | ln = eol l |
| 1286 | u = wf l 3 |
| 1287 | if ishttps u fe u ln |
| 1288 | if gt n 0 |
| 1289 | emb 44 |
| 1290 | end |
| 1291 | em jl1 |
| 1292 | k = fld l ln 2 |
| 1293 | emj k fe k ln 64 |
| 1294 | em jl2 |
| 1295 | k = fld l ln 3 |
| 1296 | emj k fe k ln 400 |
| 1297 | em jw15 |
| 1298 | n = add n 1 |
| 1299 | end |
| 1300 | l = sline add ln 1 76 a b |
| 1301 | end |
| 1302 | em jx8 |
| 1303 | n = ulong 0 |
| 1304 | l = nextl 0 69 |
| 1305 | while lt l lim bound 4096 |
| 1306 | ln = eol l |
| 1307 | fa = fld l ln 1 |
| 1308 | ta = fld l ln 3 |
| 1309 | if or feqr fa fe fa ln a b feqr ta fe ta ln a b |
| 1310 | if gt n 0 |
| 1311 | emb 44 |
| 1312 | end |
| 1313 | jedge l |
| 1314 | n = add n 1 |
| 1315 | end |
| 1316 | l = nextl add ln 1 69 |
| 1317 | end |
| 1318 | if lt majline s lim |
| 1319 | majwext s |
| 1320 | end |
| 1321 | em j08 |
| 1322 | end |
| 1323 | note ---- BibTeX, the agent guide, the slug list |
| 1324 | fn bibone s ulong to void |
| 1325 | e = eol s |
| 1326 | ka = wf s 4 |
| 1327 | if feqt ka fe ka e kart |
| 1328 | em b01a |
| 1329 | else |
| 1330 | em b01 |
| 1331 | end |
| 1332 | emwh s 1 64 |
| 1333 | em b02 |
| 1334 | v = subv s 66 |
| 1335 | if lt v get ibl 0 |
| 1336 | emx v eol v 400 |
| 1337 | else |
| 1338 | v = subv s 67 |
| 1339 | if lt v get ibl 0 |
| 1340 | emx v eol v 400 |
| 1341 | end |
| 1342 | end |
| 1343 | em b03 |
| 1344 | ta = wf s 12 |
| 1345 | emx ta fe ta e 400 |
| 1346 | em b04 |
| 1347 | da = wf s 3 |
| 1348 | emn pnum da cut da fe da e 4 |
| 1349 | em b05 |
| 1350 | va = wf s 5 |
| 1351 | emx va fe va e 200 |
| 1352 | em b06 |
| 1353 | va = wf s 8 |
| 1354 | emx va fe va e 48 |
| 1355 | em b07 |
| 1356 | va = wf s 6 |
| 1357 | emx va fe va e 96 |
| 1358 | em b08 |
| 1359 | emx va fe va e 96 |
| 1360 | em b09 |
| 1361 | end |
| 1362 | fn bib to void |
| 1363 | lim = get ibl 0 |
| 1364 | s = nextl 0 87 |
| 1365 | while lt s lim bound 4096 |
| 1366 | bibone s |
| 1367 | s = nextl add eol s 1 87 |
| 1368 | end |
| 1369 | end |
| 1370 | fn txt to void |
| 1371 | lim = get ibl 0 |
| 1372 | em x01 |
| 1373 | emor kname 120 |
| 1374 | em x02 |
| 1375 | emor korcid 32 |
| 1376 | em x03 |
| 1377 | s = nextl 0 87 |
| 1378 | while lt s lim bound 4096 |
| 1379 | e = eol s |
| 1380 | em x04 |
| 1381 | a = wf s 12 |
| 1382 | emr a fe a e 400 |
| 1383 | em x05 |
| 1384 | a = wf s 3 |
| 1385 | emr a fe a e 16 |
| 1386 | em x06 |
| 1387 | a = wf s 4 |
| 1388 | emr a fe a e 32 |
| 1389 | em x07 |
| 1390 | a = wf s 6 |
| 1391 | emr a fe a e 96 |
| 1392 | em x08 |
| 1393 | a = wf s 1 |
| 1394 | emr a fe a e 64 |
| 1395 | em x05 |
| 1396 | v = subv s 83 |
| 1397 | if lt v lim |
| 1398 | emr v eol v 600 |
| 1399 | end |
| 1400 | s = nextl add e 1 87 |
| 1401 | end |
| 1402 | emb 10 |
| 1403 | end |
| 1404 | fn slugs to void |
| 1405 | lim = get ibl 0 |
| 1406 | s = nextl 0 87 |
| 1407 | while lt s lim bound 4096 |
| 1408 | e = eol s |
| 1409 | a = wf s 1 |
| 1410 | if slugok a fe a e |
| 1411 | emr a fe a e 64 |
| 1412 | emb 10 |
| 1413 | end |
| 1414 | s = nextl add e 1 87 |
| 1415 | end |
| 1416 | end |
| 1417 | fn css to void |
| 1418 | em q01 |
| 1419 | em q02 |
| 1420 | em q03 |
| 1421 | em q04 |
| 1422 | em q05 |
| 1423 | em q06 |
| 1424 | em q07 |
| 1425 | em q08 |
| 1426 | em q09 |
| 1427 | em q10 |
| 1428 | em q11 |
| 1429 | em q12 |
| 1430 | em q13 |
| 1431 | em q14 |
| 1432 | em q15 |
| 1433 | em q16 |
| 1434 | em q17 |
| 1435 | em q18 |
| 1436 | em q19 |
| 1437 | em q20 |
| 1438 | em q21 |
| 1439 | em q22 |
| 1440 | em q23 |
| 1441 | em q24 |
| 1442 | em q25 |
| 1443 | em q26 |
| 1444 | em q27 |
| 1445 | em q28 |
| 1446 | em q29 |
| 1447 | em q30 |
| 1448 | em q31 |
| 1449 | end |
| 1450 | note ---- the filter |
| 1451 | fn rdin to void |
| 1452 | one = new uchar 1 0 |
| 1453 | n = ulong 0 |
| 1454 | k = long 1 |
| 1455 | while gt k 0 bound 262144 |
| 1456 | if eq n 262143 |
| 1457 | k = read 0 one 0 1 |
| 1458 | if ne k 0 |
| 1459 | exit 4 |
| 1460 | end |
| 1461 | break |
| 1462 | end |
| 1463 | k = read 0 ib n sub 262143 n |
| 1464 | if gt k 0 |
| 1465 | n = add n ulong k |
| 1466 | end |
| 1467 | end |
| 1468 | if lt k 0 |
| 1469 | exit 4 |
| 1470 | end |
| 1471 | put ibl 0 n |
| 1472 | end |
| 1473 | fn flush to int |
| 1474 | n = get obl 0 |
| 1475 | o = ulong 0 |
| 1476 | while lt o n bound 2097152 |
| 1477 | k = write 1 ob o sub n o |
| 1478 | if le k 0 |
| 1479 | ret 1 |
| 1480 | end |
| 1481 | o = add o ulong k |
| 1482 | end |
| 1483 | ret 0 |
| 1484 | end |
| 1485 | fn main to int |
| 1486 | if gt argcnt 1 |
| 1487 | ret maargs |
| 1488 | end |
| 1489 | rdin |
| 1490 | mamraw |
| 1491 | if not maok |
| 1492 | ret 4 |
| 1493 | end |
| 1494 | lim = get ibl 0 |
| 1495 | m = nextl 0 77 |
| 1496 | if ne m 0 |
| 1497 | ret 2 |
| 1498 | end |
| 1499 | me = eol m |
| 1500 | a = fld m me 1 |
| 1501 | b = fe a me |
| 1502 | sa = fld m me 2 |
| 1503 | sb = fe sa me |
| 1504 | if true |
| 1505 | r = mamode a b sa sb |
| 1506 | if ne r 99 |
| 1507 | ret r |
| 1508 | end |
| 1509 | end |
| 1510 | if feqt a b mcss |
| 1511 | css |
| 1512 | ret flush |
| 1513 | end |
| 1514 | if feqt a b mindex |
| 1515 | index |
| 1516 | ret flush |
| 1517 | end |
| 1518 | if feqt a b mjson |
| 1519 | json |
| 1520 | ret flush |
| 1521 | end |
| 1522 | if feqt a b mbib |
| 1523 | bib |
| 1524 | ret flush |
| 1525 | end |
| 1526 | if feqt a b mtxt |
| 1527 | txt |
| 1528 | ret flush |
| 1529 | end |
| 1530 | if feqt a b mslugs |
| 1531 | slugs |
| 1532 | ret flush |
| 1533 | end |
| 1534 | if not or or feqt a b mwork feqt a b mwjson feqt a b mwbib |
| 1535 | ret 2 |
| 1536 | end |
| 1537 | if not slugok sa sb |
| 1538 | ret 3 |
| 1539 | end |
| 1540 | s = wline sa sb |
| 1541 | if ge s lim |
| 1542 | ret 3 |
| 1543 | end |
| 1544 | if feqt a b mwork |
| 1545 | work s |
| 1546 | ret flush |
| 1547 | end |
| 1548 | if feqt a b mwjson |
| 1549 | wjson s |
| 1550 | ret flush |
| 1551 | end |
| 1552 | if feqt a b mwbib |
| 1553 | bibone s |
| 1554 | ret flush |
| 1555 | end |
| 1556 | ret 2 |
| 1557 | end |
| 1558 | note ---- multi-author registry. O remains the legacy author; U is id,name,orcid,DID,via,date. |
| 1559 | note The U and P DID is the requester: the key asked for public Zenodo metadata or brought a repository. |
| 1560 | note A requester gains no ownership; pages and JSON never present that key as an author. |
| 1561 | note J joins work to U; P is slug,how,DID,date,source,open-text. Missing P denies foreign text. |
| 1562 | note Modes: merge converts one foreign catalog; authors lists ids; author renders an id. |
| 1563 | note add and doi render information pages; foreign lists foreign slugs; corpus lists slug<TAB>title<TAB>selected-text-sha (foreign only). |
| 1564 | note quote reads foreign extracted text and prefixes its lines so they cannot become corpus headers. |
| 1565 | note Exit 4 refuses malformed/ambiguous registry data or a full input/output buffer. |
| 1566 | text mamrg "merge" |
| 1567 | text maal "authors" |
| 1568 | text maau "author" |
| 1569 | text maad "add" |
| 1570 | text mado "doi" |
| 1571 | text mafo "foreign" |
| 1572 | text maco "corpus" |
| 1573 | text maqu "quote" |
| 1574 | text maid "id" |
| 1575 | text maby "added-by" |
| 1576 | text mavia "via" |
| 1577 | text maz "zenodo" |
| 1578 | text mar "radicle" |
| 1579 | text madid "did:key:z" |
| 1580 | text marad "rad:z" |
| 1581 | text mazen "https://zenodo.org/records/" |
| 1582 | text maself "drakestapleton" |
| 1583 | text mafoot "</main><footer class='foot'><p>DOIs are minted by Zenodo. The research registry records the source and the key that requested or brought each record; that key gains no ownership and is not shown to be an author. No scripts run on this page.</p><p><a href='/research.json'>JSON</a><a href='/research.bib'>BibTeX</a><a href='/research.txt'>Guide for agents</a></p></footer></body></html>\n" |
| 1584 | text mahero "<section class='hero'><p class='eyebrow'>Research</p><h1>Ask the research.</h1><p class='sub'>Published work, connected by its sources. The agent answers from the open full text in this collection and names the papers it used. Some records contain metadata only.</p><p class='acts'><a class='btn' href='/research/add'>Add your work</a><a class='btn ghost' href='/research/doi'>Get a DOI</a></p>" |
| 1585 | text maas "<section class='card'><h2>Authors</h2><ul class='edges'>" |
| 1586 | text maalink "<li><a href='/research/authors/" |
| 1587 | text mawsec "<section class='card'><h2>Works</h2><ol class='works'>" |
| 1588 | text maend "</ol></section>\n" |
| 1589 | text mauhead "<section class='card'><p class='eyebrow'>Author</p><h1>" |
| 1590 | text mauid "</h1><p class='meta'>Author ID: " |
| 1591 | text maun "</p><p class='meta'>Added by " |
| 1592 | text maureq "</p><p class='meta'>Requester: key " |
| 1593 | text mauvia ". Source: " |
| 1594 | text maucheck ". Checked: " |
| 1595 | text mauclose "</p></section>\n" |
| 1596 | text mabyline "<p class='by'><a href='/research/authors/" |
| 1597 | text maprov "<section class='card'><h2>Source</h2><p>Added through " |
| 1598 | text mapkey " by key " |
| 1599 | note mashelf: records whose source is the retired network (field "radicle") came through the shelf |
| 1600 | text mashelf "the shelf" |
| 1601 | text maprovz "<section class='card'><h2>Source</h2><p>Public metadata from " |
| 1602 | text mapreq ". Requester: key " |
| 1603 | text mapdate ". Checked " |
| 1604 | text mapsrc ". Source: " |
| 1605 | text maptext "</p><p>Open full text may be included in the agent corpus.</p></section>\n" |
| 1606 | text mapmeta "<section class='card'><p>Metadata only. The agent does not use this work as full-text evidence.</p></section>\n" |
| 1607 | text mazdisc "<section class='card'><h2>Zenodo records</h2><p>Zenodo records listed here are public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to the person named on this page.</p></section>\n" |
| 1608 | text mazwork "<section class='card'><h2>Zenodo record</h2><p>This Zenodo record is public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to a person named on this page.</p></section>\n" |
| 1609 | text mapttl "<article class='work'><p class='eyebrow'><a href='/research'>Research</a></p><h1>" |
| 1610 | text mapacts "</p><p class='acts'><a class='btn ghost' href='/research/" |
| 1611 | text mapdoi "<p class='acts'><a class='btn' href='https://doi.org/" |
| 1612 | text mapdoi2 "'>Read at the DOI</a></p>" |
| 1613 | text mapclose "</a></p>" |
| 1614 | text maplead "<p class='lead'>" |
| 1615 | text mapp "</p>" |
| 1616 | text maquote "> " |
| 1617 | text maadd "<section class='hero'><p class='eyebrow'>Research</p><h1>Add your work</h1><p class='sub'>Sign in with your key, then add an ORCID iD or a repository you brought to the shelf.</p><p><a class='btn' href='/research/add/'>Open the submission form</a></p></section><section class='card'><h2>From Zenodo</h2><p>Give an ORCID iD. The sync worker checks public Zenodo records whose creators name that iD. The records are public metadata, and the page labels the key that asked for them as the requester. Requesting gives that key no ownership, and an ORCID match is not proof that the key belongs to that person.</p></section><section class='card'><h2>From a repository</h2><p>Bringing a repository to the shelf is closed until Interplane's own store accepts it. Include .zenodo.json, a license file, and paper.md, paper.txt or paper.pdf at its root. The worker checks the shelf entry and metadata before listing the work.</p></section><section class='card'><h2>What is shown</h2><p>The registry keeps the source, the key that requested or brought it and the check date. Requesting a record gives the key no ownership of it. Full text joins the question corpus only when its recorded license permits it. Metadata-only records can still have pages. The operator can remove a record, author or key, and a withdrawn shelf entry is removed on the next sync.</p></section>" |
| 1618 | text madoi "<section class='hero'><p class='eyebrow'>Research</p><h1>Get a DOI</h1><p class='sub'>Zenodo mints the DOI. The local tool prepares a draft; you decide whether to publish.</p></section><section class='card'><h2>Prepare a repository</h2><p>At its root, include a nonempty LICENSE file, a PDF, and .zenodo.json with title, creators (name for each), description, license, upload_type and publication_type. Check those fields and the paper before uploading. A repository that already has a DOI is refused to avoid a duplicate deposit.</p></section><section class='card'><h2>Run on your own machine</h2><p>From the Interplane forge repository root, run <code>sh tools/doi/build.sh</code>. Keep ZENODO_TOKEN in your local shell environment, outside the repository. Do not send it to Interplane.</p><p>Try the sandbox: <code>sh tools/doi/doi.sh /path/to/paper-repo</code>. To make a real deposit, use <code>sh tools/doi/doi.sh /path/to/paper-repo --production</code>. An optional <code>--source /path/to/source.tar.gz</code> uploads a source archive with the PDF.</p></section><section class='card'><h2>Review before publishing</h2><p>The tool creates a draft, prints the reserved DOI, adds it to .zenodo.json while preserving the other metadata, and uploads the files. Review the draft on <a href='https://zenodo.org/uploads'>Zenodo</a>. Only an exact <code>yes</code> at the local terminal publishes it. Another answer, or no terminal, leaves an unpublished draft. A reserved DOI is not a published record.</p></section><section class='card'><h2>Link the published work</h2><p>After publication, commit the updated metadata and <a href='/research/add'>add your work</a>. Interplane links the published record; it does not mint a second DOI.</p></section>" |
| 1619 | text majas "],\"authors\":[{\"id\":\"drakestapleton\",\"name\":\"" |
| 1620 | text maju "{\"id\":\"" |
| 1621 | text majname "\",\"name\":\"" |
| 1622 | text majorc "\",\"orcid\":\"" |
| 1623 | text majd "\",\"added_by\":\"" |
| 1624 | text majvia "\",\"via\":\"" |
| 1625 | text majdate "\",\"checked\":\"" |
| 1626 | text majreq "\",\"requester\":\"" |
| 1627 | text majrz "\",\"requester_role\":\"requested public Zenodo metadata; no ownership or identity claim" |
| 1628 | text majrr "\",\"requester_role\":\"brought the repository to the shelf; not verified" |
| 1629 | text majlinks "],\"work_authors\":[" |
| 1630 | text majwork "{\"slug\":\"" |
| 1631 | text majids "\",\"author_ids\":[\"" |
| 1632 | text majend "\"]}" |
| 1633 | fn maprefix a ulong b ulong t view uchar * to bool |
| 1634 | if lt sub b a len t |
| 1635 | ret false |
| 1636 | end |
| 1637 | ret feqt a add a len t t |
| 1638 | end |
| 1639 | fn madate a ulong b ulong to bool |
| 1640 | if ne sub b a 10 |
| 1641 | ret false |
| 1642 | end |
| 1643 | for i ulong 10 |
| 1644 | c = get ib add a i |
| 1645 | if or eq i 4 eq i 7 |
| 1646 | if ne c 45 |
| 1647 | ret false |
| 1648 | end |
| 1649 | else |
| 1650 | if not and ge c 48 le c 57 |
| 1651 | ret false |
| 1652 | end |
| 1653 | end |
| 1654 | end |
| 1655 | ret true |
| 1656 | end |
| 1657 | fn matype s ulong k ulong to bool |
| 1658 | a = wf s k |
| 1659 | b = fe a eol s |
| 1660 | ret or feqt a b maz feqt a b mar |
| 1661 | end |
| 1662 | fn maval s ulong to bool |
| 1663 | if not matype s 5 |
| 1664 | ret false |
| 1665 | end |
| 1666 | a = wf s 1 |
| 1667 | b = fe a eol s |
| 1668 | if not slugok a b |
| 1669 | ret false |
| 1670 | end |
| 1671 | if feqt a b maself |
| 1672 | ret false |
| 1673 | end |
| 1674 | a = wf s 4 |
| 1675 | if not maprefix a fe a eol s madid |
| 1676 | ret false |
| 1677 | end |
| 1678 | a = wf s 6 |
| 1679 | ret madate a fe a eol s |
| 1680 | end |
| 1681 | fn majline s ulong to ulong |
| 1682 | a = wf s 1 |
| 1683 | ret sline 0 74 a fe a eol s |
| 1684 | end |
| 1685 | fn mauline s ulong to ulong |
| 1686 | j = majline s |
| 1687 | if ge j get ibl 0 |
| 1688 | ret get ibl 0 |
| 1689 | end |
| 1690 | a = wf j 2 |
| 1691 | ret sline 0 85 a fe a eol j |
| 1692 | end |
| 1693 | fn mapline s ulong to ulong |
| 1694 | a = wf s 1 |
| 1695 | ret sline 0 80 a fe a eol s |
| 1696 | end |
| 1697 | fn matext s ulong to bool |
| 1698 | p = mapline s |
| 1699 | if ge p get ibl 0 |
| 1700 | ret false |
| 1701 | end |
| 1702 | a = wf p 6 |
| 1703 | b = fe a eol p |
| 1704 | if ne sub b a 1 |
| 1705 | ret false |
| 1706 | end |
| 1707 | ret eq get ib a 49 |
| 1708 | end |
| 1709 | note maok rejects ambiguous ids/slugs and broken joins before a document or path list is emitted. |
| 1710 | fn maok to bool |
| 1711 | lim = get ibl 0 |
| 1712 | s = nextl 0 87 |
| 1713 | while lt s lim bound 4096 |
| 1714 | a = wf s 1 |
| 1715 | b = fe a eol s |
| 1716 | if not slugok a b |
| 1717 | ret false |
| 1718 | end |
| 1719 | if ne wline a b s |
| 1720 | ret false |
| 1721 | end |
| 1722 | s = nextl add eol s 1 87 |
| 1723 | end |
| 1724 | s = nextl 0 85 |
| 1725 | while lt s lim bound 4096 |
| 1726 | if not maval s |
| 1727 | ret false |
| 1728 | end |
| 1729 | a = wf s 1 |
| 1730 | b = fe a eol s |
| 1731 | if ne sline 0 85 a b s |
| 1732 | ret false |
| 1733 | end |
| 1734 | s = nextl add eol s 1 85 |
| 1735 | end |
| 1736 | s = nextl 0 74 |
| 1737 | while lt s lim bound 4096 |
| 1738 | a = wf s 1 |
| 1739 | b = fe a eol s |
| 1740 | if ge wline a b lim |
| 1741 | ret false |
| 1742 | end |
| 1743 | if ne sline 0 74 a b s |
| 1744 | ret false |
| 1745 | end |
| 1746 | a = wf s 2 |
| 1747 | if ge sline 0 85 a fe a eol s lim |
| 1748 | ret false |
| 1749 | end |
| 1750 | s = nextl add eol s 1 74 |
| 1751 | end |
| 1752 | s = nextl 0 71 |
| 1753 | while lt s lim bound 4096 |
| 1754 | if not magvalid s |
| 1755 | ret false |
| 1756 | end |
| 1757 | s = nextl add eol s 1 71 |
| 1758 | end |
| 1759 | s = nextl 0 84 |
| 1760 | while lt s lim bound 4096 |
| 1761 | if not matvalid s |
| 1762 | ret false |
| 1763 | end |
| 1764 | s = nextl add eol s 1 84 |
| 1765 | end |
| 1766 | s = nextl 0 80 |
| 1767 | while lt s lim bound 4096 |
| 1768 | if not mapvalid s |
| 1769 | ret false |
| 1770 | end |
| 1771 | s = nextl add eol s 1 80 |
| 1772 | end |
| 1773 | ret true |
| 1774 | end |
| 1775 | fn mapvalid s ulong to bool |
| 1776 | e = eol s |
| 1777 | a = wf s 1 |
| 1778 | b = fe a e |
| 1779 | if ge wline a b get ibl 0 |
| 1780 | ret false |
| 1781 | end |
| 1782 | if ne sline 0 80 a b s |
| 1783 | ret false |
| 1784 | end |
| 1785 | if not matype s 2 |
| 1786 | ret false |
| 1787 | end |
| 1788 | a = wf s 3 |
| 1789 | if not maprefix a fe a e madid |
| 1790 | ret false |
| 1791 | end |
| 1792 | a = wf s 4 |
| 1793 | if not madate a fe a e |
| 1794 | ret false |
| 1795 | end |
| 1796 | a = wf s 5 |
| 1797 | b = fe a e |
| 1798 | if not or maprefix a b marad maprefix a b mazen |
| 1799 | ret false |
| 1800 | end |
| 1801 | a = wf s 6 |
| 1802 | if ne sub fe a e a 1 |
| 1803 | ret false |
| 1804 | end |
| 1805 | ret or eq get ib a 48 eq get ib a 49 |
| 1806 | end |
| 1807 | fn maraw a ulong b ulong to void |
| 1808 | i = a |
| 1809 | while lt i b bound 262144 |
| 1810 | emb get ib i |
| 1811 | i = add i 1 |
| 1812 | end |
| 1813 | end |
| 1814 | fn maoval t view uchar * cap ulong to void |
| 1815 | a = oval t |
| 1816 | if lt a get ibl 0 |
| 1817 | emr a eol a cap |
| 1818 | end |
| 1819 | end |
| 1820 | fn mamerge to int |
| 1821 | if not maovok |
| 1822 | ret 4 |
| 1823 | end |
| 1824 | lim = get ibl 0 |
| 1825 | a = oval maid |
| 1826 | b = eol a |
| 1827 | if not slugok a b |
| 1828 | ret 4 |
| 1829 | end |
| 1830 | if feqt a b maself |
| 1831 | ret 4 |
| 1832 | end |
| 1833 | if or lt nextl 0 85 lim lt nextl 0 74 lim |
| 1834 | ret 4 |
| 1835 | end |
| 1836 | emb 85 |
| 1837 | emb 9 |
| 1838 | emr a b 64 |
| 1839 | emb 9 |
| 1840 | maoval kname 120 |
| 1841 | emb 9 |
| 1842 | maoval korcid 32 |
| 1843 | emb 9 |
| 1844 | maoval maby 128 |
| 1845 | emb 9 |
| 1846 | maoval mavia 16 |
| 1847 | emb 9 |
| 1848 | maoval kcheck 10 |
| 1849 | emb 10 |
| 1850 | s = add eol 0 1 |
| 1851 | while lt s lim bound 262144 |
| 1852 | e = eol s |
| 1853 | ty = get ib s |
| 1854 | if and ne ty 79 ne ty 77 |
| 1855 | maraw s e |
| 1856 | emb 10 |
| 1857 | if eq ty 87 |
| 1858 | emb 74 |
| 1859 | emb 9 |
| 1860 | v = wf s 1 |
| 1861 | emr v fe v e 64 |
| 1862 | emb 9 |
| 1863 | emr a b 64 |
| 1864 | emb 10 |
| 1865 | end |
| 1866 | end |
| 1867 | s = add e 1 |
| 1868 | end |
| 1869 | ret flush |
| 1870 | end |
| 1871 | fn mauthors to void |
| 1872 | em maself |
| 1873 | emb 10 |
| 1874 | s = nextl 0 85 |
| 1875 | while lt s get ibl 0 bound 4096 |
| 1876 | emwh s 1 64 |
| 1877 | emb 10 |
| 1878 | s = nextl add eol s 1 85 |
| 1879 | end |
| 1880 | end |
| 1881 | fn malink s ulong to void |
| 1882 | em maalink |
| 1883 | if ge s get ibl 0 |
| 1884 | em maself |
| 1885 | em w02 |
| 1886 | emo kname 120 |
| 1887 | else |
| 1888 | emwh s 1 64 |
| 1889 | em w02 |
| 1890 | emwh s 2 120 |
| 1891 | end |
| 1892 | em c05 |
| 1893 | end |
| 1894 | fn maindex to void |
| 1895 | head 0 0 0 0 |
| 1896 | em mahero |
| 1897 | em iform |
| 1898 | em itry |
| 1899 | em maas |
| 1900 | malink get ibl 0 |
| 1901 | s = nextl 0 85 |
| 1902 | while lt s get ibl 0 bound 4096 |
| 1903 | malink s |
| 1904 | s = nextl add eol s 1 85 |
| 1905 | end |
| 1906 | em tsend |
| 1907 | threads |
| 1908 | em mawsec |
| 1909 | s = nextl 0 87 |
| 1910 | while lt s get ibl 0 bound 4096 |
| 1911 | if lt majline s get ibl 0 |
| 1912 | workli s |
| 1913 | end |
| 1914 | s = nextl add eol s 1 87 |
| 1915 | end |
| 1916 | em maend |
| 1917 | edges |
| 1918 | em mafoot |
| 1919 | end |
| 1920 | fn maauthor a ulong b ulong to int |
| 1921 | u = sline 0 85 a b |
| 1922 | legacy = feqt a b maself |
| 1923 | if and not legacy ge u get ibl 0 |
| 1924 | ret 3 |
| 1925 | end |
| 1926 | head 0 0 0 0 |
| 1927 | em mauhead |
| 1928 | if legacy |
| 1929 | emo kname 120 |
| 1930 | else |
| 1931 | emwh u 2 120 |
| 1932 | end |
| 1933 | em mauid |
| 1934 | emh a b 64 |
| 1935 | zen = false |
| 1936 | if legacy |
| 1937 | em maucheck |
| 1938 | emo kcheck 16 |
| 1939 | else |
| 1940 | vz = wf u 5 |
| 1941 | zen = feqt vz fe vz eol u maz |
| 1942 | if zen |
| 1943 | em maureq |
| 1944 | else |
| 1945 | em maun |
| 1946 | end |
| 1947 | emwh u 4 128 |
| 1948 | em mauvia |
| 1949 | emwh u 5 16 |
| 1950 | em maucheck |
| 1951 | emwh u 6 10 |
| 1952 | end |
| 1953 | em mauclose |
| 1954 | maorcid u legacy |
| 1955 | em mawsec |
| 1956 | s = nextl 0 87 |
| 1957 | while lt s get ibl 0 bound 4096 |
| 1958 | j = majline s |
| 1959 | same = and legacy ge j get ibl 0 |
| 1960 | if lt j get ibl 0 |
| 1961 | v = wf j 2 |
| 1962 | same = feqr v fe v eol j a b |
| 1963 | end |
| 1964 | if same |
| 1965 | workli s |
| 1966 | if mazrec s |
| 1967 | zen = true |
| 1968 | end |
| 1969 | end |
| 1970 | s = nextl add eol s 1 87 |
| 1971 | end |
| 1972 | em maend |
| 1973 | if zen |
| 1974 | em mazdisc |
| 1975 | end |
| 1976 | em mafoot |
| 1977 | ret flush |
| 1978 | end |
| 1979 | fn mazrec s ulong to bool |
| 1980 | p = mapline s |
| 1981 | if ge p get ibl 0 |
| 1982 | ret false |
| 1983 | end |
| 1984 | a = wf p 2 |
| 1985 | ret feqt a fe a eol p maz |
| 1986 | end |
| 1987 | fn maproven s ulong to void |
| 1988 | p = mapline s |
| 1989 | if ge p get ibl 0 |
| 1990 | em mapmeta |
| 1991 | ret |
| 1992 | end |
| 1993 | zen = mazrec s |
| 1994 | if zen |
| 1995 | em maprovz |
| 1996 | emwh p 2 16 |
| 1997 | em mapreq |
| 1998 | else |
| 1999 | em maprov |
| 2000 | a = wf p 2 |
| 2001 | if feqt a fe a eol p mar |
| 2002 | em mashelf |
| 2003 | else |
| 2004 | emwh p 2 16 |
| 2005 | end |
| 2006 | em mapkey |
| 2007 | end |
| 2008 | emwh p 3 128 |
| 2009 | em mapdate |
| 2010 | emwh p 4 10 |
| 2011 | em mapsrc |
| 2012 | emwh p 5 400 |
| 2013 | if matext s |
| 2014 | em maptext |
| 2015 | else |
| 2016 | em mauclose |
| 2017 | em mapmeta |
| 2018 | end |
| 2019 | if zen |
| 2020 | em mazwork |
| 2021 | end |
| 2022 | end |
| 2023 | fn mawork s ulong to void |
| 2024 | ta = wf s 12 |
| 2025 | sa = wf s 1 |
| 2026 | head ta fe ta eol s sa fe sa eol s |
| 2027 | em mapttl |
| 2028 | emwh s 12 400 |
| 2029 | em p03 |
| 2030 | emsubh s 67 400 |
| 2031 | em mapacts |
| 2032 | emwh s 1 64 |
| 2033 | em p07 |
| 2034 | emwh s 1 64 |
| 2035 | em p08 |
| 2036 | u = mauline s |
| 2037 | em mabyline |
| 2038 | emwh u 1 64 |
| 2039 | em w02 |
| 2040 | emwh u 2 120 |
| 2041 | em mapclose |
| 2042 | em maplead |
| 2043 | emsubh s 83 600 |
| 2044 | em mapp |
| 2045 | em p13 |
| 2046 | emsubh s 65 12000 |
| 2047 | em p14 |
| 2048 | cite s |
| 2049 | em mauclose |
| 2050 | v = wf s 7 |
| 2051 | if gt fe v eol s v |
| 2052 | em mapdoi |
| 2053 | emwh s 7 96 |
| 2054 | em mapdoi2 |
| 2055 | end |
| 2056 | maproven s |
| 2057 | magsnap s |
| 2058 | wvers s |
| 2059 | wedges s |
| 2060 | wfiles s |
| 2061 | wkeys s |
| 2062 | em pend |
| 2063 | em mafoot |
| 2064 | end |
| 2065 | fn majextra to void |
| 2066 | em majas |
| 2067 | emoj kname 120 |
| 2068 | em majorc |
| 2069 | emoj korcid 32 |
| 2070 | em jw15 |
| 2071 | s = nextl 0 85 |
| 2072 | while lt s get ibl 0 bound 4096 |
| 2073 | emb 44 |
| 2074 | em maju |
| 2075 | emwj s 1 64 |
| 2076 | em majname |
| 2077 | emwj s 2 120 |
| 2078 | em majorc |
| 2079 | emwj s 3 32 |
| 2080 | em majd |
| 2081 | emwj s 4 128 |
| 2082 | em majvia |
| 2083 | emwj s 5 16 |
| 2084 | em majdate |
| 2085 | emwj s 6 10 |
| 2086 | em majreq |
| 2087 | emwj s 4 128 |
| 2088 | vz = wf s 5 |
| 2089 | if feqt vz fe vz eol s maz |
| 2090 | em majrz |
| 2091 | else |
| 2092 | em majrr |
| 2093 | end |
| 2094 | em jw15 |
| 2095 | s = nextl add eol s 1 85 |
| 2096 | end |
| 2097 | em majlinks |
| 2098 | s = nextl 0 87 |
| 2099 | n = ulong 0 |
| 2100 | while lt s get ibl 0 bound 4096 |
| 2101 | if gt n 0 |
| 2102 | emb 44 |
| 2103 | end |
| 2104 | em majwork |
| 2105 | emwj s 1 64 |
| 2106 | em majids |
| 2107 | u = mauline s |
| 2108 | if lt u get ibl 0 |
| 2109 | emwj u 1 64 |
| 2110 | else |
| 2111 | em maself |
| 2112 | end |
| 2113 | em majend |
| 2114 | n = add n 1 |
| 2115 | s = nextl add eol s 1 87 |
| 2116 | end |
| 2117 | end |
| 2118 | fn malists corpus bool to void |
| 2119 | s = nextl 0 87 |
| 2120 | while lt s get ibl 0 bound 4096 |
| 2121 | foreign = lt majline s get ibl 0 |
| 2122 | show = foreign |
| 2123 | if corpus |
| 2124 | show = or not foreign matext s |
| 2125 | end |
| 2126 | if show |
| 2127 | emwh s 1 64 |
| 2128 | if corpus |
| 2129 | emb 9 |
| 2130 | a = wf s 12 |
| 2131 | emr a fe a eol s 400 |
| 2132 | if foreign |
| 2133 | emb 9 |
| 2134 | t = matline s |
| 2135 | if lt t get ibl 0 |
| 2136 | emwh t 2 64 |
| 2137 | else |
| 2138 | emb 45 |
| 2139 | end |
| 2140 | end |
| 2141 | end |
| 2142 | emb 10 |
| 2143 | end |
| 2144 | s = nextl add eol s 1 87 |
| 2145 | end |
| 2146 | end |
| 2147 | fn mamode a ulong b ulong sa ulong sb ulong to int |
| 2148 | if feqt a b mamrg |
| 2149 | ret mamerge |
| 2150 | end |
| 2151 | if feqt a b maal |
| 2152 | mauthors |
| 2153 | ret flush |
| 2154 | end |
| 2155 | if feqt a b maau |
| 2156 | if not slugok sa sb |
| 2157 | ret 3 |
| 2158 | end |
| 2159 | ret maauthor sa sb |
| 2160 | end |
| 2161 | if or feqt a b maad feqt a b mado |
| 2162 | head 0 0 0 0 |
| 2163 | if feqt a b maad |
| 2164 | em maadd |
| 2165 | else |
| 2166 | em madoi |
| 2167 | end |
| 2168 | em mafoot |
| 2169 | ret flush |
| 2170 | end |
| 2171 | if feqt a b mafo |
| 2172 | malists false |
| 2173 | ret flush |
| 2174 | end |
| 2175 | if feqt a b maco |
| 2176 | malists true |
| 2177 | ret flush |
| 2178 | end |
| 2179 | ret 99 |
| 2180 | end |
| 2181 | fn maqtext to int |
| 2182 | bol = true |
| 2183 | while true bound 2097152 |
| 2184 | k = read 0 ib 0 4096 |
| 2185 | if lt k 0 |
| 2186 | ret 1 |
| 2187 | end |
| 2188 | if eq k 0 |
| 2189 | ret 0 |
| 2190 | end |
| 2191 | i = ulong 0 |
| 2192 | while lt i ulong k bound 4096 |
| 2193 | c = get ib i |
| 2194 | if bol |
| 2195 | em maquote |
| 2196 | bol = false |
| 2197 | end |
| 2198 | emb c |
| 2199 | if eq c 10 |
| 2200 | bol = true |
| 2201 | end |
| 2202 | i = add i 1 |
| 2203 | end |
| 2204 | r = flush |
| 2205 | if ne r 0 |
| 2206 | ret r |
| 2207 | end |
| 2208 | put obl 0 0 |
| 2209 | end |
| 2210 | ret 1 |
| 2211 | end |
| 2212 | fn maargs to int |
| 2213 | av = new uchar 16 0 |
| 2214 | if ne argcnt 2 |
| 2215 | ret 2 |
| 2216 | end |
| 2217 | z = argread 1 av 0 16 |
| 2218 | if ne z 5 |
| 2219 | ret 2 |
| 2220 | end |
| 2221 | for i ulong 5 |
| 2222 | if ne get av i get maqu i |
| 2223 | ret 2 |
| 2224 | end |
| 2225 | end |
| 2226 | ret maqtext |
| 2227 | end |
| 2228 | note Foreign O values are checked before the U record is emitted; the merged parser repeats checks. |
| 2229 | fn maovok to bool |
| 2230 | a = oval maby |
| 2231 | if not maprefix a eol a madid |
| 2232 | ret false |
| 2233 | end |
| 2234 | a = oval mavia |
| 2235 | b = eol a |
| 2236 | if not or feqt a b maz feqt a b mar |
| 2237 | ret false |
| 2238 | end |
| 2239 | a = oval kcheck |
| 2240 | if not madate a eol a |
| 2241 | ret false |
| 2242 | end |
| 2243 | a = oval kname |
| 2244 | ret and lt a get ibl 0 gt eol a a |
| 2245 | end |
| 2246 | text maorc1 "<p class='orcid'><span class='idb'>ORCID iD</span><a href='https://orcid.org/" |
| 2247 | fn maorcid u ulong legacy bool to void |
| 2248 | a = get ibl 0 |
| 2249 | b = a |
| 2250 | if legacy |
| 2251 | a = oval korcid |
| 2252 | b = eol a |
| 2253 | else |
| 2254 | a = wf u 3 |
| 2255 | b = fe a eol u |
| 2256 | end |
| 2257 | if ne sub b a 19 |
| 2258 | ret |
| 2259 | end |
| 2260 | for i ulong 19 |
| 2261 | c = get ib add a i |
| 2262 | if or or eq i 4 eq i 9 eq i 14 |
| 2263 | if ne c 45 |
| 2264 | ret |
| 2265 | end |
| 2266 | else |
| 2267 | ok = and ge c 48 le c 57 |
| 2268 | if and eq i 18 eq c 88 |
| 2269 | ok = true |
| 2270 | end |
| 2271 | if not ok |
| 2272 | ret |
| 2273 | end |
| 2274 | end |
| 2275 | end |
| 2276 | em maorc1 |
| 2277 | emh a b 19 |
| 2278 | em w02 |
| 2279 | emh a b 19 |
| 2280 | em mapclose |
| 2281 | end |
| 2282 | text mawby "</span><a href='/research/authors/" |
| 2283 | text mawdoi "<a class='doi' href='https://doi.org/" |
| 2284 | fn mawli s ulong to void |
| 2285 | em w01 |
| 2286 | emwh s 1 64 |
| 2287 | em w02 |
| 2288 | emwh s 12 400 |
| 2289 | em w03 |
| 2290 | emsubh s 83 600 |
| 2291 | em w04 |
| 2292 | emwh s 3 16 |
| 2293 | em w05 |
| 2294 | emwh s 4 32 |
| 2295 | em mawby |
| 2296 | u = mauline s |
| 2297 | emwh u 1 64 |
| 2298 | em w02 |
| 2299 | emwh u 2 120 |
| 2300 | em w09 |
| 2301 | v = wf s 7 |
| 2302 | if gt fe v eol s v |
| 2303 | em mawdoi |
| 2304 | emwh s 7 96 |
| 2305 | em w02 |
| 2306 | emwh s 7 96 |
| 2307 | em w09 |
| 2308 | end |
| 2309 | em w10 |
| 2310 | end |
| 2311 | text majp1 "],\"provenance\":{\"how\":\"" |
| 2312 | text majp2 "\",\"source\":\"" |
| 2313 | text majp3 "\",\"open_text\":" |
| 2314 | text majp4 "},\"author_ids\":[\"" |
| 2315 | text majp5 "],\"author_ids\":[\"" |
| 2316 | fn majwext s ulong to void |
| 2317 | p = mapline s |
| 2318 | if lt p get ibl 0 |
| 2319 | em majp1 |
| 2320 | emwj p 2 16 |
| 2321 | em majd |
| 2322 | emwj p 3 128 |
| 2323 | em majreq |
| 2324 | emwj p 3 128 |
| 2325 | if mazrec s |
| 2326 | em majrz |
| 2327 | else |
| 2328 | em majrr |
| 2329 | end |
| 2330 | em majdate |
| 2331 | emwj p 4 10 |
| 2332 | em majp2 |
| 2333 | emwj p 5 400 |
| 2334 | em majp3 |
| 2335 | if matext s |
| 2336 | em jtrue |
| 2337 | else |
| 2338 | em jfalse |
| 2339 | end |
| 2340 | magjson s |
| 2341 | em majp4 |
| 2342 | else |
| 2343 | em majp5 |
| 2344 | end |
| 2345 | u = mauline s |
| 2346 | emwj u 1 64 |
| 2347 | em jq |
| 2348 | end |
| 2349 | note ---- G: slug, repository commit (40 lowercase hex), paper SHA-256 (64 lowercase hex). |
| 2350 | note Only a foreign work (W with J and P) may carry one G line; legacy documents never show it. |
| 2351 | text magh1 "<section class='card'><h2>Source snapshot</h2><p>Repository commit: <code>" |
| 2352 | text magh2 "</code>. Paper SHA-256: <code>" |
| 2353 | text magh3 "</code>.</p></section>\n" |
| 2354 | text magj1 ",\"source_commit\":\"" |
| 2355 | text magj2 "\",\"paper_sha256\":\"" |
| 2356 | fn mahex a ulong b ulong n ulong to bool |
| 2357 | if ne sub b a n |
| 2358 | ret false |
| 2359 | end |
| 2360 | i = a |
| 2361 | while lt i b bound 64 |
| 2362 | c = get ib i |
| 2363 | ok = false |
| 2364 | if and ge c 48 le c 57 |
| 2365 | ok = true |
| 2366 | end |
| 2367 | if and ge c 97 le c 102 |
| 2368 | ok = true |
| 2369 | end |
| 2370 | if not ok |
| 2371 | ret false |
| 2372 | end |
| 2373 | i = add i 1 |
| 2374 | end |
| 2375 | ret true |
| 2376 | end |
| 2377 | fn magline s ulong to ulong |
| 2378 | a = wf s 1 |
| 2379 | ret sline 0 71 a fe a eol s |
| 2380 | end |
| 2381 | fn magvalid s ulong to bool |
| 2382 | lim = get ibl 0 |
| 2383 | e = eol s |
| 2384 | a = wf s 1 |
| 2385 | b = fe a e |
| 2386 | if ne sline 0 71 a b s |
| 2387 | ret false |
| 2388 | end |
| 2389 | w = wline a b |
| 2390 | if ge w lim |
| 2391 | ret false |
| 2392 | end |
| 2393 | if eq get mgr 0 0 |
| 2394 | if ge majline w lim |
| 2395 | ret false |
| 2396 | end |
| 2397 | end |
| 2398 | if ge mapline w lim |
| 2399 | ret false |
| 2400 | end |
| 2401 | a = wf s 2 |
| 2402 | if not mahex a fe a e 40 |
| 2403 | ret false |
| 2404 | end |
| 2405 | a = wf s 3 |
| 2406 | b = fe a e |
| 2407 | if ne b e |
| 2408 | ret false |
| 2409 | end |
| 2410 | ret mahex a b 64 |
| 2411 | end |
| 2412 | fn magsnap s ulong to void |
| 2413 | g = magline s |
| 2414 | if ge g get ibl 0 |
| 2415 | ret |
| 2416 | end |
| 2417 | em magh1 |
| 2418 | emwh g 2 40 |
| 2419 | em magh2 |
| 2420 | emwh g 3 64 |
| 2421 | em magh3 |
| 2422 | end |
| 2423 | fn magjson s ulong to void |
| 2424 | g = magline s |
| 2425 | if ge g get ibl 0 |
| 2426 | ret |
| 2427 | end |
| 2428 | em magj1 |
| 2429 | emwj g 2 40 |
| 2430 | em magj2 |
| 2431 | emwj g 3 64 |
| 2432 | em jq |
| 2433 | end |
| 2434 | note mamraw: set mgr when the mode line (first line) names merge |
| 2435 | fn mamraw to void |
| 2436 | m = nextl 0 77 |
| 2437 | if ne m 0 |
| 2438 | ret |
| 2439 | end |
| 2440 | a = fld m eol m 1 |
| 2441 | if feqt a fe a eol m mamrg |
| 2442 | put mgr 0 1 |
| 2443 | end |
| 2444 | end |
| 2445 | |
| 2446 | note T binds a foreign work to the selected immutable cache, or '-' when there is no text. |
| 2447 | fn matline s ulong to ulong |
| 2448 | a = wf s 1 |
| 2449 | ret sline 0 84 a fe a eol s |
| 2450 | end |
| 2451 | fn matvalid s ulong to bool |
| 2452 | e = eol s |
| 2453 | a = wf s 1 |
| 2454 | b = fe a e |
| 2455 | if ne sline 0 84 a b s |
| 2456 | ret false |
| 2457 | end |
| 2458 | w = wline a b |
| 2459 | if ge w get ibl 0 |
| 2460 | ret false |
| 2461 | end |
| 2462 | if eq get mgr 0 0 |
| 2463 | if ge majline w get ibl 0 |
| 2464 | ret false |
| 2465 | end |
| 2466 | end |
| 2467 | a = wf s 2 |
| 2468 | b = fe a e |
| 2469 | if ne b e |
| 2470 | ret false |
| 2471 | end |
| 2472 | if eq sub b a 1 |
| 2473 | ret eq get ib a 45 |
| 2474 | end |
| 2475 | ret mahex a b 64 |
| 2476 | end |