KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
6.2KB

  1. <?php
  2. /*************************************************************************************
  3. * yaml.php
  4. * --------
  5. * Author: Josh Ventura (JoshV10@gmail.com)
  6. * Copyright: (c) 2010 Josh Ventura
  7. * Release Version: 1.0.8.11
  8. * Date Started: 2010/12/14
  9. *
  10. * YAML language file for GeSHi.
  11. *
  12. * YAML gets hairy sometimes. If anything needs fixed, drop me an email and
  13. * I'll probably spit up on it. This is, in general, not a long format.
  14. *
  15. * CHANGES
  16. * ---------
  17. * 2010/12/14
  18. * - Started project in rage over GML support but not YAML support. WTFH?
  19. * 2010/12/15
  20. * - Submitted to Ben.
  21. *
  22. * TODO (not updated since release)
  23. * ----------------------------------
  24. * - Field testing and necessary corrections: this grammar file is usable, but not
  25. * completely accurate. There are, in fact, multiple cases in which it will mess
  26. * up, and some of it may need moved around. It is the most temperamental parser
  27. * I have ever associated my name with. Points of interest follow:
  28. * * Improvised support for | and >: since PHP offers no variable-width lookbehind,
  29. * these blocks will still be highlighted even when commented out. As it happens,
  30. * any line ending with | or > could result in the unintentional highlighting of
  31. * all remaining lines in the file, just because I couldn't check for this regex
  32. * as a lookbehind: '/:(\s+)(!!(\w+)(\s+))?/'
  33. * If there is a workaround for that, it needs implemented.
  34. * * I may be missing some operators. I deliberately omitted inline array notation
  35. * as, in general, it's ugly and tends to conflict with plain-text. Ensuring all
  36. * highlighted list delimiters are not plain text would be as simple as checking
  37. * that they follow a colon directly. Alas, without variable-length lookbehinds,
  38. * if there is a way to do so in GeSHi I am unaware of it.
  39. * * I kind of whored the comment regexp array. It seemed like a safe bet, so it's
  40. * where I crammed everything. Some of it may need moved elsewhere for neatness.
  41. * * The !!typename highlight needs not to interfere with ": |" and ": >": Pairing
  42. * key: !!type | value is perfectly legal, but again due to lookbehind issues, I
  43. * can't add a case for that. Also, it is likely that multiple spaces can be put
  44. * between the colon and pipe symbol, which would also break it.
  45. *
  46. *************************************************************************************
  47. *
  48. * This file is part of GeSHi.
  49. *
  50. * GeSHi is free software; you can redistribute it and/or modify it
  51. * under the terms of the GNU General Public License as published by
  52. * the Free Software Foundation; either version 2 of the License, or
  53. * (at your option) any later version.
  54. *
  55. * GeSHi is distributed in the hope that it will be useful,
  56. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  57. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  58. * GNU General Public License for more details.
  59. *
  60. * You should have received a copy of the GNU General Public License
  61. * along with GeSHi; if not, write to the Free Software
  62. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  63. *
  64. ************************************************************************************/
  65. $language_data = array (
  66. 'LANG_NAME' => 'YAML',
  67. 'COMMENT_SINGLE' => array(),
  68. 'COMMENT_MULTI' => array(),
  69. //Keys
  70. 'COMMENT_REGEXP' => array( // ENTRY ZERO SHOULD CHECK FOR (\n(\s*)([^#%]+?):(\s+)(!!(\w+)(\s+))?) AS A LOOKBEHIND, BUT IT CAN'T.
  71. 0 => '/(?<=\s[\|>]\n)(\s+)(.*)((?=[\n$])(([\n^](\1(.*)|(?=[\n$])))*)|$)/', // Pipe blocks and > blocks.
  72. 1 => '/#(.*)/', // Blue # comments
  73. 2 => '/%(.*)/', // Red % comments
  74. 3 => '/(^|\n)([^#%^\n]+?)(?=: )/', // Key-value names
  75. 4 => '/(^|\n)([^#%^\n]+?)(?=:\n)/',// Key-group names
  76. 5 => '/(?<=^---)(\s*)!(\S+)/', // Comments after ---
  77. 6 => '/(?<=: )(\s*)\&(\S+)/', // References
  78. 7 => '/(?<=: )(\s*)\*(\S+)/', // Dereferences
  79. 8 => '/!!(\w+)/', // Types
  80. //9 => '/(?<=\n)(\s*)-(?!-)/', // List items: This needs to search within comments 3 and 4, but I don't know how.
  81. ),
  82. 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  83. 'QUOTEMARKS' => array('"'),
  84. 'ESCAPE_CHAR' => '',
  85. 'KEYWORDS' => array(
  86. 1 => array(
  87. 'all','any','none', "yes", "no"
  88. ),
  89. ),
  90. 'SYMBOLS' => array(
  91. 1 => array('---', '...'),
  92. 2 => array(': ', ">\n", "|\n", '<<:', ":\n") // It'd be nice if I could specify that the colon must
  93. // follow comment 3 or 4 to be considered, and the > and |
  94. // must follow such a colon.
  95. ),
  96. 'CASE_SENSITIVE' => array(
  97. GESHI_COMMENTS => false,
  98. 1 => false,
  99. ),
  100. 'STYLES' => array(
  101. 'KEYWORDS' => array(
  102. 1 => 'font-weight: bold;'
  103. ),
  104. 'COMMENTS' => array(
  105. 0 => 'color: #303050;background-color: #F5F5F5',
  106. 1 => 'color: blue;',
  107. 2 => 'font-weight: bold; color: red;',
  108. 3 => 'color: green;',
  109. 4 => 'color: #007F45;',
  110. 5 => 'color: #7f7fFF;',
  111. 6 => 'color: #FF7000;',
  112. 7 => 'color: #FF45C0;',
  113. 8 => 'font-weight: bold; color: #005F5F;',
  114. //9 => 'font-weight: bold; color: #000000;',
  115. ),
  116. 'ESCAPE_CHAR' => array(
  117. ),
  118. 'BRACKETS' => array(
  119. ),
  120. 'STRINGS' => array(
  121. 0 => 'color: #CF00CF;'
  122. ),
  123. 'NUMBERS' => array(
  124. // 0 => 'color: #33f;' // Don't highlight numbers, really...
  125. ),
  126. 'METHODS' => array(
  127. 1 => '',
  128. 2 => ''
  129. ),
  130. 'SYMBOLS' => array(
  131. 1 => 'color: cyan;',
  132. 2 => 'font-weight: bold; color: brown;'
  133. ),
  134. 'REGEXPS' => array(
  135. ),
  136. 'SCRIPT' => array(
  137. 0 => ''
  138. )
  139. ),
  140. 'URLS' => array(1 => ''),
  141. 'OOLANG' => false,
  142. 'OBJECT_SPLITTERS' => array( ),
  143. 'REGEXPS' => array( ),
  144. 'STRICT_MODE_APPLIES' => GESHI_NEVER,
  145. 'SCRIPT_DELIMITERS' => array( ),
  146. 'HIGHLIGHT_STRICT_BLOCK' => array( )
  147. );
  148. ?>