Index: cli.lua ================================================================== --- cli.lua +++ cli.lua @@ -224,12 +224,19 @@ end return main(input, outp, log, mode, suggestions, vars, extrule) end --- local ok, e = pcall(entry_cli) -local ok, e = true, entry_cli() +local ok, e = xpcall(entry_cli, function(e) + if not ss.exn.is(e) then + e = ss.bug('lua vm error: %s', e) + end + e.trace = debug.traceback(nil, nil, 1) + log:write(e.trace .. '\n') + return e +end) +-- local ok, e = true, entry_cli() if not ok then local str = 'translation failure' if ss.exn.is(e) then str = e.kind.desc end @@ -252,8 +259,11 @@ end if color then str = string.format('\27[1;31m%s\27[m', str) end log:write(string.format('%s: %s\n', str, e)) + if ss._debug and ss.exn.is(e) and e.trace then + log:write(e.trace) + end os.exit(1) end os.exit(e) Index: cortav.lua ================================================================== --- cortav.lua +++ cortav.lua @@ -1,9 +1,10 @@ -- [ʞ] cortav.lua -- ~ lexi hale -- © EUPL v1.2 -- ? reference implementation of the cortav document language +-- \ from Ranuir "written document" -- -- ! TODO refactor encoding logic. it's a complete -- mess and i seem to have repeatedly gotten -- confused about how it's supposed to work. -- the whole shitshow needs to be replaced @@ -118,11 +119,11 @@ new.generation = 1 end end; fns = { fail = function(self, msg, ...) - --error(string.format(msg,...)) + -- error(string.format(msg,...)) ct.exns.tx(msg, self.src.file, self.line or 0, ...):throw() end; insert = function(self, block) block.origin = self:clone() table.insert(self.sec.blocks,block) @@ -360,11 +361,11 @@ return self.docjob:fork(name, pred, ...) end; sub = function(self, ctx) -- convenience function for single-inheritance structure -- sets up a doc/ctx pair for a subdocument embedded in the source - -- of a gretaer document, pointing subdoc props to global tables/values + -- of a greater document, pointing subdoc props to global tables/values local newdoc = ct.doc.mk(self) newdoc.meta = self.meta newdoc.ext = self.ext newdoc.enc = self.enc newdoc.stage = self.stage Index: makefile ================================================================== --- makefile +++ makefile @@ -87,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)' - $(call comp-lua,$^,$@) + $(if $(debug),echo "require'sirsem'._debug=1" | $(call comp-lua,sirsem.lua - $(filter-out sirsem.lua,$^),$@),$(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) @@ -106,17 +106,21 @@ .PHONY: syncdoc syncdoc: $(build)/cortav.html fossil uv add $< --as cortav.html fossil uv sync --all -# clean is written in overly cautious fashion to minimize damage, -# just in case it ever gets invoked in a bad way (e.g. build=/) +# clean and wipe are written in overly cautious fashion to minimize damage, +# just in case they ever get invoked in a bad way (e.g. build=/) .PHONY: clean clean: - rm -f $(build)/*.{html,lc,sh,txt,desktop} \ - $(build)/$(executable){,.bin} \ - $(build)/bind + rm -f $(build)/*.{html,lc,sh,desktop} \ + $(build)/$(executable){,.bin} + rm -r $(build)/bind +# wipe also kills external datasheets +.PHONY: wipe +wipe: clean + rm -f $(build)/*.txt rmdir $(build) $(build)/%.sh: desk/%.sh | $(build)/ echo >$@ "#!$(sh)" echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"' Index: render/html.lua ================================================================== --- render/html.lua +++ render/html.lua @@ -739,13 +739,15 @@ function span_renderers.deref(t,b,s) local r = b.origin:ref(t.ref) local name = t.ref if name:find'%.' then name = name:match '^[^.]*%.(.+)$' end + if type(r) == 'string' then addStyle 'abbr' - return tag('abbr',{title=r},next(t.spans) and htmlSpan(t.spans,b,s) or name) + r = ct.parse_span(r, b.origin) + return tag('abbr',{title=htmlentities(plainrdr.htmlSpan(r))}, next(t.spans) and htmlSpan(t.spans,b,s) or name) end if r.kind == 'resource' then local rid = getSafeID(r, 'res-') if r.class == 'image' then if not cssRulesFor[r] then Index: sirsem.lua ================================================================== --- sirsem.lua +++ sirsem.lua Index: tool/makeshim.lua ================================================================== --- tool/makeshim.lua +++ tool/makeshim.lua