cortav  Diff

Differences From Artifact [7b2c420807]:

To Artifact [2cc3a528df]:


    17     17   * [*headings]: cortav uses almost the same syntax for headings that markdown does, except it only allows the "ATX style" headings, with one or more hash characters at the start of the line. the only differences from markdown are:
    18     18   ** you can use the unicode section character [`§] instead of [`#] if you're feeling snobby
    19     19   ** you must put a space between the control sequence (the sequence of hashes or section symbols, in this case) and the title text. [`# title] creates a section with the heading text "title", but [`#title] creates a new section with no heading at all; instead, it gives the anonymous section the ID [`title]. and of course, you can combine the two: [`#ttl title] creates a section with the heading text "title" and the ID [`ttl]. what are IDs for? we'll get to that in a little bit
    20     20   * [*paragraphs] are mostly the same as in markdown, except that a paragraph break occurs after every newline character, not every blank line. paragraphs can be indented by however many spaces you like; such indentation will be ignored. (tabs have a special meaning, however). in cortav, you can also explicitly mark a line of text as a paragraph by preceding it with a period character ([`.]), which is useful if you want to start a paragraph with text that would otherwise be interpreted specially.
    21     21   * [*italic text] -- or rather, [!emphasized] text -- is written as [`\[!my spiffy italic text\]]. in cortav, these spans can be nested within other spans (or titles, or table cells, or…), and the starting and ending point is unambiguous.
    22     22   * [*bold text] -- or rather, [*strong] text -- is written as [`\[*my commanding bold text\]].
    23     23   * [*bold-italic text] -- or rather, [![*emphasized strong text]] -- has no specific notation. rather, you create it by nesting one span within the other, for instance: [`\[*[!my ostentatious bold-italic text\]]].
    24         -* [*links] are quite different from their markdown equivalents. cortav does not have inline links, as it is intended to be easily readable in both formatted and plain-text format, and long URLs rather disrupt the flow of reading. rather, a link tag is written with the notation [`\[>nifty-link my nifty link\]], where the word [`nifty-link] immediately following the arrow is an [!identifier] indicating the destination of the link. (instead of a greater-than sign, you can also use the unicode arrow symbol [`→].) if the identifier is the same as one you've assigned to a section, cortav produces a link within the document to that section. otherwise, it will look for a [!reference] to tell it the URI for the link. a reference is a key-value pair created by adding a line like [`nifty-link: https://zombo.com] [!indented by exactly one tab]. you can place this reference anywhere you like so long as it's in the same section; if you want to name a reference in another section, you have to prefix it with that section's ID, e.g. [`\[>spiffy-section.nifty-link my nifty link declared in a spiffy section\]].
           24  +* [*links] are quite different from their markdown equivalents. cortav does not have inline links, as it is intended to be easily readable in both formatted and plain-text format, and long URLs rather disrupt the flow of reading. rather, a link tag is written with the notation [`\[>nifty-link my nifty link\]], where the word [`nifty-link] immediately following the arrow is an [!identifier] indicating the destination of the link. (instead of a greater-than sign, you can also use the unicode arrow symbol [`→].) if the identifier is the same as one you've assigned to a document object, such as a section, cortav produces a link within the document to that object. otherwise, it will look for a [!reference] (or failing that, a [>rsrc resource]) to tell it the URI for the link. if nothing in the document matches the ID, an error will result and compilation will be aborted. (a reference is a key-value pair created by adding a line like [`nifty-link: https://zombo.com] [!indented by exactly one tab]. you can place this reference anywhere you like so long as it's in the same section; if you want to name a reference in another section, you have to prefix it with that section's ID, e.g. [`\[>spiffy-section.nifty-link my nifty link declared in a spiffy section\]].)
    25     25   * [*lists] use a different syntax from markdown. you can start a line with a [`*] to create an unordered list, or [`:] to create an ordered list; indentation doesn't matter. if you want to nest list items, instead of putting two spaces before the child item, you just add another star or colon. and of course, you can nest lists of different kinds within one another.
    26         -* [*horizontal rules] use roughly the same syntax: three or more hyphens on a line of their own ([`\---]). underlines also work ([`___], [`-_-], [`__-__-__] etc).
    27         -* some markdown implementations support [*tables]. cortav does too, using a very simple notation.
           26  +* [*horizontal rules] use roughly the same syntax: three or more hyphens on a line of their own ([`\---]). underlines also work ([`___], [`-_-], [`__-__-__] etc), as do horizontal unicode box drawing characters ([`─ ━ ┈] etc).
           27  +* some markdown implementations support [*tables]. cortav does too, using a very simple notation similar to the usual notation used in markdown. a key difference, however, is that cortav table cells can contain any formatting a paragraph can.
    28     28   * [*underlines] are supported by some markdown implementations. in cortav, you can apply them with the notation [`\[_my underlined text\]] -- please just use them sparingly when you render to HTML!
    29     29   * [*strikethrough] is supported by some extended versions of markdown. cortav uses the notation [`\[~my deleted text\]], with the intended semantics of text that is being removed by some revision of a document. (you can also denote text that is being [!added] by using a plus sign instead of a tilde)
    30         -* [*images] are a bit more complicated. see the section on [>rsrc resources] for an explanation.
           30  +* [*images] are a bit more complicated, but much more versatile. see the section on [>rsrc resources] for an explanation.
    31     31   * [*smart quotes] and [*em dashes] are inserted automatically, just as in markdown, provided you have the [>tsmog transmogrify] extension available. (it is part of the reference implementation and defined by the spec, but not required.) in fact, you can insert longer dashes than em dashes just by increasing the number of hyphens. the reference implementation's transmogrifier also translates ascii arrows like [`\-->] into their unicode equivalents ([`→]).
    32     32   * [*literals] (also known as [*code text]) can be inserted with the [`\[`int main(void);] syntax. note however that literals are not protected from the transmogrifier, and are parsed like any other span, which may cause problems if the source code you're quoting makes use of such forbidden runes. in this case, you'll want to wrap the code span in a raw span. the syntax for this is [`\[`[\\int main(void);\]]], but since this is a bit unwieldy it can also be abbreviated as [`\[`\\int main(void);\]].
    33     33   
    34     34   of course, this is only a small taste of what cortav can do, not even touching on key features like macros, footnotes, or equation formatting. read the sections on [>onblocks blocks] and [>onspans spans] for all the gory details.
    35     35   
    36     36   ## encoding
    37     37   a cortav document is made up of a sequence of codepoints. UTF-8 must be supported, but other encodings (such as UTF-32 or C6B) may be supported as well. lines will be derived by splitting the codepoints at the linefeed character or equivalent. note that unearthly encodings like C6B or EBCDIC will need to select their own control sequences.
................................................................................
    46     46   
    47     47   three more extensions are reserved for identifying a cortav intent file.
    48     48   * [`ctc] is the shorthand extension
    49     49   * [`cortavcun] is the canonical disambiguation extension
    50     50   * [`] is the canonical Corran extension, a byte sequence comprising the unicode codepoints [`U+E3CE U+E3BD U+E3CE]. where the filesystem in question does not specify a filename encoding, the bytes should be expressed in UTF-8.
    51     51   
    52     52   on systems which use metadata to encode filetype, two values are defined to identify cortav source files
    53         -* [`text/x-cortav] should be used when strings or arbitrary byte sequences are supported
           53  +* [`text/x.cortav] should be used when strings or arbitrary byte sequences are supported
    54     54   * [`CTAV] (that is, the byte sequence [`0x43 54 41 56]) should be used on systems that support only 32-bit file types/4-character type codes like Classic Mac OS.
    55     55   
    56     56   two more values are defined to identify cortav intent files.
    57         -* [`text/x-cortav-intent]
           57  +* [`text/x.cortav-intent]
    58     58   * [`CTVC] (the byte sequence [`0x43 54 56 43])
    59     59   
    60         -on systems which do not define a canonical way of encoding the filetype but support extended attributes of some kind, such as linux, an attribute named [$mime] may be created and given the value [`text/x-cortav] or [`text/x-cortav-intent]; alternatively, extensions may be used.
           60  +on systems which do not define a canonical way of encoding the filetype but support extended attributes of some kind, such as linux, an attribute named [$mime] may be created and given the value [`text/x.cortav] or [`text/x.cortav-intent]; alternatively, extensions may be used.
    61     61   
    62         -it is also possible to indicate the nature of a cortav file without using filesystem metadata. this is done by prefixing the file with a magic byte sequence. the sequence used depends on the encoding.
           62  +it is also possible to indicate the nature of a cortav file without using filesystem metadata. this is done by prefixing the file with a magic byte sequence. the sequence used depends on the encoding. currently, only sequences for UTF-8 and ASCII are defined, as these are the only encodings supported by the reference implementation. in the event that other implementations add support for other encodings, their sequences will be standardized here.
    63     63   * for UTF-8 and ASCII plain text files, [`%ct[!\\n]] (that is, the byte sequence [`0x25 63 74 0A]) should be used
    64         -* for C6B+PS files (parastream), the file should begin with the paragraph [`], which equates to the byte sequence [` 0x3E 2E 14 0C 01 04 00 00 00 03 07 3E 2D], including the parastream header).
    65     64   consequently, this sequence should be ignored by a cortav parser at the start of a file (except as an indication of file format).
    66     65   
    67     66   for FreeDesktop-based systems, the [`build/velartrill-cortav.xml] file included in the repository supplies mappings for the extensions and magic byte sequences. a script is also included which can be registered with xdg-open so that double-clicking on a cortav file will render it out and open it in your default web browser. [`$ make install] will generate the necessary FreeDesktop XML files and register them, as well as install the script and the [`cortav] executable itself. for more information see [>refimpl-build building the reference implementation].
    68     67   
           68  +##levels levels
           69  +not all of cortav's features make sense in every context. for this reason, cortav defines N [!levels] of compliance. for example, a social media platform that enables simple paragraph styling and linking using cortav syntax may claim to be "cortav level 1 compliant". every level [=N] is a strict superset of level [=N-1].
           70  +* level 1: [*styling]. simple inline formatting sequences like strong, emphatic, literal, links, etc. math equation styling need not be supported. paragraphs, lists, and references are the only block elements supported. suitable for styling tweets and other very short content.
           71  +* level 2: [*layout]. implements header, paragraph, newline, directive, and reference block elements. supports resources at least for remote or attached images. suitable for longer social media posts.
           72  +* level 3: [*publishing]. implements all currently standardized core behavior, including zero or more extensions.
           73  +* level 4: [*reference]. implements all currently standardized behavior, including [!all] standardized extensions.
           74  +
           75  +! note that which translators are implemented is not specified by level, as this is, naturally, implementation-dependent. (it would make rather little sense for the blurb parser of a cortav-enabled blog engine to support generating PDFs, after all.) level encodes only which features of the cortav [!language] are supported.
           76  +
    69     77   ##onblocks structure
    70         -cortav is based on an HTML-like block model, where a document consists of sections, which are made up of blocks, which may contain a sequence of spans. flows of text are automatically conjoined into spans, and blocks are separated by one or more newlines. this means that, unlike in markdown, a single logical paragraph [*cannot] span multiple ASCII lines. the primary purpose of this was to ensure ease of parsing, but also, both markdown and cortav are supposed to be readable from within a plain text editor. this is the 21st century. every reasonable text editor supports soft word wrap, and if yours doesn't, that's entirely your own damn fault.
           78  +cortav is based on an HTML-like block model, where a document consists of sections, which are made up of blocks, which may contain a sequence of spans. flows of text are automatically conjoined into spans, and blocks are separated by one or more newlines. this means that, unlike in markdown, a single logical paragraph [*cannot] span multiple ASCII lines. the primary purpose of this was to ensure ease of parsing, but also, both markdown and cortav are supposed to be readable from within a plain text editor. this is the 21st century. every reasonable text editor supports soft word wrap, and if yours doesn't, that's entirely your own damn fault. hard-wrapping lines is incredibly user-hostile, especially to users on mobile devices with small screens. cortav does not allow it.
    71     79   
    72     80   the first character(s) of every line (the "control sequence") indicates the role of that line. if no control sequence is recognized, the line is treated as a paragraph. the currently supported control sequences are listed below. some control sequences have alternate forms, in order to support modern, readable unicode characters as well as plain ascii text.
    73     81   
    74     82   * [*paragraphs] ([`.] [` ¶] [`❡]): a paragraph is a simple block of text. the period control sequence is only necessary if the paragraph text starts with text that would be interpreted as a control sequence otherwise
    75     83   * newlines [` \\]: inserts a line break into previous paragraph and attaches the following text. mostly useful for poetry or lyrics
    76         -* [*section starts] [`#] [`§]: starts a new section. all sections have an associated depth, determined by the number of sequence repetitions (e.g. "###" indicates depth-three"). sections may have headers and IDs; both are optional. IDs, if present, are a sequence of raw-text immediately following the hash marks. if the line has one or more space character followed by styled-text, a header will be attached. the character immediately following the hashes can specify a particular type of section. e.g.:
           84  +* [*section starts] [`#] [`§]: starts a new section. all sections have an associated depth, determined by the number of sequence repetitions (e.g. "###" indicates depth three). sections may have headers and IDs; both are optional. IDs, if present, are a sequence of raw-text immediately following the hash marks. if the line has one or more space character followed by styled-text, a header will be attached. the character immediately following the hashes can specify a particular type of section. e.g.:
    77     85   ** [`#] is a simple section break.
    78     86   ** [`#anchor] opens a new section with the ID [`anchor].
    79     87   ** [`# header] opens a new section with the title "header".
    80     88   ** [`#anchor header] opens a new section with both the ID [`anchor] and the title "header".
    81         -* [*nonprinting sections] ([`^]): sometimes, you'll want to create a namespace without actually adding a visible new section to the document. you can achieve this by creating a [!nonprinting section] and defining resources within it. nonprinting sections can also be used to store comments, notes, or other information that is useful to have in the source file without it becoming a part of the output
    82         -* [*resource] ([`@]): defines a [!resource]. a resource is an file or object that exists outside of the document but which will be included in the document somehow. common examples of resources include images, videos, iframes, or headers/footers. see [>rsrc resources] for more information.
    83         -* [*lists] ([`*] [`:]): these are like paragraph nodes, but list nodes that occur next to each other will be arranged so as to show they compose a sequence. depth is determined by the number of stars/colons. like headers, a list entry may have an ID that can be used to refer back to it; it is indicated in the same way. if colons are used, this indicates that the order of the items is signifiant. :-lists and *-lists may be intermixed; however, note than only the last character in the sequence actually controls the depth type.
    84         -* [*directives] ([`%]): a directive issues a hint to the renderer in the form of an arbitrary string. directives are normally ignored if they are not supported, but you may cause a warning to be emitted where the directive is not supported with [`%!] or mark a directive critical with [`%!!] so that rendering will entirely fail if it cannot be parsed.
           89  +* [*nonprinting sections] ([`^]): sometimes, you'll want to create a namespace without actually adding a visible new section to the document. you can achieve this by creating a [!nonprinting section] and defining resources within it. nonprinting sections can also be used to store comments, notes, to-dos, or other meta-information that is useful to have in the source file without it becoming a part of the output. nonprinting sections can be used for a sort of "literate markup," where resource and reference definitions can intermingle with human-readable narrative about those definitions.
           90  +* [*resource] ([`@]): defines a [!resource]. a resource is a file or object that exists outside of the document but which will are to be included in the document somehow. common examples of resources include images, videos, iframes, or headers/footers. see [>rsrc resources] for more information.
           91  +* [*lists] ([`*] [`:]): these are like paragraph nodes, but list nodes that occur next to each other will be arranged so as to show they compose a sequence. depth is determined by the number of stars/colons. like headers, a list entry may have an ID that can be used to refer back to it; it is indicated in the same way. if colons are used, this indicates that the order of the items is signifiant. [`:]-lists and [`*]-lists may be intermixed; however, note than only the last character in the sequence actually controls the type. a blank line terminates the current list.
           92  +* [*directives] ([`%]): a directive issues a hint to the renderer in the form of an arbitrary string. directives are normally ignored if they are not supported, but you may cause a warning to be emitted where the directive is not supported with [`%!] or mark a directive critical with [`%!!] so that rendering will entirely fail if it cannot be obeyed.
    85     93   * [*comments] ([`%%]): a comment is a line of text that is simply ignored by the renderer.
    86     94   * [*asides] ([`!]): indicates text that diverges from the narrative, and can be skipped without interrupting it. think of it like block-level parentheses. asides which follow one another are merged as paragraphs of the same aside, usually represented as a sort of box. if the first line of an aside contains a colon, the stretch of styled-text from the beginning to the aside to the colon will be treated as a "type heading," e.g. "Warning:"
    87     95   * [*code] ([`~~~]): a line beginning with ~~~ begins or terminates a block of code. code blocks are by default not parsed, but parsing can be activated by preceding the code block with an [`%[*expand]] directive. the opening line should look like one of the below
    88     96   ** [`~~~]
    89     97   ** [`~~~ language] (markdown-style shorthand syntax)
    90     98   ** [`~~~ \[language\] ~~~] (cortav syntax)
    91     99   ** [`~~~ \[language\] #id ~~~]
................................................................................
    92    100   ** [`~~~ title ~~~]
    93    101   ** [`~~~ title \[language\] ~~~]
    94    102   ** [`~~~ \[language\] title ~~~]
    95    103   ** [`~~~ title \[language\] #id ~~~]
    96    104   *[*reference] (tab): a line beginning with a tab is treated as a "reference." references hold out-of-line metadata for preceding text like links and footnotes. a reference consists of an identifier followed by a colon and an arbitrary number of spaces or tabs, followed by text. whether this text is interpreted as raw-text or styled-text depends on the context in which the reference is used. in encodings without tab characters, two preceding blanks can be used instead.
    97    105   * [*quotation] ([`<]): a line of the form [`<[$name]> [$quote]] denotes an utterance by [$name].
    98    106   * [*blockquote] ([`>]): alternate blockquote syntax. can be nested by repeating the [`>] character.
    99         -* [*subtitle] ([`--]): attaches a subtitle to the previous header
          107  +* [*subtitle/caption] ([`\--]): attaches a subtitle to the previous header, or caption to the previous object
   100    108   * [*embed] ([`&]): embeds a referenced object. can be used to show images or repeat previously defined objects like lists or tables, optionally with a caption.
   101    109   ** [`&$[$macro] [$arg1]|[$arg2]|[$argn]…] invokes a block-level macro with the supplied arguments
   102    110   *** [`&$mymacro arg 1|arg 2|arg 3]
   103    111   ** [`&[$image]] embeds an image or other block-level object. [!image] can be a reference with a url or file path, or it can be an embed section (e.g. for SVG files)
   104    112   ***[`&myimg All that remained of the unfortunate blood magic pageant contestants and audience (police photo)]
   105         -** [`&-[$section] [$styled-text]] embeds a closed disclosure element. in interactive outputs, this will display as a block [!section] which can be clicked on to view the full contents of the referenced section; if [$styled-text] is present, it overrides the title of the section you are embedding. in static outputs, the disclosure object will display as an enclosed box with [$styled-text] as the title text
          113  +** [`&-[$ident] [$styled-text]] embeds a closed disclosure element containing the text of the named object (a nonprinting section or cortav resource should usually be used to store the content; it can also name an image or video, of course). in interactive outputs, this will display as a block which can be clicked on to view the full contents of the referenced object [$ident]; if [$styled-text] is present, it overrides the title of the section you are embedding (if any). in static outputs, the disclosure object will display as an enclosed box with [$styled-text] as the title text
   106    114   *** [`&-ex-a Prosecution Exhibit A (GRAPHIC CONTENT)]
   107    115   ** [`&+[$section] [$styled-text]] is like the above, but the disclosure element is open by default
   108         -* [*horizontal rule] ([`\---]): inserts a horizontal rule or other context break; does not end the section. must be followed by newline. underlines can also be used in place of dashes.
   109         -* [*page break] ([`\^^]): for formats that support pagination, like HTML (when printed), indicates that the rest of the current page should be blank. for formats that do not, extra margins will be inserted. does not create a new section
   110         -* [*page rule] ([`\^-^]): inserts a page break for formats that support them, and a horizontal rule for formats that do not. does not create a new section
          116  +* [*horizontal rule] ([`\---]): inserts a horizontal rule or other context break; does not end the section. must be followed by newline. underlines can also be used in place of dashes ([`___], [`-_-], [`__-__-__] etc), as can horizontal unicode box drawing characters ([`─ ━ ┈] etc).
          117  +* [*page break] ([`\^^]): for formats that support pagination, like EPUB or HTML (when printed), indicates that the rest of the current page should be blank. for formats that do not, extra margins will be inserted. does not create a new section
          118  +* [*page rule] ([`\^-^]): inserts a page break for formats that support them, and a horizontal rule for formats that do not. does not create a new section. comprised of any number of horizontal rule characters surrounded by a pair of carets (e.g. [`^-^] [`^_^] [`^----^] [`^__--^] [`^┈┈┈┈┈^])
   111    119   * [*table cells] ([`+ |]): see [>ex.tab table examples].
   112         -* [*equations] ([`=]) block-level equations can be inserted with the [`=]
          120  +* [*equations] ([`=]): block-level equations can be inserted with the [`=] sequence
          121  +* [*cross-references] ([`=>] [`⇒]): inserts a block-level link. uses the same syntax as span links ([`⇒[$ident] [$styled-text]]). can be followed by a caption to add a longer descriptive text. especially useful for gemtext output. ident can be omitted to cross-reference, for example, a physical book.
   113    122   * [*empty lines] (that is, lines consisting of nothing but whitespace) constitute a [!break], which terminates multiline objects that do not have a dedicated termination sequence, for example lists and asides.
   114    123   
   115    124   ##onspans styled text
   116    125   most blocks contain a sequence of spans. these spans are produced by interpreting a stream of [*styled-text] following the control sequence. styled-text is a sequence of codepoints potentially interspersed with escapes. an escape is formed by an open square bracket [`\[] followed by a [*span control sequence], and arguments for that sequence like more styled-text. escapes can be nested.
   117    126   
   118    127   * strong {obj *|styled-text}: causes its text to stand out from the narrative, generally rendered as bold or a brighter color.
   119    128   * emphatic {obj !|styled-text}: indicates that its text should be spoken with emphasis, generally rendered as italics
................................................................................
   121    130   * literal {obj `|styled-text}: indicates that its text is a reference to a literal sequence of characters or other discrete token. generally rendered in monospace
   122    131   * variable {obj $|styled-text}: indicates that its text is a stand-in that will be replaced with what it names. generally rendered in italic monospace, ideally of a different color
   123    132   * underline {obj _|styled-text}: underlines the text. use sparingly on text intended for webpages -- underlined text  [!is] distinct from links, but underlining non-links is still a violation of convention.
   124    133   * strikeout {obj ~|styled-text}: indicates that its text should be struck through or otherwise indicated for deletion
   125    134   * insertion {obj +|styled-text}: indicates that its text should be indicated as a new addition to the text body.
   126    135   ** consider using a macro definition [`\edit: [~[#1]][+[#2]]] to save typing if you are doing editing work
   127    136   * link \[>[!ref] [!styled-text]\]: produces a hyperlink or cross-reference denoted by [$ref], which may be either a URL specified with a reference or the name of an object like an image or section elsewhere in the document. the unicode characters [`→] and [`🔗] can also be used instead of [`>] to denote a link.
   128         -* footnote {span ^|ref|[$styled-text]}: annotates the text with a defined footnote. in interactive output media [`\[^citations.qtheo Quantum Theosophy: A Neophyte's Catechism]] will insert a link with the next [`Quantum Theosophy: A Neophyte's Catechism] that, when clicked, causes a footnote to pop up on the screen. for static output media, the text will simply have a superscript integer after it denoting where the footnote is to be found.
          137  +* footnote {span ^|ref|[$styled-text]}: annotates the text with a defined footnote. in interactive output media [`\[^citations.qtheo Quantum Theosophy: A Neophyte's Catechism]] will insert a link with the text [`Quantum Theosophy: A Neophyte's Catechism] that, when clicked, causes a footnote to pop up on the screen. for static output media, the text will simply have a superscript integer after it denoting where the footnote is to be found.
   129    138   * superscript {obj '|[$styled-text]}
   130    139   * subscript {obj ,|[$styled-text]}
   131    140   * raw {obj \\ |[$raw-text]}: causes all characters within to be interpreted literally, without expansion. the only special characters are square brackets, which must have a matching closing bracket, and backslashes.
   132    141   * raw literal \[$\\[!raw-text]\]: shorthand for [\[$[\…]]]
   133         -* macro [`\{[!name] [!arguments]\}]: invokes a [>ex.mac macro], specified with a reference
          142  +* macro [` \{[!name] [!arguments]}]: invokes a [>ex.mac macro], specified with a reference
   134    143   * argument {obj #|var}: in macros only, inserts the [$var]-th argument. otherwise, inserts a context variable provided by the renderer.
   135    144   * raw argument {obj ##|var}: like above, but does not evaluate [$var].
   136    145   * term {obj &|name}, {span &|name|[$expansion]}: quotes a defined term with a link to its definition, optionally with a custom expansion of the term (for instance, to expand the first use of an acronym)
   137    146   * inline image {obj &@|name}: shows a small image or other object inline. the unicode character [`🖼] can also be used instead of [`&@].
   138    147   * unicode codepoint {obj U+|hex-integer}: inserts an arbitrary UCS codepoint in the output, specified by [$hex-integer]. lowercase [`u] is also legal.
   139    148   * math mode {obj =|equation}: activates additional transformations on the span to format it as a mathematical equation; e.g. [`*] becomes [`×] and [`/] --> [`÷].
   140    149   * extension {span %|ext|…}: invokes extension named in [$ext]. [$ext] will usually be an extension name followed by a symbol (often a period) and then an extension-specific directive, although for some simple extensions it may just be the plain extension name. further syntax and semantics depend on the extension. this syntax can also be used to apply formatting specific to certain renderers, such as assigning a CSS class in the [`html] renderer ([`\[%html.myclass my [!styled] text]]).
................................................................................
   158    167   
   159    168   ##ident identifiers
   160    169   any identifier (including a reference) that is defined within a named section must be referred to from outside that section as [`[!sec].[!obj]], where [$sec] is the ID of the containing section and [$obj] is the ID of the object one wishes to reference.
   161    170   
   162    171   ##rsrc resources
   163    172   a [!resource] represents content that is not encoded directly into the source file, but which is embedded by some means in the output. resources can either be [!embedded], in which case they are compiled into the final document itself, or they can be [!linked], in which case the final document only contains a URI or similar tag referencing the resource. not all render backends support both linking and embedding embedding, nor do all backends support all object types (for instance, [`groff] does not support video embedding.)
   164    173   
   165         -a resource definition is begun by line consisting of an [`@] sign and an [>ident identifier]. this line is followed by any number of parameters. a parameter is a line beginning with a single tab, a keyword, a colon, and a then a value. additional lines can be added to a parameter by following it with a line that consists of two tabs followed by the text you wish to add. (this is the same syntax used by references.) a resource definition is terminated by a break, or any line that does not begin with a tab
          174  +a resource definition is begun by line consisting of an [`@] sign and an [>ident identifier].  this line is followed by any number of parameters. a parameter is a line beginning with a single tab, a keyword, a colon, and a then a value. additional lines can be added to a parameter by following it with a line that consists of two tabs followed by the text you wish to add. (this is the same syntax used by references.) a resource definition is terminated by a break, or any line that does not begin with a tab
   166    175   
   167    176   a resource definition in use looks like this:
   168    177   
   169         -~~~
          178  +~~~cortav
   170    179   this is a demonstration of resources
   171    180   @smiley
   172    181   	src: link image/webp http://cdn.example.net/img/smile.webp
   173    182   		  link image/png file:img/smile.png
   174    183   		  embed image/gif file img/smile.gif
   175    184   	desc: the Smiling Man would like to see you in his office
   176    185   here is the resource in span context [&smiley]
   177    186   and here it is in block context:
   178    187   &smiley
   179    188   ~~~
   180    189   
   181    190   rendered as HTML, this might produce the following:
   182    191   
   183         -~~~
          192  +~~~html
   184    193   <style>
   185    194   	.res-smiley {
   186    195   		content: image-set(
   187    196   			url(http://cdn.example.net/img/smile.webp) type(image/webp),
   188    197   			url(img/smile.png) type(image/png),
   189    198   			url(data:image/gif;base64,/* … */) type(image/gif)
   190    199   		); /* this will actually be repeated with a -webkit- prefix */
................................................................................
   193    202   <p>this is a demonstration of resources</p>
   194    203   <p>here is the resource in span context: <span class="res-smiley"></span></p>
   195    204   <p>and here it is in block context:</p>
   196    205   <div class=".res-smiley"></div>
   197    206   ~~~
   198    207   
   199    208   note that empty elements with CSS classes are used in the output, to avoid repeating long image definitions (especially base64 inline encoded ones!)
          209  +
          210  +in the opening line of a resource declaration, the identifier can be omitted. in this case, rather than registering a new resource in the current section, the resource will be inserted as a block at the position where it is defined. this is a shorthand for resources that are only used once. for resources used inline or multiple times, an identifier must be defined.
          211  +
          212  +as an additional shortcut, a resource with only one source file can place its source specification on the opening line, separated by whitespace from the opening sequence. this means that the following are identical.
          213  +
          214  +~~~cortav
          215  +@smiley link image/webp file:smile.webp
          216  +	desc: the Smiling Man would like to see you in his office
          217  +
          218  +@smiley
          219  +	src: link image/webp file:smile.webp
          220  +	desc: the Smiling Man would like to see you in his office
          221  +~~~
          222  +
          223  +this can be combined with ID omission for a very concise block-level image syntax.
          224  +
          225  +~~~cortav
          226  +@smiley
          227  +	src: link image/webp file:smile.webp
          228  +&smiley
          229  +
          230  +%% is the same as
          231  +
          232  +@smiley link image/webp file:smile.webp
          233  +&smiley
          234  +
          235  +%% is the same as
          236  +
          237  +@ link image/webp file:smile.webp
          238  +
          239  +%% is almost the same as
          240  +
          241  +@ image/webp;base64 (*
          242  +	%% inhuman gurgling in textual form
          243  +*)
          244  +
          245  +%% (except that the last wil require embedding)
          246  +~~~
   200    247   
   201    248   inline resources are defined a bit differently:
   202    249   
   203    250   ~~~cortav
   204    251   @smiling-man-business-card text/plain {
   205    252   	THE SMILING MAN  | tel. 0-Ω00-666█
   206    253   	if you can read this | email: nameless@smiles.gov
................................................................................
   209    256   @smiling-man-business-card image/png;base64 {
   210    257   	%% incomprehensible gibbering redacted
   211    258   }
   212    259   ~~~
   213    260   
   214    261   for an inline resource, the identifier is followed by a MIME type and an opening bracket. the opening bracket may be any of the characters [`\{][`\[][`(][`<], and can optionally be followed by additional characters to help disambiguate the closing bracket. the closing bracket is determined by "flipping" the opening bracket, producing bracket pairs like the following:
   215    262   * [`\{:][`:}]
   216         -* [`<!--] [`--!>]
          263  +* [`\<!--] [`\--!>]
   217    264   * [`(*<][`>*)]
   218    265   * [`<>][`<>] [!(disables nesting!)]
   219         -if the open and closing brackets are distinguishable, they will nest appropriately, meaning that [`{][`}] alone is very likely to be a safe choice to escape a syntactically correct C program (that doesn't abuse macros too badly). brackets are searched for during parsing; encoded resources are not decoded until a later stage, so a closing bracket character in a base64-encoded text file cannot break out of its escaping.
          266  +if the open and closing brackets are distinguishable, they will nest appropriately, meaning that [`\{][`\}] alone is very likely to be a safe choice to escape a syntactically correct C program (that doesn't abuse macros too badly). brackets are searched for during parsing; encoded resources are not decoded until a later stage, so a closing bracket character in a base64-encoded text file cannot break out of its escaping.
   220    267   
   221    268   as a convenience, if the first line of the resource definition begins with a single tab, one tab will be dropped from every following line in order to allow legible indentation. similarly, if an opening bracket is followed immediately by a newline, this newline is discarded.
   222    269   
   223         -text within a resource definition body is not expanded unless the resource definition is preceded with an [`%[*expand]] directive. if an expand directive is found, the MIME type will be used to try and determine an appropriate type of formatting, potentially invoking a separate renderer. for example, [`text/html] will invoke the [`html] backend, and [`application/x-troff] will invoke the [`groff] backend. if no suitable renderer is available, expansions will generate only plain text.
          270  +text within a resource definition body is not expanded unless the resource definition is preceded with an [`%[*expand]] directive or the resource MIME type is [`text/x.cortav]. if an expand directive is found, the MIME type will be used to try and determine an appropriate type of formatting, potentially invoking a separate renderer. for example, [`text/html] will invoke the [`html] backend, and [`application/x-troff] will invoke the [`groff] backend. if no suitable renderer is available, expansions will generate only plain text.
   224    271   
   225    272   two suffixes are accepted: [`;base64] and [`;hex]. the former will decode the presented strings using the base64 algorithm to obtain the resources data; the second will ignore all characters but ASCII hexadecimal digits and derive the resource data byte-by-byte by reading in hexadecimal pairs. for instance, the following sections are equivalent:
   226    273   
   227         -~~~
          274  +~~~cortav
   228    275   @propaganda text/plain {
   229    276   	WORLDGOV SAYS
   230    277   	“don't waste time with unproductive thoughts
   231    278   	 your wages will be docked accordingly”
   232    279   }
   233    280   ~~~
   234         -~~~
          281  +~~~cortav
   235    282   @propaganda text/plain;hex {
   236    283   	574f 524c 4447 4f56 2053 4159 530a e280 9c64 6f6e 2774 2077 6173
   237    284   	7465 2074 696d 6520 7769 7468 2075 6e70 726f 6475 6374 6976 6520
   238    285   	7468 6f75 6768 7473 0a20 796f 7572 2077 6167 6573 2077 696c 6c20
   239    286   	6265 2064 6f63 6b65 6420 6163 636f 7264 696e 676c 79e2 809d 0a
   240    287   }
   241    288   ~~~
   242         -~~~
          289  +~~~cortav
   243    290   @propaganda text/plain;base64 {
   244    291   	V09STERHT1YgU0FZUwrigJxkb24ndCB3YXN0ZSB0aW1lIHdpdGggdW5wcm9kdWN0aXZlIHRob3Vn
   245    292   	aHRzCiB5b3VyIHdhZ2VzIHdpbGwgYmUgZG9ja2VkIGFjY29yZGluZ2x54oCdCg==
   246    293   }
   247    294   ~~~
   248    295   
   249         -inline resources can also be (ab)used for multiline macros:
   250         -~~~
   251         -@def text/x-cortav {
          296  +inline resources can also offer a cleaner syntax for complex multiline macros.
          297  +~~~cortav
          298  +@def text/x.cortav {
   252    299   	* [*[#1]] [!([#2])
   253    300   	*: [#3]
   254    301   }
   255    302   &def nuclear bunker|n|that which will not protect you from the Smiling Man
   256    303   ~~~
   257         -to make this usage simpler, resources with a type of [`text/x-cortav] can omit the MIME type field.
          304  +to make this usage simpler, resources with a type of [`text/x.cortav] can omit the MIME type field.
          305  +
          306  +inline resources are a great way to extend cortav with implementation-dependent features. say you want mathtex in your cortav renderer -- all you have to do is support a new MIME type [`text/x.mathtex], and then the users can embed their math equations like so:
          307  +
          308  +~~~cortav
          309  +and as we see from the value of κ below, Bose-Fleischer-Kincaid entities of Carlyle subtype γ lack interaction with the putative "Higgs field" of Athabaskan Windchime Theory, seemingly ruling out any possibility of direct interaction with the spacetime metric, and consequently removing the maximal density "limitations" that exist for bosonic matter.
          310  +@ text/x.mathtex {>
          311  +	%% divide subtract differentiate blah blah blah i don't know math
          312  +<}
          313  +given the selective cross-interaction of γ-BFKs, we conclude that, under the prevailing cosmocelestial paradigm, the answer to the age-old question of how many angels can dance on the head of a pin is "as many as would like to."
          314  +~~~
   258    315   
   259    316   ### supported parameters
   260         -* [`src] (all): specifies where to find the file, what it is, and how to embed it. each line of [`src] should consist of three whitespace-separated words: embed method, MIME type, and URI.
   261         -** embed methods
   262         -*** [`local]: loads the resource at build time and embeds it into the output file. not all implementations may allow loading remote network resources at build time.
   263         -*** [`remote]: only embeds a reference to the location of the resource. use this for e.g. live iframes, dynamic images, or images hosted by a CDN.
   264         -*** [`auto]: embeds a reference in file formats where that's practical, and use a remote reference otherwise.
          317  +* [`src] (all): specifies where to find the file, what it is, and how to embed it. each line of [`src] should consist of two  whitespace-separated words: MIME type and URI. the specification can also be prefixed with an extra word, [`auto], [`link], or [`embed], to control how the resource will be referenced from the output file.
          318  +** reference mode: the optional first word; if the requested reference mode is not applicable or valid for the output format or URI given, the source line will be skipped over.
          319  +*** [`embed]: loads the resource at build time and embeds it into the output file. not all implementations may allow loading remote network resources at build time.
          320  +*** [`link]: only embeds a reference to the location of the resource. use this for e.g. live iframes, dynamic images, or images hosted by a CDN.
          321  +*** [`auto]: embeds a reference in file formats where that's practical, and use a remote reference otherwise. [`auto] is the default if the first word is omitted.
   265    322   ** MIME types: which file types are supported depends on the individual implementation and renderer backend; additionally, extensions can add support for extra types. MIME-types that have no available handler will, where possible, result in an attachment that can be extracted by the user, usually by clicking on a link. however, the following should be usable with all compliant implementations
   266    323   *** [`image/*] (graphical outputs only)
   267    324   *** [`video/*] (interactive outputs only)
   268    325   *** [`image/svg+xml] is handled specially for HTML files, and may or may not be compatible with other renderer backends.
   269    326   *** [`font/*] can be used with the HTML backend to reference a web font
   270    327   *** [`font/woff2] can be used with the HTML backend to reference a web font
   271    328   *** [`text/plain] (will be inserted as a preformatted text block)
   272    329   *** [`text/css] (can be used when producing HTML files to link in an extra stylesheet, either by embedding it or referencing it from the header)
   273         -*** [`text/x-cortav] (will be parsed and inserted as a formatted text block; context variables can be passed to the file with [`ctx.[$var]] parameters)
          330  +*** [`text/x.cortav] (will be parsed and inserted as a formatted text block; context variables can be passed to the file by setting [`ctx.[$var]] parameters on the resource, e.g. [`ctx.recipient-name: Mr. Winthrop])
   274    331   *** [`application/x-troff] can be used to supply sections of text written in raw [`groff] syntax. these are ignored by other renderers.
   275         -*** [`text/html] can be used to supply sections of text written in raw HTML.
          332  +*** [`text/html] can be used to supply sections of text written in raw HTML. these are ignored by non-HTML outputs.
   276    333   *** any MIME-type that matches the type of file being generated by the renderer can be used to include a block of data that will be passed directly to the renderer.
   277    334   ** URI types: additional URI types can be added by extensions or different implementations, but every compliant implementation must support these URIs.
   278         -*** [`http], [`https]: accesses resources over HTTP. add a [`file] fallback if possible for the benefit of renderers/viewers that do not have internet access abilities.
   279         -*** [`file]: references local files. absolute paths should begin [`file:/]; the slash should be omitted for relative paths. note that this doesn't have quite the same meaning as in HTML -- [`file] can (and usually should be) used with HTML outputs to refer to resources that reside on the same server. a cortav URI of [`file:/etc/passwd] will actually result in the link [`/etc/passwd], not [`file:///etc/passwd] when converted to HTML. generally, you only should use [`http] when you're referring to a resource that exists on a different domain.
          335  +*** [`http], [`https]/[`http+tls]: accesses resources over HTTP. add a [`file] fallback if possible for the benefit of renderers/viewers that do not have internet access abilities.
          336  +*** [`file]: references local files. (the meaning of "local" varies depending on the translation format.) absolute paths should begin [`file:/]; the slash should be omitted for relative paths. note that this doesn't have quite the same meaning as in HTML -- [`file] can (and usually should be) used with HTML outputs to refer to resources that reside on the same server. a cortav URI of [`file:/etc/passwd] will actually result in the link [`/etc/passwd], not [`file:///etc/passwd] when converted to HTML. generally, you only should use [`http] when you're referring to a resource that exists on a different domain.
   280    337   *** [`name]: a special URI used generally for referencing resources that are already installed on a target system and do not need to be embedded or linked, the name and type are enough for a renderer on another machine to locate the correct resource. this is useful mostly for [>fonts fonts], where it's more typical to refer to fonts that are installed on your system rather than providing paths to font files.
   281    338   *** [`gemini]: accesses resources over the gemini protocol. currently you should really only use this for [`local] resources unless you're using the gemtext renderer backend, since nothing but gemini browsers are liable to support this protocol.
          339  +*** [`role]: specifies an abstract resource determined by context, e.g. [`role:backdrop], [`role:body-font]. for use by translators to formats which make provisions for viewer control. a [`role] URI is special in that it is never embedded; it always depends on context — user preferences, environment variables, system stylesheets, what have you — at the time the output file is viewed, rather than the time of the input file being rendered.
   282    340   * [`desc]: supplies a narrative description of the resources, for use as an "alt-text" when the image cannot be loaded and for screenreaders.
   283    341   * [`detail]: supplies extra narrative commentary that is displayed contextually, e.g. when the user hovers her mouse cursor over the embedded object. also used for [`desc] if [`desc] is not supplied.
   284    342   
   285    343   note that in certain cases, full MIME types do not need to be used. say you're defining a font with the [`name] URI -- you can't necessary know what file type the system fonts on another computer are going to be. in this case, you can just write [`font] instead of [`font/ttf] or [`font/woff2] or similar. all cortav needs to know in this case is what abstract kind of object you're referencing. [`groff] fonts (referenced with the [`dit] URI) don't have a specific MIME type either.
   286    344   
   287    345   
   288    346   ##ctxvar context variables
................................................................................
   307    365   
   308    366   when a document parse begins, the font stack is empty (unless a default font has already been loaded by an intent file).
   309    367   when the font stack is empty, cortav does not include font specifications in its output, and thus will use whatever the default of the various rendering programs is.
   310    368   
   311    369   to use fonts, we first have to define the fonts as [>rsrc resources].
   312    370   
   313    371   ~~~cortav
   314         -%% first, we create a new section to namespace the fonts
   315         -#^fonts
   316         -%% we then define each font as a resource
          372  +%% first, we create a new nonprinting section to namespace the fonts
          373  +^fonts
          374  +we then define each font as a resource:
   317    375   @serif
   318    376   	src: auto font name:Alegreya
   319    377   		embed  font/ttf file:project-fonts/alegreya.ttf
   320    378   		link font/woff2 file:/assets/font/alegreya.woff2
   321    379   		auto font name:Times New Roman
   322    380   		auto font dit:TR/bold=TRB/italic=TRI/bold,italic=TRBI
   323    381   @sans
................................................................................
   340    398   	font-family: "fontdef-sans";
   341    399   	src: local("Alegreya Sans"),
   342    400   		local("Open Sans"),
   343    401   		local("sans-serif");
   344    402   }
   345    403   ~~~
   346    404   
   347         -there are two things that aren't super clear from the CSS, however. notice how we used [`auto] on a couple of those specs? this means it's up to the renderer to decide whether to link or embed the font. in HTML, a font specified by name can't really be embedded, but for some file formats, it can be. [`auto] lets us produce valid HTML while still taking advantage of font embedding in other formats.
          405  +there are two things that aren't super clear from the CSS, however. notice how we used [`auto] on a couple of those specs? this means it's up to the renderer to decide whether to link or embed the font. [!in HTML], a font specified by name can't really be embedded, but for some translation formats such as PDF or PostScript, a system font can be selected by name and then embedded into the output. [`auto] lets us produce valid HTML while still taking advantage of font embedding in other formats.
   348    406   
   349         -now that we have our font families defined, we can use their identifiers with the [`%[*font]] directive to control the font stack. the first thing we need to do is push a new font context. there's two ways we can do this:
          407  +now that we have our font families defined, we can use their identifiers with the [`%[*font]] directive to control the font stack. the first thing we need to do is push a new font context, as the stack starts out empty. there's two ways we can do this:
   350    408   	fnd: [`%[*font] [#1]]
   351    409   * {fnd dup} will create a copy of the current font context, allowing us to make some changes and then revert later with the {fnd pop} command. this isn't useful in our case, however, because right now the stack is empty; there's nothing to duplicate.
   352    410   * {fnd new} will create a brand new empty context for us to work with and push it to the stack. this can also be used to temporarily revert to the system default fonts, and then switch back with {fnd pop}.
   353    411   * {fnd set} changes one or more entries in the current font context. it can take a space-separated list of arguments in the form [`[$entry]=[$font-id]]. the supported entries are:
   354    412   ** [`body]: the fallback font. if only this is set in a given font context, it will be used for everything
   355    413   ** [`paragraph]: the font used for normal paragraphs
   356    414   ** [`header]: the font used in headers
................................................................................
   452    510   * {d include} transcludes another file
   453    511   * {d import} reads in the contents of another file as an embeddable section
   454    512   * {d quote} transcludes another file, without expanding the text except for paragraphs 
   455    513   * {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.
   456    514   * {d expand} causes the next object (usually a code block) to be fully expanded when it would otherwise not be
   457    515   * {d font} controls the font stack, for outputs that support changing fonts. see [>fonts fonts] for more information.
   458    516   * {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
   459         -** {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 UTF-8. this might be used at the top of a document to set its primary language.
          517  +** {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.
   460    518   ** {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
   461    519   ** {d lang sec en-US} switches to American English for the duration of a section. does not affect the language stack.
   462    520   ** {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
   463    521   * {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.
   464    522   ** {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:
   465    523   *** [`essay]
   466    524   *** [`narrative]
................................................................................
   771    829   
   772    830   	corran: http://ʞ.cc/fic/spirals/society
   773    831   	tengwar: https://en.wikipedia.org/wiki/Tengwar
   774    832   
   775    833   ###refimpl-switches switches
   776    834   [`cortav.lua] offers various switches to control its behavior.
   777    835   + long                      + short + function                                    +
   778         -| [`--out [!file]]              :|:[`-o]:| sets the output file (default stdout)       |
   779         -| [`--log [!file]]              :|:[`-l]:| sets the log file (default stderr)          |
   780         -| [`--define [!var] [!val]]     :|:[`-d]:| sets the context variable [$var] to [$val]  |
   781         -| [`--mode-set [!mode]]         :|:[`-y]:| activates the [>refimpl-mode mode] with ID [!mode]
   782         -| [`--mode-clear [!mode]]       :|:[`-n]:| disables the mode with ID [!mode]           |
   783         -| [`--mode [!id] [!val]]        :|:[`-m]:| configures mode [!id] with the value [!val] |
   784         -| [`--mode-set-weak [!mode]]    :|:[`-Y]:| activates the [>refimpl-mode mode] with ID [!mode] if the source file does not specify otherwise
   785         -| [`--mode-clear-weak [!mode]]  :|:[`-N]:| disables the mode with ID [$mode] if the source file does not specify otherwise
   786         -| [`--mode-weak [!id] [!val]]   :|:[`-M]:| configures mode [$id] with the value [$val] if the source file does not specify otherwise
   787         -| [`--help]                     :|:[`-h]:| display online help                         |
   788         -| [`--version]                  :|:[`-V]:| display the interpreter version             |
          836  +| [`\--out [!file]]              :|:[`-o]:| sets the output file (default stdout)       |
          837  +| [`\--log [!file]]              :|:[`-l]:| sets the log file (default stderr)          |
          838  +| [`\--define [!var] [!val]]     :|:[`-d]:| sets the context variable [$var] to [$val]  |
          839  +| [`\--mode-set [!mode]]         :|:[`-y]:| activates the [>refimpl-mode mode] with ID [!mode]
          840  +| [`\--mode-clear [!mode]]       :|:[`-n]:| disables the mode with ID [!mode]           |
          841  +| [`\--mode [!id] [!val]]        :|:[`-m]:| configures mode [!id] with the value [!val] |
          842  +| [`\--mode-set-weak [!mode]]    :|:[`-Y]:| activates the [>refimpl-mode mode] with ID [!mode] if the source file does not specify otherwise
          843  +| [`\--mode-clear-weak [!mode]]  :|:[`-N]:| disables the mode with ID [$mode] if the source file does not specify otherwise
          844  +| [`\--mode-weak [!id] [!val]]   :|:[`-M]:| configures mode [$id] with the value [$val] if the source file does not specify otherwise
          845  +| [`\--help]                     :|:[`-h]:| display online help                         |
          846  +| [`\--version]                  :|:[`-V]:| display the interpreter version             |
   789    847   
   790    848   ###refimpl-mode modes
   791    849   most of [`cortav.lua]'s implementation-specific behavior is controlled by use of [!modes]. these are namespaced options which may have a boolean, string, or numeric value. boolean modes are set with the [`-y] [`-n] flags; other modes use the [`-m] flags.
   792    850   
   793    851   most modes are defined by the renderer backend. the following modes affect the behavior of the frontend:
   794    852   
   795    853   + ID                 + type   + effect
................................................................................
   869    927   if the [`toc] extension is active but [`%[*toc]] directive is provided, the table of contents will be given its own section at the start of the document (after the title page, if any).
   870    928   
   871    929   ## further directions
   872    930   
   873    931   ### additional backends
   874    932   it is eventually intended to support to following backends, if reasonably practicable.
   875    933   * [*html]: emit HTML and CSS code to typeset the document. [!in progress]
   876         -* [*svg]: emit SVG, taking advantage of its precise layout features to produce a nicely formatted and paginated document. pagination can be accomplished through emitting multiple files or by assigning one layer to each page. [!long term]
   877         -* [*groff]: the most important output backend, rivalling [*html]. will allow the document to be typeset in a wide variety of formats, including PDF and manpage. [!short term]
          934  +* [*svg]: emit SVG, taking advantage of its precise layout features to produce a nicely formatted and paginated document. pagination can perhaps be accomplished through emitting multiple files (somewhat problematic) or by assigning one layer to each page. [!long term]
          935  +* [*groff]: the most important output backend, rivalling [*html]. will allow the document to be typeset in a wide variety of formats, including PDF and manpage. [!in progress]
   878    936   * [*gemtext]: essentially a downrezzing of cortav to make it readable to Gemini clients
   879    937   * [*ast]: produces a human- and/or machine-readable dump of the document's syntax tree, to aid in debugging or for interoperation with systems that do not support `cortav` direcly. mode [`ast:repr] wil allow selecting formats for the dump. [`ast:rel] can be [`tree] (the default) to emit a hierarchical representation, or [`flat] to emit an array of nodes that convey hierarchy [^flatdoc by naming one another], rather than being placed inside one another. [`tree] is easier for humans to parse; [`flat] is easier for computers. origin information can be included for each node with the flag [`ast:debug-syms], but be aware this will greatly increase file size.
   880    938   ** [`tabtree] [!(default)]: a hierarchical tree view, with the number of tabs preceding an item showing its depth in the tree
   881    939   ** [`sexp]
   882    940   ** [`binary]: emit a raw binary format that is easier for programs to read. maybe an lmdb or cdb file?
   883         -** [`json]
          941  +** [`json]: obligatory, alas
   884    942   
   885    943   	flatdoc: ~~~flat sexp example output [scheme]~~~
   886    944   		(nodes
   887    945   			(section (id . "section1")
   888    946   				(anchor "introduction")
   889    947   				(kind . "ordinary")
   890    948   				(label . "section1-heading")
................................................................................
   951   1009   ### LCH support
   952   1010   right now, the use of color in the HTML renderer is very unsatisfactory. the accent mechanism operates on the basis of the CSS HSL function, which is not perceptually uniform; different hues will present different mixes of brightness and some (yellows?) may be ugly or unreadable.
   953   1011   
   954   1012   the ideal solution would be to simply switch to using LCH based colors. unfortunately, only Safari actually supports the LCH color function right now, and it's unlikely (unless Lea Verou and her husband manage to work a miracle) that Colors Level 4 is going to be implemented very widely any time soon.
   955   1013   
   956   1014   this leaves us in an awkward position. we can of course do the math ourselves, working in LCH to implement the internal [`@tone] macro, and then "converting" these colors to HSL. unfortunately, you can't actually convert from LCH to HSL; it's like converting from pounds to kilograms. LCH can represent any color the human visual system can perceive; sRGB can't, and CSS HSL is implemented in sRGB. however, we could at least approximate something that would allow for perceptually uniform brightness, which would be an improvement, and this is probably the direction to go in, unless a miracle occurs and [`lch()] or [`color()] pop up in Blink.
   957   1015   
   958         -it may be possible to do a more reasonable job of handling colors in the postscript and TeX outputs. unsure about SVG but i assume it suffers the same problems HTML/CSS do. does groff even support color??
         1016  +it may be possible to do a more reasonable job of handling colors in the postscript and TeX outputs. unsure about SVG but i assume it suffers the same problems HTML/CSS do. groff lets us choose between [`rgb] and [`cmyk] for specifying color, with no explanation of what those mean.
         1017  +
         1018  +currently all internal colors are expressed and stored as HSL, and we're using code borrowed from my Minetest mod [`[>sorcrep sorcery]] & written by glowpelt for converting that into RGB for non-HTML outputs like groff. probably what should be done is to switch to LCH internally, accept both HSL and LCH input, and "downres" to the best representation each format can support. that's probably going to have to wait until someone who knows a bit more about color theory and math than me can do it (paging Lea Verou)
         1019  +
         1020  +	sorcrep: https://c.hale.su/sorcery
   959   1021   
   960   1022   ### intent files
   961   1023   there's currently no standard way to describe the intent and desired formatting of a document besides placing pragmata in the source file itself. this is extremely suboptimal, as when generating collections of documents, it's ideal to be able to keep all formatting information in one place. users should also be able to specify their own styling overrides that describe the way they prefer to read [`cortav] files, especially for uses like gemini or gopher integration.
   962   1024   
   963   1025   at some point soon [`cortav] needs to address this by adding intent files that can be activated from outside the source file, such as with a command line flag or a configuration file setting. these will probably consist of lines that are interpreted as pragmata. in addition to the standard intent format however, individual implementations should feel free to provide their own ways to provide intent metadata; e.g. the reference implementation, which has a lua interpreter available, should be able to take a lua script that runs after the parse stage and generates . this will be particularly useful for the end-user who wishes to specify a particular format she likes reading her files in without forcing that format on everyone she sends the compiled document to, as it will be able to interrogate the document and make intelligent decisions about what pragmata to apply.
   964   1026   
   965   1027   intent files should also be able to define [>rsrc resources], [>ctxvar context variables], and macros.