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    635   -- objects, including ones that users have not assigned IDs
   636    636   -- to, and objects with the same name in different unlabeled
   637    637   -- sections. to handle this, we provide a "namespace" mechanism,
   638    638   -- where some lua table (really its address in memory) is used
   639    639   -- as a handle for the object and a unique ID is attached to it.
   640    640   -- if the object has an ID of its own, it is guaranteed to be
   641    641   -- unique and returned; otherwise, a generic id of the form
   642         --- `x-%u` is generated, where %u is an integer that incrementsfile:///home/lexi/dev/cortav/build/cortav.html
          642  +-- `x-%u` is generated, where %u is an integer that increments
   643    643   -- for every new object
   644    644   	local ids = {}
   645    645   	local canonicalID = {}
   646    646   	return function(obj,pfx)
   647    647   		pfx = pfx or ''
   648    648   		if canonicalID[obj] then
   649    649   			return canonicalID[obj]
................................................................................
   970    970   	if l:sub(1,1) == '.' then l = l:sub(2) end
   971    971   	return {
   972    972   		kind = "paragraph";
   973    973   		spans = ct.parse_span(l, c);
   974    974   	}
   975    975   end)
   976    976   
   977         -local function insert_section(skind) return function(l,c,j)
          977  +local insert_subtitle = blockwrap(function(l,c)
          978  +	return {
          979  +		kind = "subtitle";
          980  +		spans = ct.parse_span(l:sub(3), c);
          981  +	}
          982  +end)
          983  +
          984  +local function
          985  +insert_section(skind) return function(l,c,j)
   978    986   	local depth, id, t = l:match '^([#§^]+)([^%s]*)%s*(.-)$'
   979    987   	if id and id ~= "" then
   980    988   		if c.doc.sections[id] then
   981    989   			c:fail('duplicate section name “%s”', id)
   982    990   		end
   983    991   	else id = nil end
   984    992   
................................................................................
  1173   1181   ct.ctlseqs = {
  1174   1182   	{seq = '.', fn = insert_paragraph};
  1175   1183   	{seq = '¶', fn = insert_paragraph};
  1176   1184   	{seq = '❡', fn = insert_paragraph};
  1177   1185   	{seq = '#', fn = insert_section()};
  1178   1186   	{seq = '§', fn = insert_section()};
  1179   1187   	{seq = '^', fn = insert_section 'namespace'};
         1188  +	{seq = '--',fn = insert_subtitle};
  1180   1189   	{seq = '+', fn = insert_table_row};
  1181   1190   	{seq = '|', fn = insert_table_row};
  1182   1191   	{seq = '│', fn = insert_table_row};
  1183   1192   	{seq = '!', fn = function(l,c,j,d)
  1184   1193   		local last = d[#d]
  1185   1194   		local txt = l:match '^%s*!%s*(.-)$'
  1186   1195   		if (not last) or last.kind ~= 'aside' then

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

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