Overview
Comment: | add rudimentary syntax hiliting for kate/kwrite/kdepart |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
87fed4ec344b47289992a1eb59eada5a |
User & Date: | lexi on 2021-12-19 18:12:38 |
Other Links: | manifest | tags |
Context
2021-12-20
| ||
00:09 | split cortav into modules, enable use as library, create extension mechanism stub, fix up docs check-in: 9c67b0312c user: lexi tags: trunk | |
2021-12-19
| ||
18:12 | add rudimentary syntax hiliting for kate/kwrite/kdepart check-in: 87fed4ec34 user: lexi tags: trunk | |
05:25 | further develop html renderer and document it, many doc fixes, fix misc bugs check-in: 2e37b523b5 user: lexi tags: trunk | |
Changes
Modified cortav.ct from [6a93030d29] to [fcb217abd6].
15 15 16 16 ## structure 17 17 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. 18 18 19 19 the first character(s) of every line (the "control sequence") indicates the role of that line. if no control sequence is recognized, the sequence [$.] is implied instead. the standard line classes and their associated 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. 20 20 21 21 * paragraphs (. ΒΆ β‘): a paragraph is a simple block of text. the period control sequence is only necessary if the paragraph text begins with something that would otherwise be interpreted as a control sequence. 22 -* newlines (\): inserts a line break into previous paragraph and attaches the following text. mostly useful for poetry or lyrics. 22 +* newlines (\\): inserts a line break into previous paragraph and attaches the following text. mostly useful for poetry or lyrics. 23 23 * 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.: 24 24 ** [$#] is a simple section break. 25 25 ** [$#anchor] opens a new section with the ID [$anchor]. 26 26 ** [$# header] opens a new section with the title "header". 27 27 ** [$#anchor header] opens a new section with both the ID [$anchor] and the title "header". 28 28 ** [$#>conversation] opens a blockquote section named [$conversation] without a header. 29 29 ** [$#^id] opens a footnote section for the multiline footnote [$id]. the ID must be specified. ................................................................................ 54 54 55 55 ## styled text 56 56 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. 57 57 58 58 * strong \[*[!styled-text]\]: causes its text to stand out from the narrative, generally rendered as bold or a brighter color. 59 59 * emphatic \[![!styled-text]\]: indicates that its text should be spoken with emphasis, generally rendered as italics 60 60 * literal \[$[!styled-text]\]: indicates that its text is a reference to a literal sequence of characters, variable name, or other discrete token. generally rendered in monospace 61 +* strikeout \[$[~styled-text]\]: indicates that its text should be struck through or otherwise indicated for deletion 62 +* insertion \[$[+styled-text]\]: indicates that its text should be indicated as a new addition to the text body. 63 +** consider using a macro definition [$\edit: [~[#1]][+[#2]]] to save typing if you are doing editing work 61 64 * 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. 62 65 * footnote \[^[!ref] [!styled-text]\]: annotates the text with a defined footnote 63 66 * raw \[\\[!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 64 67 * raw literal \[$\\[!raw-text]\]: shorthand for [\[$[\β¦]]] 65 -* macro \{[!name] [!arguments]}: invokes a [>ex.mac macro], specified with a reference 68 +* macro \{[!name] [!arguments]\}: invokes a [>ex.mac macro], specified with a reference 66 69 * argument \[#[!var]\]: in macros only, inserts the [$var]-th argument. otherwise, inserts a context variable provided by the renderer. 67 70 * raw argument \[##[!var]\]: like above, but does not evaluate [$var]. 68 71 * term \[&[!name] ([!label])\]: quotes a defined term with a link to its definition 69 72 * inline image \[&@[!name]\]: shows a small image or other object inline. the unicode character [$πΌ] can also be used instead of [$&@]. 70 73 71 74 ## identifiers 72 75 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. ................................................................................ 193 196 ts enables the spans: 194 197 * [$\[π#[!level] [!styled-text]\]]: redacts the span if the security level is below that specified. 195 198 * [$\[π.[!word] [!styled-text]\]]: redacts the span if the specified codeword clearance is not enabled. 196 199 (the padlock emoji is shorthand for [$%ts].) 197 200 198 201 ts redacts spans securely; that is, they are simply replaced with an indicator that they have been redacted, without visually leaking the length of the redacted text. 199 202 200 -~~~ts-example example ~~~ cortav 203 +~~~#ts-example example [cortav] ~~~ 201 204 %ts word doc sorrowful-pines SORROWFUL PINES 202 205 203 206 # intercept R1440 TCT S3 204 207 this communication between the ambassador of [*POLITY DOORMAT CRIMSON] "Socialist League world Glory" and an unknown noble of [*POLITY ROSE] "the Empire of a Thousand Suns" was intercepted by [*SYSTEM SUPINE WARBLE]. 205 208 206 209 ## involved individuals 207 210 * (A) [*DOORMAT CRIMSON] Ambassador [π.morose-frenzy Hyacinth Autumn-Lotus] (confidence 1.0) ................................................................................ 250 253 | [$--version] :|:[$-V]:| display the interpreter version | 251 254 252 255 ###refimpl-mode modes 253 256 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. 254 257 255 258 most modes are defined by the renderer backend. the following modes affect the behavior of the frontend: 256 259 257 -+ ID + type + effect 260 ++ ID + type + effect 258 261 | [$render:format]:| string | selects the [>refimpl-rend renderer] (default [$html]) 259 262 | [$parse:show-tree]:| flag | dumps the parse tree to the log after parsing completes 260 263 261 264 ##refimpl-rend renderers 262 265 [$cortav.lua] implements a frontend-backend architecture, separating the parsing stage from the rendering stage. this means new renderers can be added to [$cortav.lua] relatively easily. currently, only an [>refimpl-rend-html HTML renderer] is included; however, a [$groff] backend is planned at some point in the future, so that PDFs and manpages can be generated from cortav files. 263 266 264 267 ###refimpl-rend-html html ................................................................................ 281 284 -m render:format html \ 282 285 -m html:width 40em \ 283 286 -m html:accent 80 \ 284 287 -m html:hue-spread 35 \ 285 288 -y html:dark-on-light # could also be written as: 286 289 $ cortav readme.ct -ommmmy readme.html render:format html html:width 40em html:accent 80 html:hue-spread 35 html:dark-on-light 287 290 ~~~ 288 -
Modified cortav.lua from [1d4d9e0a4b] to [a950584594].
854 854 local styles = {} 855 855 if opts.width then 856 856 table.insert(styles, string.format([[body {padding:0 1em;margin:auto;max-width:%s}]], opts.width)) 857 857 end 858 858 if opts.accent then 859 859 table.insert(styles, string.format(':root {--accent:%s}', opts.accent)) 860 860 end 861 - if opts.accent or (not opts['dark-on-light']) then 861 + if opts.accent or (not opts['dark-on-light']) and (not opts['fossil-uv']) then 862 862 stylesNeeded.accent = true 863 863 end 864 864 865 865 866 866 for k in pairs(stylesNeeded) do 867 867 if not stylesets[k] then ct.exns.unimpl('styleset %s not implemented (!)', k):throw() end 868 868 table.insert(styles, prepcss(stylesets[k]))
Added cortav.xml version [8189edad17].
1 +<?xml version='1.0' encoding='UTF-8'?> 2 +<!-- 3 + [Κ] cortav.xml 4 + ~ lexi hale <lexi@hale.su> 5 + Β© AGPLv3 6 + ? Kate/kwrite-compatible syntax definition for the cortav markup format 7 + > ln cortav.xml $HOME/.local/share/org.kde.syntax-highlighting/syntax/ 8 +--> 9 +<language name='Cortav' version='1' kateversion='2.4' section='Markup' extensions='*.ct'> 10 + <highlighting> 11 + <list name='extension-directives'> 12 + <item>uses</item> 13 + <item>needs</item> 14 + <item>inhibits</item> 15 + </list> 16 + <list name='renderer-directives'> 17 + <item>html</item> 18 + <item>groff</item> 19 + <item>ps</item> 20 + <item>tex</item> 21 + <item>plaintext</item> 22 + <item>rtf</item> 23 + <item>svg</item> 24 + </list> 25 + <contexts> 26 + <context name='init' attribute='Normal Text' lineEndContext='#pop' fallthroughContext='text'> 27 + <RegExpr String='\\.' attribute='Escaped Char'/> 28 + <RegExpr attribute='Section Cue' context='sec-ident' String='(#|Β§)+' firstNonSpace='true' /> 29 + <StringDetect String='~~~' attribute='Literal Block Cue' firstNonSpace='true' context='literal-block-cue'/> 30 + <RegExpr attribute='List' String='[\*:]+' firstNonSpace='true' context='text' /> 31 + <Detect2Chars char='%' char1='!' attribute='Critical Directive Cue' context='directive'/> 32 + <DetectChar char='%' attribute='Directive Cue' context='directive'/> 33 + <DetectChar char='	' attribute='Normal Text' context='refdef-id'/> 34 + </context> 35 + 36 + <context name='sec-ident' attribute='Identifier' lineEndContext='#pop'> 37 + <DetectSpaces context='#pop!sec' attribute='Normal Text'/> 38 + </context> 39 + 40 + <context name='sec' attribute='Header' lineEndContext='#pop'> 41 + <IncludeRules context='text'/> 42 + </context> 43 + 44 + <context name='refdef-id' attribute='Identifier' lineEndContext='#pop'> 45 + <DetectChar char=':' attribute='Normal Text' context='#pop!refdef'/> 46 + </context> 47 + <context name='refdef' attribute='Styled Text' lineEndContext='#pop'> 48 + </context> 49 + 50 + <context name='directive' attribute='Directive' lineEndContext='#pop'> 51 + <keyword attribute='Extension Directive' String='extension-directives'/> 52 + <keyword attribute='Renderer Directive' String='renderer-directives'/> 53 + </context> 54 + 55 + <context name='text' attribute='Normal Text' lineEndContext='#pop'> 56 + <RegExpr String='\\.' attribute='Escaped Char'/> 57 + <DetectChar attribute='Span Delimiter' context='span-cue' char='['/> 58 + <DetectChar attribute='Macro Delimiter' context='macro' char='{'/> 59 + </context> 60 + 61 + <context name='span' attribute='Styled Text' lineEndContext='#pop'> 62 + <IncludeRules context='text'/> 63 + <DetectChar attribute='Span Delimiter' context='#pop' char=']'/> 64 + </context> 65 + 66 + <context name='macro' attribute='Macro' lineEndContext='#pop'> 67 + <DetectSpaces context='#pop!macro-body'/> 68 + <DetectChar attribute='Macro Delimiter' char='}' context='#pop'/> 69 + </context> 70 + 71 + <context name='macro-body' attribute='Styled Text' lineEndContext='#pop'> 72 + <RegExpr String='\\.' attribute='Escaped Char'/> 73 + <DetectChar attribute='Field Delimiter' char='|'/> 74 + <DetectChar attribute='Macro Delimiter' char='}' context='#pop'/> 75 + <IncludeRules context='span'/> 76 + </context> 77 + 78 + <context name='span-emph' attribute='Emphatic Text' lineEndContext='#pop'> 79 + <IncludeRules context='span'/> 80 + </context> 81 + 82 + <context name='span-strong' attribute='Strong Text' lineEndContext='#pop'> 83 + <IncludeRules context='span'/> 84 + </context> 85 + 86 + <context name='span-del' attribute='Deleted Text' lineEndContext='#pop'> 87 + <IncludeRules context='span'/> 88 + </context> 89 + 90 + <context name='span-cue' attribute='Span Cue' lineEndContext='#pop'> 91 + <StringDetect attribute='Span Cue' String='$\' context='#pop!flat-span' /> 92 + 93 + <DetectChar attribute='Span Cue' char='!' context='#pop!span-emph' /> 94 + <DetectChar attribute='Span Cue' char='*' context='#pop!span-strong' /> 95 + <DetectChar attribute='Span Cue' char='~' context='#pop!span-del' /> 96 + 97 + <AnyChar attribute='Span Cue' String='$+π' context='#pop!span' /> 98 + <StringDetect attribute='Span Cue' String='β' context='#pop!ref' /> 99 + <StringDetect attribute='Span Cue' String='π' context='#pop!ref' /> 100 + <DetectChar attribute='Span Cue' char='>' context='#pop!ref' /> 101 + <DetectChar attribute='Span Cue' char='&' context='#pop!ref' /> 102 + <DetectChar attribute='Span Cue' char='#' context='#pop!var-ref' /> 103 + <DetectChar attribute='Span Cue' char='\' context='#pop!flat-span' /> 104 + </context> 105 + 106 + <context name='flat-span' attribute='Unstyled Text' lineEndContext='#pop'> 107 + <Detect2Chars attribute='Escaped Char' context='#stay' char='\' char1=']'/> 108 + <DetectChar attribute='Span Delimiter' context='#pop' char=']'/> 109 + </context> 110 + 111 + <context name='ref' attribute='Reference' lineEndContext='#pop'> 112 + <DetectSpaces context='#pop!span'/> 113 + </context> 114 + 115 + <context name='var-ref' attribute='Reference' lineEndContext='#pop'> 116 + <WordDetect String="cortav" attribute='Standard Namespace'/> 117 + <WordDetect String="env" attribute='Standard Namespace'/> 118 + <DetectChar attribute='Span Delimiter' context='#pop' char=']'/> 119 + </context> 120 + 121 + <context name='literal-block-cue' attribute='Literal Block Cue' lineEndContext='#pop!literal-block'> 122 + <RegExpr String='\[[^\]]+\]' attribute='External Reference'/> 123 + <RegExpr String='#[^\s]+' attribute='Identifier'/> 124 + <RegExpr String='~~~$' attribute='Literal Block Cue'/> 125 + <RegExpr String='[^\s]+' attribute='Header'/> 126 + </context> 127 + <context name='literal-block' attribute='Literal Block' lineEndContext='#stay'> 128 + <RegExpr String='~~~$' attribute='Literal Block Cue' firstNonSpace='true' context='#pop'/> 129 + </context> 130 + </contexts> 131 + <itemDatas> 132 + <itemData name='Normal Text' defStyleNum='dsNormal'/> 133 + <itemData name='Styled Text' defStyleNum='dsNormal'/> 134 + <itemData name='Emphatic Text' defStyleNum='dsNormal' italic='true'/> 135 + <itemData name='Strong Text' defStyleNum='dsNormal' bold='true'/> 136 + <itemData name='Deleted Text' defStyleNum='dsNormal' strikeout='true'/> 137 + 138 + <itemData name='Section Cue' defStyleNum='dsKeyword' bold='true'/> 139 + <itemData name='Header' defStyleNum='dsControlFlow' underline='true'/> 140 + <itemData name='Identifier' defStyleNum='dsVariable'/> 141 + 142 + <itemData name='Unstyled Text' defStyleNum='dsVerbatimString'/> 143 + <itemData name='Escaped Char' defStyleNum='dsSpecialChar'/> 144 + <itemData name='Reference' defStyleNum='dsControlFlow' underline='true'/> 145 + <itemData name='Span Cue' defStyleNum='dsKeyword' bold='true'/> 146 + <itemData name='Span Delimiter' defStyleNum='dsKeyword'/> 147 + <itemData name='Directive' defStyleNum='dsAttribute' bold='true'/> 148 + <itemData name='Directive Cue' defStyleNum='dsAttribute'/> 149 + <itemData name='Critical Directive Cue' defStyleNum='dsImport' bold='true'/> 150 + <itemData name='Extension Directive' defStyleNum='dsImport' bold='true'/> 151 + <itemData name='Renderer Directive' defStyleNum='dsExtension' bold='true'/> 152 + <itemData name='Standard Namespace' defStyleNum='dsBuiltIn' bold='true'/> 153 + <itemData name='Comment' defStyleNum='dsComment'/> 154 + <itemData name='Macro' defStyleNum='dsPreprocessor' bold='true'/> 155 + <itemData name='Macro Delimiter' defStyleNum='dsPreprocessor'/> 156 + <itemData name='Field Delimiter' defStyleNum='dsPreprocessor' bold='true'/> 157 + <itemData name='List' defStyleNum='dsOperator'/> 158 + 159 + <itemData name='Literal Block' defStyleNum='dsSpecialString'/> 160 + <itemData name='Literal Block Cue' defStyleNum='dsPreprocessor' bold='true'/> 161 + 162 + <itemData name='External Reference' defStyleNum='dsImport'/> 163 + </itemDatas> 164 + </highlighting> 165 + <general> 166 + <comments> 167 + <comment name='singleLine' start='%%' /> 168 + </comments> 169 + <keywords weakDeliminator='-+:/' /> 170 + </general> 171 +</language>