Index: cortav.ct ================================================================== --- cortav.ct +++ cortav.ct @@ -580,11 +580,11 @@ *** [`stageplay]: uses asides to denote actions, quotes for dialogue *** [`manual] *** [`glossary] *** [`news] *** [`book]: section depths 1-3 gain additional semantics -***: [*part]: the section gets a page to itself to announce the beginning of a new part or appendix +***: [*part]: the section gets a page to itself to announce the beginning of a new part or appendix. the first part is treated as the title page. ***: [*chapter]: the section is preceded by a page break ***: [*heading]: the section can occur on the same page as text and headings from other sections ** {d pragma accent} specifies an accent hue (in degrees around the color wheel) for renderers which support colorized output ** {d pragma accent-spread} is a factor that controls the "spread" of hues used in the document. if 0, only the accent color will be used; if larger, other hues will be used in addition to the primary accent color. ** {d pragma dark-on-light on\|off} controls whether the color scheme used should be light-on-dark or dark-on-light @@ -603,11 +603,11 @@ > —spoke to the man under the bridge again, the one who likes to bite the heads off the fish, and he suggested i take a brief sabbatical and journey to the Wandering Oak (where all paths meet) in search of inspiration and the forsaken sword of Pirate Queen Granuaile. a capital idea! i shall depart upon the morrow, having honored the Lord Odin and poisoned my accursed minstrels as is tradition— > —can't smell my soul anymore, but that's beside the point entirely— > —that second moon (always have wondered why nobody else seems to notice the damn fool thing except on Michaelmas day). alas, my luck did not endure, and i was soon to find myself knee-deep in— > —just have to see about that, won't we!— -the nearest surviving relative of Lord Hawthorne is believed to be a wandering beggar with a small pet meerkat who sells cursed wooden trinkets to unwary children. she will not be contacted, as the officers of the Yard fear her. +the nearest surviving relative of Lord Hawthorne is believed to be a wandering beggar with a small slow loris for a pet who sells cursed wooden trinkets to unwary children. she will not be contacted, as the officers of the Yard fear her. ~~~ ~~~links & notes #lnr [cortav] ~~~ this sentence contains a [>zombo link] to zombo com. you can do anything[^any] at zombo com. zombo: https://zombo.com Index: cortav.lua ================================================================== --- cortav.lua +++ cortav.lua @@ -160,14 +160,24 @@ local rid = sec.refs[id] if rid then return rid, id, sec end end + + for _, i in ipairs(sec.imports) do + local rr, ri, rs = checkFromSec(i, doc) + if ri then return rr, ri, rs end + end if doc.sections[id] then return nil, id, doc.sections[id] end + + for _, i in ipairs(doc.globals) do + local rr, ri, rs = checkFromSec(i, doc) + if ri then return rr, ri, rs end + end else local secid, ref = string.match(id, "(.-)%.(.+)") local s s = s or doc.sections[secid] if s then @@ -223,10 +233,11 @@ ct.sec = declare { ident = 'section'; mk = function() return { blocks = {}; refs = {}; + imports = {}; depth = 0; kind = 'ordinary'; } end; construct = function(self, id, depth) self.id = id @@ -357,10 +368,11 @@ return newdoc, nctx end; }; mk = function(...) return { sections = {}; + globals = {}; secorder = {}; embed = {}; meta = {}; vars = {}; parents = {...}; @@ -1006,10 +1018,39 @@ license = dsetmeta; keywords = dsetmeta; desc = dsetmeta; when = dcond; unless = dcond; + with = function(w,c) + local _,str = w(2) + local aka, name = str:match '^([^=])=(.*)$' + if aka == nil then name=str aka=name end + + local o,id,s = c:ref(name) + if o then -- import object + c.sec.import.objs[aka] = o + else -- import scope + table.insert(c.sec.import.scope, s) + end + end; + global = function(w,c) + local _,str = w(2) + if str ~= nil and str ~= '' then + local aka, name = str:match '^([^=])=(.*)$' + if aka == nil then name=str aka=name end + + local o,id,s = c:ref(name) + + if o then + c.doc.globals.objs[aka] = name + else + table.insert(c.doc.globals, s) + end + else + table.insert(c.doc.globals, c.sec) + end + end; pragma = function(w,c) end; lang = function(w,c) local _, op, l = w(2) local langstack = c.doc.stage.langstack Index: ext/transmogrify.lua ================================================================== --- ext/transmogrify.lua +++ ext/transmogrify.lua @@ -10,11 +10,11 @@ ['----'] = '⸻'; }; { ['<==>'] = '⟺'; - ['===>'] = '⇐'; + ['===>'] = '⟹'; ['<==='] = '⟸'; }; { ['<->'] = '↔'; Index: makefile ================================================================== --- makefile +++ makefile @@ -59,13 +59,15 @@ ifneq ($(filter net,$(binds-names)),) lua-bindeps += -lcurl endif -dbg-flags-luac = $(if $(debug),,-s) -dbg-flags-cc = $(if $(debug),-g,-s) - +ifneq (luac-broken,) + comp-lua = $(if $(debug),,env strip=1) $(lua) tool/luac.lua $1 $(if $2,>$2) +else + comp-lua = $(luac) $(if $(debug),,-s) -o $(if $2,$2,-) $1 +endif # by default, we fetch and parse information about encodings we # support so that cortav can do fancy things like format math # equations by character class (e.g. italicizing variables) # this is not necessary for parsing the format, and can be @@ -85,11 +87,11 @@ # raw bytecode without shebang header, must be run as `lua cortav.lc` $(build)/$(executable).lc: sirsem.lua $(encoding-files) cortav.lua $(rendrs) $(extens) cli.lua | $(build)/ @echo ' » building with extensions $(extens-names)' @echo ' » building with renderers $(rendrs-names)' - $(luac) $(dbg-flags-luac) -o $@ $^ + $(call comp-lua,$^,$@) # true standalone binary, wraps bytecode file and (optionally) lua $(build)/$(executable).bin: $(build)/$(executable).lc tool/makeshim.lua $(binds) $(lua) tool/makeshim.lua $< "" $(binds-names) |\ $(CC) -s -o$@ -xc - -xnone $(binds) $(lua-standalone) $(lua-bindeps) @@ -130,11 +132,11 @@ mkdir -p $@ $(build)/unicode.txt: | $(build)/ curl $(encoding-data-ucs-url) > $@ $(build)/ucstbls.lc: $(encoding-data-ucs) tool/ucs.lua | $(build)/ - $(lua) tool/ucs.lua $< | $(luac) -o $@ - + $(lua) tool/ucs.lua $< >$@ .PHONY: install install: $(build)/cortav $(build)/cortav-view.sh $(build)/velartrill-cortav-view.desktop | $(bin-prefix)/ install $(build)/$(executable) $(bin-prefix) install $(build)/cortav-view.sh $(bin-prefix) ADDED tool/luac.lua Index: tool/luac.lua ================================================================== --- tool/luac.lua +++ tool/luac.lua @@ -0,0 +1,21 @@ +-- luac is broken in some distributions, and cannot take more than one +-- argument without crashing on a double free or similar. this +-- completely breaks the cortav build process, so we supply our own +-- ultra-simplistic and painfully primitive luac replacement. +-- this does not generate very good object code. +-- pass luac-broken=1 when building to use +local pgm = "" +local strip = os.getenv("strip")=="1" +if #arg > 1 then + local chunks = {} + for i, f in ipairs(arg) do + local nc = assert(loadfile(f)) + nc = string.format("load%q(...)", string.dump(nc)) + table.insert(chunks, nc) + end + pgm = assert(string.dump(load(table.concat(chunks)))) +else + pgm = assert(string.dump(loadfile(arg[1]))) +end + +io.stdout:write(pgm) Index: tool/ucs.lua ================================================================== --- tool/ucs.lua +++ tool/ucs.lua @@ -153,6 +153,6 @@ local top = 1 for k,v in pairs(ranges) do tab[top] = string.format('{0x%x,0x%x,%u}',table.unpack(v)) top = top + 1 end -io.stdout:write(string.format(tpl, table.concat(tab,',\n'))) +io.stdout:write(string.dump(load(string.format(tpl, table.concat(tab,',\n')))))