"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/asciidoc.lang" (12 May 2020, 12070 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "asciidoc.lang": 3.53_vs_3.54.

    1 --[[ "asciidoc.lang" v0.0.4 | 2019/01/01 | Highlight v3.48
    2 ********************************************************************************
    3 *                                                                              *
    4 *                          AsciiDoc Syntax Definition                          *
    5 *                                                                              *
    6 *                              by Tristano Ajmone                              *
    7 *                                                                              *
    8 ********************************************************************************
    9 NOTE: Alpha WIP!
   10 
   11 Currently implemented elements:
   12 
   13   - Comments.
   14 --------------------------------------------------------------------------------
   15 ** MANDATORY ELEMENTS **
   16 The bare minimum definitions required for a langDef file to be valid are:
   17   -- Description
   18   -- Keywords
   19 If a langDef file doesn't provide these definitions, Highlight will raise an
   20 error. All other definitions are optional.
   21 --------------------------------------------------------------------------------
   22 ** HIGHLIGHT DEFAULTS **
   23 Highlight provides a default definition to the following syntax elements:
   24   -- Identifiers
   25   -- Digits
   26   -- Escape
   27 All other definition are empty/false by default.
   28 --------------------------------------------------------------------------------
   29 Written by Tristano Ajmone:
   30     <tajmone@gmail.com>
   31     https://github.com/tajmone
   32     https://gitlab.com/tajmone
   33 Released into the public domain according to the Unlicense terms:
   34     http://unlicense.org/
   35 ------------------------------------------------------------------------------]]
   36 
   37 Description = "AsciiDoc" -- Syntax description
   38 
   39 Categories = {"markup"}
   40 
   41 --==============================================================================
   42 -- SUPPRESSED ELEMENTS
   43 --==============================================================================
   44 NeverMatch = [=[ \A(?!x)x ]=] -- Never-Matching RegEx!
   45 
   46 Digits = [=[ \A(?!x)x ]=] -- Not needed! but could use them for somithing else!
   47 --------------------------------------------------------------------------------
   48 
   49 --==============================================================================
   50 -- SYNTAX SETTINGS
   51 --==============================================================================
   52 IgnoreCase = false -- Are keywords case-sensitive? (true/false)
   53 EnableIndentation = false -- Syntax may be reformatted and indented? (true/false)
   54 Identifiers = [=[ [a-zA-Z_]\w* ]=] -- Highlight's default Identifiers definition
   55 
   56 --[[============================================================================
   57                                     COMMENTS
   58 ================================================================================
   59 AsciiDoc comments delimiters must always be placed at beginning of line and end
   60 the line without other characters.
   61 ------------------------------------------------------------------------------]]
   62 Comments = {
   63   -- Define BLOCK-COMMENTS delimiters
   64   { Block  = true,
   65     Nested = false,
   66     Delimiter = {
   67       [=[ ^\/{4}$ ]=], -- ////
   68       [=[ ^\/{4}$ ]=]  -- ////
   69     }
   70   },
   71   -- Define SINGLE-LINE-COMMENTS delimiter
   72   { Block = false,
   73     Delimiter = { [=[ ^\/\/ ]=] } -- //
   74   }
   75 }
   76 --[[============================================================================
   77                                     STRINGS
   78 ================================================================================
   79 Strings = { Delimiter|DelimiterPairs={Open, Close, Raw?}, Escape?, Interpolation?,
   80             RawPrefix?, AssertEqualLength? }
   81 
   82   Delimiter:         String, regular expression which describes string delimiters
   83   DelimiterPairs:    List, includes open and close delimiter expressions if not
   84                       equal, includes optional Raw flag as boolean which marks
   85                       delimiter pair to contain a raw string
   86   Escape:            String, regex of escape sequences (optional)
   87   Interpolation:     String, regex of interpolation sequences (optional)
   88   RawPrefix:         String, defines raw string indicator (optional)
   89   AssertEqualLength: Boolean, set true if delimiters must have the same length
   90 ------------------------------------------------------------------------------]]
   91 
   92 --[============================================[
   93 Strings = {
   94 
   95 --------------------------------------------------------------------------------
   96 --                              STRING DELIMITERS
   97 --------------------------------------------------------------------------------
   98 
   99   -- SYMMETRICAL STRINGS DELIMITERS
  100   Delimiter = [=[ "|' ]=], -- Double- and single-quote delimiters: " '
  101 
  102   -- ASSYMMETRICAL STRINGS DELIMITERS
  103   -- Example: Lua style string-delimiters:
  104   DelimiterPairs= {
  105     { Open  = [=[ \[=*\[ ]=],  -- [[  [=[  [===[   etc.
  106       Close = [=[ \]=*\] ]=],  -- ]]  ]=]  ]===]   etc.
  107       Raw = true, -- Are these raw string delimiters? (true/false)
  108     }
  109   },
  110   AssertEqualLength = true,  -- Delimiters must have the same length?
  111 
  112   -- RAW-STRING PREFIX (if language supports it)
  113   RawPrefix = "R",           -- Raw string indicator (optional): R (C style)
  114 --[[----------------------------------------------------------------------------
  115                                 ESCAPE SEQUENCES
  116 --------------------------------------------------------------------------------
  117 If the language at hand supports escape sequences, define a RegEx pattern to
  118 capture them.
  119 
  120     https://en.wikipedia.org/wiki/Escape_sequences_in_C
  121 
  122 NOTE: Escape sequences are not restricted to occur inside strings only, they
  123       will be matched anywhere in the source code (some languages, like Perl
  124       and Bash, allow their use anywhere). Usually this doesn't constitute a
  125       problem, but in some languages this uncostrained behaviour might cause
  126       false positives matches; in such cases you'll need to restrict escape
  127       sequences occurence to inside-strings context only by implementing a
  128       custom hook via the OnStateChange() function --- see "Hook Preset #01"
  129       further down.                                                         --]]
  130 
  131 -- Highlight's default built-in Escape definition:
  132   -- Escape = [=[ \\u[[:xdigit:]]{4}|\\\d{3}|\\x[[:xdigit:]]{2}|\\[ntvbrfa\\\?'"] ]=],
  133   Escape = NeverMatch,
  134 --[[----------------------------------------------------------------------------
  135                                 INTERPOLATION
  136 --------------------------------------------------------------------------------
  137 String, regex of interpolation sequences (optional)
  138 
  139 To understand interpolation, here is an example from Javascript:
  140 
  141     var apples = 6;
  142     console.log(`There are ${apples} apples in the basket!`);
  143 
  144 which will otuput:
  145 
  146     There are 6 apples in the basket!
  147 
  148 References:
  149     https://en.wikipedia.org/wiki/String_interpolation
  150 --]]
  151   Interpolation = NeverMatch,
  152   -- Interpolation = [=[ \$\{.+?\} ]=], -- Javascript Interpolation: ${ ... }
  153 }
  154 --]============================================]
  155 
  156 
  157 
  158 --[[============================================================================
  159                                   PREPROCESSOR
  160 ================================================================================
  161 PreProcessor = { Prefix, Continuation? }
  162 
  163   Prefix:        String, regular expression which describes open delimiter
  164   Continuation:  String, contains line continuation character (optional).
  165 
  166 NOTE: This element is treated by Highlight parser in a similar way to single-
  167       line comments: it swallows up everything from the matching Prefix up to
  168       the end of the line -- but unlike comment lines (which can't contain
  169       further syntax elements), the parser will still be looking for some
  170       syntax elements (in the current line) which might be reasonably found
  171       within a line of preprocessor directives (eg: strings and comments);
  172       but once these elements are dealt with, the parser will resume the
  173       PreProcessor state to carry on parsing the rest of the line.
  174 
  175       Furthermore, the Continuation character allows this element to span
  176       across multiple line (without the need of an opening and closing pair,
  177       unlike multiline comments do).
  178 PreProcessor = {
  179   -- Case sensitive? ** SHOULD TEST!! **
  180   Prefix = [=[ (?:include|tag|end) ]=]
  181   -- Continuation = "\\", -- Backslash ('\') marks continuation of preprocessor line
  182 }
  183 --]]
  184 
  185 --[[============================================================================
  186                                   OPERATORS
  187 ============================================================================--]]
  188 -- Operators = [=[ \&|<|>|\!|\||\=|\/|\*|\%|\+|\-|~ ]=] -- Match: &<>!|=/*%+-~
  189 
  190 
  191 --[[============================================================================
  192                                   KEYWORDS
  193 ================================================================================
  194 Keywords = { Id, List|Regex, Group? }
  195 
  196   Id:    Integer, keyword group id (values 1-4, can be reused for several keyword
  197           groups)
  198   List:  List, list of keywords
  199   Regex: String, regular expression
  200   Group: Integer, capturing group id of regular expression, defines part of regex
  201           which should be returned as keyword (optional; if not set, the match
  202           with the highest group number is returned (counts from left to right))
  203 
  204 NOTE: Keyword group Ids are not limited to 4, you can create as many as you
  205       need; but bare in mind that most themes that ship with Highlight usually
  206       provide definitions only for Ids 1-4, so in order to syntax-color Keyword
  207       groups with Ids greater than 4 you'll need to define a theme that covers
  208       their definitions.                                                    --]]
  209 
  210 
  211 Keywords = {
  212 --------------------------------------------------------------------------------
  213 --                                  Keywords 1
  214 --------------------------------------------------------------------------------
  215 -- NOTE: If you've set `IgnoreCase = false` then all keywords in the list must
  216 --       be in lowercase otherwise they'll never match! With case-insensitive
  217 --       languages, Highlight converts to lowercase the token before comparing
  218 --       it to the entries of the Keywords list, but the list entries are not
  219 --       manipulated before comparison.
  220   -- { Id = 1,
  221   --   List = {
  222   --     -- Keywords list
  223   --     "avracadavrah"
  224   --   }
  225   -- },
  226 --------------------------------------------------------------------------------
  227 --                                  Keywords 2
  228 --------------------------------------------------------------------------------
  229 -- Preprocessor Directives
  230   { Id = 4,
  231     Regex = [=[ (?<!\\)((?:include|ifdef|ifndef|ifeval|endif|tag|end)\:\:) ]=],
  232     Group = 1
  233   }
  234 }
  235 
  236 -- =============================================================================
  237 -- Hook Preset #01 -- Escape Sequences Only Inside String
  238 -- =============================================================================
  239 
  240 --[[
  241 function OnStateChange(oldState, newState, token, kwgroup)
  242 --  This function ensure that escape sequences outside strings are ignored.
  243 --  Based on André Simon's reply to Issue #23:
  244 --  -- https://github.com/andre-simon/highlight/issues/23#issuecomment-332002639
  245   if newState==HL_ESC_SEQ and oldState~=HL_STRING  then
  246     return HL_REJECT
  247   end
  248   return newState
  249 end
  250 --]]
  251 
  252 --[[============================================================================
  253                                   CHANGELOG
  254 ================================================================================
  255 v0.0.4 | 2019/01/01 | Highlight v3.48
  256   - Define:
  257     - Keywords Id 4 :: Preprocessor Directives
  258   - Fix:
  259     - Single line Comment: Remove '$'
  260   - Suppress:
  261     - Keywords Id 1
  262 v0.0.3 | 2019/01/01 | Highlight v3.48
  263   - Suppress: Operators, Strings.
  264 v0.0.2 | 2019/01/01 | Highlight v3.48
  265   - Fix block comments (delimiters must fill the line.)
  266   - Suppress Preprocessor.
  267 v0.0.1 | 2019/01/01 | Highlight v3.48
  268   - Define comments (single-line and block).
  269   - Suppress some unused elements.
  270 v0.0.0 | 2019/01/01 | Highlight v3.48
  271   - Just the langDef boliterplate.
  272 
  273 --]]