Index: cortav.ct ================================================================== --- cortav.ct +++ cortav.ct @@ -559,20 +559,28 @@ ##dir directives d: [`%[*[##1]]] dd: [`%[*[##1]] [#2]] * {d author} encodes document authorship. multiple author directives can be issued to add additional coauthors * {d cols} specifies the number of columns the next object should be rendered with -* {d include} transcludes another file -* {d import} reads in the contents of another file as an embeddable section +* {d include} transcludes another file (but see also [>rsrc]) +* {d with} imports symbols from another scope: +** {dd with|[$section]} imports all symbols in [$section] +** {dd with|[$section].[$object]} imports [$object] from [$section] +** {dd with|[$name]=[$section]} creates a local alias [$name] for [$section] +** {dd with|[$name]=[$section].[$object]} imports [$object] from [$section] under the name [$name] +* {d global} exports all symbols in the current section so they can be used unprefixed from any other section +** {dd global|[$section]} exports all symbols in [$section] +** {dd global|[$section].[$object]} exports [$object] from [$section] +** {dd global|[$name]=[$section]} creates a global alias [$name] for [$section] +** {dd global|[$name]=[$section].[$object]} exports [$object] from [$section] under the name [$name] * {d quote} transcludes another file, without expanding the text except for paragraphs -* {d embed}, where possible, embeds another file as an object within the current one. in HTML this could be accomplished with e.g. an iframe. * {d expand} causes the next object (usually a code block) to be fully expanded when it would otherwise not be * {d font} controls the font stack, for outputs that support changing fonts. see [>fonts fonts] for more information. * {d lang} changes the current language, which is used by extensions to e.g. control typographical conventions, and may be encoded into the output by certain renderers (e.g. HTML). note that quotes and blockquotes can be set to a separate language with a simpler syntax. the language should be notated using IETF language tags -** {d lang is x-ranuir-Cent-CR8} sets the current language to Ranuir as spoken in the Central Worlds, written in Corran and encoded using C6B+U8L (which can also be interpreted as UTF-8, albeit with some lost semantics). this might be used at the top of a document to set its primary language. -** {d lang push gsw-u-sd-chzh} temporarily switches to Zürich German, e.g. to quote a German passage in an otherwise Ranuir document -** {d lang sec en-US} switches to American English for the duration of a section. does not affect the language stack. +** {dd lang is|x-ranuir-Cent-CR8} sets the current language to Ranuir as spoken in the Central Worlds, written in Corran and encoded using C6B+U8L (which can also be interpreted as UTF-8, albeit with some lost semantics). this might be used at the top of a document to set its primary language. +** {dd lang push|gsw-u-sd-chzh} temporarily switches to Zürich German, e.g. to quote a German passage in an otherwise Ranuir document +** {dd lang sec|en-US} switches to American English for the duration of a section. does not affect the language stack. ** {d lang pop} drops the current language off the language stack, returning to whatever was pushed or set before it. this would be used, for instance, at the end of a passage * {d pragma} supplies semantic data about author intent, the kind of information the document contains and hints about how it should be displayed to the user. think of them like offhand remarks to the renderer -- there's no guarantee that it'll pay any attention, but if it does, your document will look better. pragmas have no scope; they affect the entire document. the pragma function exists primarily as a means to allow parameters that would normally need to be specified on e.g. the command line to be encoded in the document instead in a way that multiple implementations can understand. a few standard pragmas are defined. ** {d pragma layout} gives a hint on how the document should be layed out. the first hint that is understood will be applied; all others will be discarded. standard hints include: *** [`essay] *** [`narrative] Index: cortav.lua ================================================================== --- cortav.lua +++ cortav.lua @@ -1759,5 +1759,22 @@ return val, true else return ct.parse_span(val, v.origin), false end end + +function ct.linkspans(link) + if link.spans and next(link.spans) then return link.spans end + + local o, id, s = link.origin:ref(link.ref) + if o then --TODO + if type(o) == 'table' then + end + return {id} + else -- it's a section link + if s.heading_node then + return s.heading_node.spans + end + end + + -- give up; the renderer decides how to represent this link +end Index: makefile ================================================================== --- makefile +++ makefile @@ -59,11 +59,11 @@ ifneq ($(filter net,$(binds-names)),) lua-bindeps += -lcurl endif -ifneq (luac-broken,) +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 Index: render/html.lua ================================================================== --- render/html.lua +++ render/html.lua @@ -764,11 +764,12 @@ return htmlSpan(v.spans, b, s) end function span_renderers.link(sp,b,s) local href = idLink(sp.ref,b) - return tag('a',{href=href}, next(sp.spans) and htmlSpan(sp.spans,b,s) or href) + local lsp = ct.linkspans(sp) + return tag('a',{href=href}, lsp and htmlSpan(lsp,b,s) or href) end span_renderers['line-break'] = function(sp,b,s) return elt('br') end