cortav  Check-in [0042f47e35]

Overview
Comment:fix definition-form deref rendering, fix exns, add debug mechanism for printing stacktraces, alleviate multifarious dimbulbery
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: 0042f47e35e38a5eef62c89daf189c9231e361050debd05f3c0a6e2bd4066ca5
User & Date: lexi on 2024-07-18 21:43:59
Other Links: manifest | tags
Context
2024-07-18
21:43
fix definition-form deref rendering, fix exns, add debug mechanism for printing stacktraces, alleviate multifarious dimbulbery Leaf check-in: 0042f47e35 user: lexi tags: trunk
18:36
fix untransmogrified footnotes begot by absent hook call check-in: bb010e612e user: lexi tags: trunk
Changes

Modified cli.lua from [0dc68c1657] to [047ac156ff].

222
223
224
225
226
227
228
229







230
231
232
233
234
235
236
237
...
250
251
252
253
254
255
256



257
258
259
		input.stream = file
		input.src.file = args[1]
	end

	return main(input, outp, log, mode, suggestions, vars, extrule)
end

-- local ok, e = pcall(entry_cli)







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
	local color = false
	if native then
................................................................................
			end
		end
	end
	if color then
		str = string.format('\27[1;31m%s\27[m', str)
	end
	log:write(string.format('%s: %s\n', str, e))



	os.exit(1)
end
os.exit(e)







|
>
>
>
>
>
>
>
|







 







>
>
>



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
257
258
259
260
261
262
263
264
265
266
267
268
269
		input.stream = file
		input.src.file = args[1]
	end

	return main(input, outp, log, mode, suggestions, vars, extrule)
end

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
	local color = false
	if native then
................................................................................
			end
		end
	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)

Modified cortav.lua from [3e270c2a7b] to [f2a5ec5d52].

1
2
3
4

5
6
7
8
9
10
11
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
-- [ʞ] cortav.lua
--  ~ lexi hale <lexi@hale.su>
--  © EUPL v1.2
--  ? reference implementation of the cortav document language

--
--  ! 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
--         with a clean, simple paradigm: documents
--         are translated to UTF8 on the way in, and
................................................................................
			new.generation = old.generation + 1
		else
			new.generation = 1
		end
	end;
	fns = {
		fail = function(self, 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)
			return block
		end;
................................................................................
		end;
		job = function(self, name, pred, ...) -- convenience func
			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
			local newdoc = ct.doc.mk(self)
			newdoc.meta = self.meta
			newdoc.ext = self.ext
			newdoc.enc = self.enc
			newdoc.stage = self.stage
			newdoc.defined_in_parent_section = ctx.sec
			-- vars are handled through proper recursion across all parents and




>







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
-- [ʞ] cortav.lua
--  ~ lexi hale <lexi@hale.su>
--  © 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
--         with a clean, simple paradigm: documents
--         are translated to UTF8 on the way in, and
................................................................................
			new.generation = old.generation + 1
		else
			new.generation = 1
		end
	end;
	fns = {
		fail = function(self, 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)
			return block
		end;
................................................................................
		end;
		job = function(self, name, pred, ...) -- convenience func
			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 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
			newdoc.defined_in_parent_section = ctx.sec
			-- vars are handled through proper recursion across all parents and

Modified makefile from [8d3e37cc0b] to [c76cdbdd22].

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117




118
119
120
121
122
123
124
	cat $< >>$@
	chmod +x $@

# 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,$^,$@)

# 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)

# loadable lua modules for binds, mainly useful for testing
................................................................................
	$(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv

.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=/)
.PHONY: clean
clean:
	rm -f $(build)/*.{html,lc,sh,txt,desktop} \
	      $(build)/$(executable){,.bin} \
	      $(build)/bind




	rmdir $(build)

$(build)/%.sh: desk/%.sh | $(build)/
	echo >$@ "#!$(sh)"
	echo >>$@ 'cortav_exec="$(bin-prefix)/$(executable)"'
	echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"'
	cat $< >> $@







|







 







|
|


|
|
|
>
>
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	cat $< >>$@
	chmod +x $@

# 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)'
	$(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)

# loadable lua modules for binds, mainly useful for testing
................................................................................
	$(build)/$(executable) $< -o $@ -m render:format html -y html:fossil-uv

.PHONY: syncdoc
syncdoc: $(build)/cortav.html
	fossil uv add $< --as cortav.html
	fossil uv sync --all

# 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,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)"'
	echo >>$@ 'cortav_flags="$${ct_format_flags-$(default-format-flags)}"'
	cat $< >> $@

Modified render/html.lua from [e178fd542c] to [7d5a564158].

737
738
739
740
741
742
743

744
745

746
747
748
749
750
751
752
753
			-- return string.format("&#%u;", code)
		end

		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)
			end
			if r.kind == 'resource' then
				local rid = getSafeID(r, 'res-')
				if r.class == 'image' then
					if not cssRulesFor[r] then
						local css = prepcss(string.format([[
							section p > .%s {







>


>
|







737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
			-- return string.format("&#%u;", code)
		end

		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'
				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
						local css = prepcss(string.format([[
							section p > .%s {

Modified sirsem.lua from [7e67a3ff12] to [c354742055].

Modified tool/makeshim.lua from [9df833faa8] to [c724b89ab4].