(function () {\n version.extensions['revisionMacros'] = {\n major: 1,\n minor: 0,\n revision: 0\n };\n macros['cycle'] = macros['insertion'] = macros['removal'] = macros['revision'] = macros['span'] = {\n handler: function (g, e, f, b) {\n function tagcontents(starttags, desttags, endtags, k) {\n function tagfound(i, e) {\n for(var j = 0; j < e.length; j++) {\n if(a.indexOf(e[j],i) == i) {\n return e[j];\n }\n }\n }\n var a = b.source.slice(k);\n var l = 0;\n var c = "";\n var tg;\n for(var i = 0; i < a.length; i++) {\n if(tg = tagfound(i,starttags)) {\n l++;\n }\n else if ((tg = tagfound(i,desttags)) && l==0) {\n b.nextMatch = k + i + tg.length;\n return [c, tg];\n }\n else if (tg = tagfound(i, endtags)) {\n l--;\n if(l < 0) {\n return null;\n }\n }\n c += a.charAt(i);\n }\n return null;\n }\n var begintags = ["<<revision","<<cycle","<<insertion","<<removal","<<span"];\n var becomes = ["<<becomes>>", "<<gains>>"];\n var endtags = ["<<endrevision>>","<<endcycle>>","<<endinsertion>>","<<endremoval>>","<<endspan>>"];\n var name = f[0].replace(" ", "_");\n var k = b.source.indexOf('>>', b.matchStart) + 2;\n var c, vsns, vsn, i, cn, vtype;\n vsns = [];\n c = tagcontents(begintags, becomes.concat(endtags), endtags, k);\n if(c && endtags.indexOf(c[1])==-1) {\n while(c) {\n vsns.push(c);\n c = tagcontents(begintags, becomes, endtags, b.nextMatch);\n }\n c = tagcontents(begintags, ["<<end"+e+">>"], endtags, b.nextMatch);\n }\n if(!c) {\n throwError(g, "can't find matching end" + e);\n return;\n }\n vsns.push(c);\n i = 0;\n cn = 0;\n m = insertElement(g, "span", null, e + " " + name);\n if(vsns.length > 0) {\n h = insertElement(m, "span", null, "revision-span initial");\n }\n else {\n h = m;\n }\n if(e == "insertion") {\n h.style.display = "none";\n }\n h.setAttribute("data-enabled", (e != "insertion") + "");\n vsn = vsns.shift();\n h.tweecode = vsn[0];\n while(vsns.length > 0) {\n i += 1;\n vtype = vsn[1].slice(2, -2);\n vsn = vsns.shift();\n h = insertElement(m, "span", null, "revision-span " + vtype);\n h.tweecode = vsn[0];\n h.setAttribute("data-enabled", "false");\n h.style.display = "none";\n }\n h=m.firstChild;\n new Wikifier(h, h.tweecode);\n }\n }\n macros['becomes'] = macros['gains'] = macros['endrevision'] = macros['endinsertion'] = macros['endremoval'] = macros['endcycle'] = {\n handler: function () {}\n }\n macros['revert'] = macros['revise'] = {\n handler: function (a, b, c) {\n var l, rev, rname, de;\n de = "data-enabled";\n function disableLink(l) {\n l.style.display = "none";\n }\n function enableLink(l) {\n l.style.display = "inline";\n }\n function updateLink(l) {\n var rall = document.getElementsByClassName(rname);\n var cannext, canprev;\n for(var i = 0; i < rall.length; i++) {\n var r = rall[i];\n if(r.classList.contains("cycle")) {\n cannext = canprev = true;\n }\n else {\n var rc = r.childNodes;\n var rcl = rc.length;\n var ins = r.classList.contains("insertion");\n var rmv = r.classList.contains("removal");\n var ind = -1;\n for(var k = 0; k < rc.length; k++) {\n if(rc[k].getAttribute(de) == "true") {\n ind = k;\n }\n }\n if(ind == -1 && (ins || rmv)) {\n (ins ? cannext = true : canprev = true);\n }\n if(ind > (ins ? -1 : 0)) {\n canprev = true;\n }\n if(ind>-1 && ind < (rmv ? rcl : rcl - 1)) {\n cannext = true;\n }\n }\n }\n var can = (l.classList.contains("revert") ? canprev : cannext);\n (can ? enableLink : disableLink)(l);\n }\n function reviseOnClick() {\n var rall, r, rc, rcl, ind, curr, next, ins, rmv, cyc;\n var rsp = "revision-span";\n function showVer(n) {\n n.innerHTML = "";\n new Wikifier(n,n.tweecode);\n n.setAttribute(de, "true");\n n.style.display = "inline";\n n.classList.remove(rsp+"-out");\n n.classList.add(rsp+"-in");\n if (n.timeout) clearTimeout(n.timeout);\n n.timeout = setTimeout(function () {\n n.classList.remove(rsp+"-in");\n }, 1);\n }\n\n function hideVer(n) {\n n.setAttribute(de, "false");\n n.classList.remove(rsp+"-in");\n n.classList.add(rsp+"-out");\n if (n.timeout) clearTimeout(n.timeout);\n n.timeout = setTimeout(function () {\n if(n.getAttribute(de) == "false") {\n n.classList.remove(rsp+"-out");\n n.style.display = "none";\n n.innerHTML = "";\n }\n }, 1000);\n }\n\n function doToGainerSpans(n, fn) {\n for(var k = n - 1; k >= 0; k--) {\n if(rc[k + 1].classList.contains("gains")) {\n fn(rc[k]);\n }\n else break;\n }\n }\n rall = document.getElementsByClassName(rname);\n for(var i = 0; i < rall.length; i++) {\n r = rall[i];\n rc = r.childNodes;\n ins = r.classList.contains("insertion");\n rmv = r.classList.contains("removal");\n cyc = r.classList.contains("cycle");\n rcl = rc.length - 1;\n ind = -1;\n for(var k = 0; k <= rcl; k++) {\n if(rc[k].getAttribute(de) == "true") {\n ind = k;\n }\n }\n if(ind == -1) {\n if(ins) {\n ind = -1;\n curr = null;\n }\n else if(rmv) {\n ind = rcl + 1;\n curr = null;\n }\n }\n else {\n if(rev) {\n ind -= 1;\n }\n curr = (ind >= 0 ? rc[ind] : (cyc ? rc[rcl] : null));\n }\n next = (ind < rcl ? rc[ind + 1] : (cyc ? rc[0] : null));\n var docurr = (rev ? showVer : hideVer);\n var donext = (rev ? hideVer : showVer);\n if(curr) {\n if(!(next && next.classList.contains("gains"))) {\n docurr(curr);\n doToGainerSpans(ind, docurr);\n }\n }\n if(next) {\n donext(next);\n }\n ind += (rev ? -1 : 1);\n }\n var lall = document.getElementsByClassName("reviseLink_" + rname);\n for(i = 0; i < lall.length; i++) {\n updateLink(lall[i]);\n }\n }\n rname = c[0].replace(" ", "_");\n rev = (b == "revert");\n if(c.length < 2) {\n throwError(a, b + ' macro needs 2 parameters');\n return;\n }\n l = Wikifier.createInternalLink(a, null);\n l.className = "internalLink reviseLink reviseLink_" + rname + " " + b;\n insertText(l, c[1]);\n l.onclick = reviseOnClick;\n disableLink(l);\n setTimeout(function(){\n updateLink(l);\n },1);\n }\n }\n}());
setTimeout(function(){ var next = "Start2";\n\nvar h = state.history; if (h[0].passage.title=="Start") { var n = insertElement(null, 'div');n.style.display="none";n.appendChild($("passages").removeChild($("passageStart")));state.display(next,null);$("passages").appendChild(n);}},1);
You see here <<revision books>>a closed book.<<becomes>>a chewed book.<<becomes>>paper scraps.<<endrevision>>\n<<revise books "Chew book">>\n<<revert books "Unchew book">>\n\nYou see here <<revision box1>>a closed box. You could <<revise box1 "open the box">>, I guess.<<becomes>>an open box, containing <<revision box2>>a closed capsule<<becomes>>an empty capsule<<endrevision>> and some junk. \n\n<<revise box2 "Open the capsule.">>\n<<revert box1 "Close the box.">>\n<<endrevision>>\n\nYou look at the vase: <<revision vase>>Two roses<<gains>>, an orchid<<gains>>, a pencil<<gains>>, a straw<<gains>>, a 30cm ruler<<gains>>, a fork<<becomes>>A bunch of miscellaneous stuff<<endrevision>>, and a violet are inside.\n<<revise vase "Add flower to vase">>\n<<revert vase "Remove flower from vase">>\n\nYou see here <<revision book2>>a closed book<<gains>> (with a bite mark)<<becomes>>a chewed book<<gains>> (mostly eaten)<<becomes>>some paper scraps<<endrevision>>.\n<<revise book2 "Chew book">>\n<<revert book2 "Unchew book">>\n\nYou're in a <<revision wet>>wet, slimy<<becomes>>dry, crusty<<endrevision>> part of the dungeon. It's really quite incredible - you could've sworn it was <<revision wet>>dessicated<<becomes>>saturated<<endrevision>> just a few moments ago.\nA <<revision wet>>//glistening//<<becomes>>''dusty''<<endrevision>>, glowing glass wheel is on the wall. \n<<revision wet>><<revise wet "Turn it right.">>\nIt won't go left.<<becomes>>It won't go right.\n<<revert wet "Turn it left.">><<endrevision>>\n\nYou see here <<cycle pet>>a dog<<becomes>>a cat<<endcycle>>.\nYou also see here <<cycle pet>>a snail<<becomes>>a roach<<becomes>>a rat<<endcycle>>.\n<<revise pet "Change pets">>\n<<revert pet "Change pets too">>\n\n<<set $c=0; $d=1>><<cycle counter>>The Fibbonacci counter reads "<<print $c+$d>>".<<set $e=$c; $c=$d; $d+=$e>><<endcycle>>\n<<revise counter "Increment the counter.">>\n\nYou look at the plate. <<insertion grain>>1 grain.<<becomes>>2 grains.<<becomes>>3 grains.<<endinsertion>>\n<<revise grain "Drop a grain">> //The text "1 grain" is added at first click.//\n<<revert grain "Undrop a grain">>\n\nYou look at the plate. <<removal seed>>3 seeds.<<becomes>>2 seeds.<<becomes>>1 seed.<<endremoval>>\n<<revise seed "Eat a seed">> //The text "1 seed" is removed at last click.//\n<<revert seed "Uneat a seed">>\n\nYou look at the clock. <<cycle hand>>9:00<<becomes>>12:00<<becomes>>3:00<<becomes>>6:00<<endcycle>>\n<<revise hand "Turn it clockwise">>\n<<revert hand "Turn it widdershins">>\n
{{{<<revision>>}}} macro example
.revision-span-in {\n opacity: 0;\n}\n.revision-span:not(.revision-span-out) {\n transition: 1s;\n -webkit-transition: 1s;\n}\n.revision-span-out {\n position:absolute;\n opacity: 0;\n}\n