cortav  Check-in [362f9a6647]

Overview
Comment:add missing subtitle support
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 362f9a6647920ca47f5b32119c319eb7cc0b6318ac4a079742feef4e3c0464c4
User & Date: lexi on 2024-07-17 20:10:10
Other Links: manifest | tags
Context
2024-07-17
22:21
beginnings of some support for captions/subtitles, excise dumb ideas from readme and fix typo, black pharaoh but this codebase needs a rewrite check-in: 435c29db6b user: lexi tags: trunk
20:10
add missing subtitle support check-in: 362f9a6647 user: lexi tags: trunk
2024-05-07
19:25
unbreak build (oops sorry about that) check-in: b4009ca1bd user: lexi tags: trunk
Changes

Modified cortav.lua from [a5e2ed074c] to [76257c7c34].

635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
...
970
971
972
973
974
975
976








977
978
979
980
981
982
983
984
....
1173
1174
1175
1176
1177
1178
1179

1180
1181
1182
1183
1184
1185
1186
-- objects, including ones that users have not assigned IDs
-- to, and objects with the same name in different unlabeled
-- sections. to handle this, we provide a "namespace" mechanism,
-- where some lua table (really its address in memory) is used
-- as a handle for the object and a unique ID is attached to it.
-- if the object has an ID of its own, it is guaranteed to be
-- unique and returned; otherwise, a generic id of the form
-- `x-%u` is generated, where %u is an integer that incrementsfile:///home/lexi/dev/cortav/build/cortav.html
-- for every new object
	local ids = {}
	local canonicalID = {}
	return function(obj,pfx)
		pfx = pfx or ''
		if canonicalID[obj] then
			return canonicalID[obj]
................................................................................
	if l:sub(1,1) == '.' then l = l:sub(2) end
	return {
		kind = "paragraph";
		spans = ct.parse_span(l, c);
	}
end)









local function insert_section(skind) return function(l,c,j)
	local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
	if id and id ~= "" then
		if c.doc.sections[id] then
			c:fail('duplicate section name “%s”', id)
		end
	else id = nil end

................................................................................
ct.ctlseqs = {
	{seq = '.', fn = insert_paragraph};
	{seq = '¶', fn = insert_paragraph};
	{seq = '❡', fn = insert_paragraph};
	{seq = '#', fn = insert_section()};
	{seq = '§', fn = insert_section()};
	{seq = '^', fn = insert_section 'namespace'};

	{seq = '+', fn = insert_table_row};
	{seq = '|', fn = insert_table_row};
	{seq = '│', fn = insert_table_row};
	{seq = '!', fn = function(l,c,j,d)
		local last = d[#d]
		local txt = l:match '^%s*!%s*(.-)$'
		if (not last) or last.kind ~= 'aside' then







|







 







>
>
>
>
>
>
>
>
|







 







>







635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
...
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
....
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
-- objects, including ones that users have not assigned IDs
-- to, and objects with the same name in different unlabeled
-- sections. to handle this, we provide a "namespace" mechanism,
-- where some lua table (really its address in memory) is used
-- as a handle for the object and a unique ID is attached to it.
-- if the object has an ID of its own, it is guaranteed to be
-- unique and returned; otherwise, a generic id of the form
-- `x-%u` is generated, where %u is an integer that increments
-- for every new object
	local ids = {}
	local canonicalID = {}
	return function(obj,pfx)
		pfx = pfx or ''
		if canonicalID[obj] then
			return canonicalID[obj]
................................................................................
	if l:sub(1,1) == '.' then l = l:sub(2) end
	return {
		kind = "paragraph";
		spans = ct.parse_span(l, c);
	}
end)

local insert_subtitle = blockwrap(function(l,c)
	return {
		kind = "subtitle";
		spans = ct.parse_span(l:sub(3), c);
	}
end)

local function
insert_section(skind) return function(l,c,j)
	local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
	if id and id ~= "" then
		if c.doc.sections[id] then
			c:fail('duplicate section name “%s”', id)
		end
	else id = nil end

................................................................................
ct.ctlseqs = {
	{seq = '.', fn = insert_paragraph};
	{seq = '¶', fn = insert_paragraph};
	{seq = '❡', fn = insert_paragraph};
	{seq = '#', fn = insert_section()};
	{seq = '§', fn = insert_section()};
	{seq = '^', fn = insert_section 'namespace'};
	{seq = '--',fn = insert_subtitle};
	{seq = '+', fn = insert_table_row};
	{seq = '|', fn = insert_table_row};
	{seq = '│', fn = insert_table_row};
	{seq = '!', fn = function(l,c,j,d)
		local last = d[#d]
		local txt = l:match '^%s*!%s*(.-)$'
		if (not last) or last.kind ~= 'aside' then

Modified render/html.lua from [3985289eae] to [e689cbb41c].

251
252
253
254
255
256
257













258
259
260
261
262
263
264
...
868
869
870
871
872
873
874




875
876
877
878
879
880
881
				margin: 0.7em 0;
				text-align: justify;
			}
			section {
				margin: 1.2em 0;
			}
			section:first-child { margin-top: 0; }













		]];
		accent = [[
			@media screen {
				body { background: @bg; color: @fg }
				a[href] {
					color: @tone(0.7 30);
					text-decoration-color: @tone/0.4(0.7 30);
................................................................................
			['horiz-rule'] = function(b,s)
				return elt'hr'
			end;
			paragraph = function(b,s)
				addStyle 'paragraph'
				return tag('p', nil, sr.htmlSpan(b.spans, b, s), b)
			end;




			directive = function(b,s)
				-- deal with renderer directives
				local _, cmd, args = b.words(2)
				if cmd == 'page-title' then
					if not opts.title then doctitle = args end
				elseif b.critical then
					b.origin:fail('critical HTML renderer directive “%s” not supported', cmd)







>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
				margin: 0.7em 0;
				text-align: justify;
			}
			section {
				margin: 1.2em 0;
			}
			section:first-child { margin-top: 0; }
		]];
		subtitle = [[
			.subtitle {
				color: @tone(0.3 20); 
				font-size: 1.2em;
				font-style: italic;
				margin-left: 1em;
			}
			blockquote + .subtitle {
				&::before {
					content: "— ";
				}
			}
		]];
		accent = [[
			@media screen {
				body { background: @bg; color: @fg }
				a[href] {
					color: @tone(0.7 30);
					text-decoration-color: @tone/0.4(0.7 30);
................................................................................
			['horiz-rule'] = function(b,s)
				return elt'hr'
			end;
			paragraph = function(b,s)
				addStyle 'paragraph'
				return tag('p', nil, sr.htmlSpan(b.spans, b, s), b)
			end;
			subtitle = function(b,s)
				addStyle 'subtitle'
				return tag('div', {class='subtitle'}, sr.htmlSpan(b.spans, b, s), b)
			end;
			directive = function(b,s)
				-- deal with renderer directives
				local _, cmd, args = b.words(2)
				if cmd == 'page-title' then
					if not opts.title then doctitle = args end
				elseif b.critical then
					b.origin:fail('critical HTML renderer directive “%s” not supported', cmd)