plugins/geshi/geshi/latex.php
changeset 2 9e3258dfae15
parent 0 441963e5b07a
child 3 f3e2bbbd2155
--- a/plugins/geshi/geshi/latex.php	Sun Feb 10 19:00:04 2008 -0500
+++ b/plugins/geshi/geshi/latex.php	Fri May 29 19:30:59 2009 -0400
@@ -2,11 +2,37 @@
 /*************************************************************************************
  * latex.php
  * -----
- * Original Author: efi
- * modified by Matthias Pospiech (mail@matthiaspospiech.de)
+ * Author: efi, Matthias Pospiech (matthias@pospiech.eu)
+ * Copyright: (c) 2006 efi, Matthias Pospiech (matthias@pospiech.eu), Nigel McNie (http://qbnz.com/highlighter)
+ * Release Version: 1.0.8.2
+ * Date Started: 2006/09/23
+ *
+ * LaTeX language file for GeSHi.
+ *
+ * CHANGES
+ * -------
+ * 2008/08/18 (1.0.8.1)
+ *  - Changes in color and some additional command recognition
+ *  - No special Color for Brackets, it is only distracting
+ *    if color should be reintroduced it should be less bright
+ *  - Math color changed from green to violett, since green is now used for comments
+ *  - Comments are now colored and the only green. The reason for coloring the comments
+ *    is that often important information is in the comments und was merely unvisible before.
+ *  - New Color for [Options]
+ *  - color for labels not specialised anymore. It makes sence in large documents but less in
+ *    small web examples.
+ *  - \@keyword introduced
+ *  - Fixed \& escaped ampersand
+ * 2006/09/23 (1.0.0)
+ *  -  First Release
+ *
+ * TODO
+ * -------------------------
+ * *
+ *
  *************************************************************************************
  *
- *   This file is not yet part of GeSHi. (and is not compatible to the 1.1+ branch)
+ *     This file is part of GeSHi.
  *
  *   GeSHi is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -24,14 +50,11 @@
  *
  ************************************************************************************/
 
-if (isset($this) && is_a($this, 'GeSHi')) {
-    $this->set_symbols_highlighting(false);
-    $this->set_numbers_highlighting(false);
-}
-
 $language_data = array (
     'LANG_NAME' => 'LaTeX',
-    'COMMENT_SINGLE' => array(1 => '%'),
+    'COMMENT_SINGLE' => array(
+        1 => '%'
+        ),
     'COMMENT_MULTI' => array(),
     'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
     'QUOTEMARKS' => array(),
@@ -39,45 +62,45 @@
     'KEYWORDS' => array(
         ),
     'SYMBOLS' => array(
-        '.', ',','\\',"~", "{", "}", "[", "]", "$"
+        "&", "\\", "{", "}", "[", "]"
         ),
     'CASE_SENSITIVE' => array(
-        GESHI_COMMENTS => true,
-        1 => false,
-        2 => false,
-        3 => false,
-        4 => false,
+        GESHI_COMMENTS => false,
         ),
     'STYLES' => array(
         'KEYWORDS' => array(
             ),
         'COMMENTS' => array(
-            1 => 'color: #808080; font-style: italic;'
+            1 => 'color: #2C922C; font-style: italic;'
             ),
         'ESCAPE_CHAR' => array(
+            0 =>  'color: #000000; font-weight: bold;'
             ),
         'BRACKETS' => array(
             ),
         'STRINGS' => array(
+            0 =>  'color: #000000;'
             ),
         'NUMBERS' => array(
             ),
         'METHODS' => array(
             ),
         'SYMBOLS' => array(
+            0 =>  'color: #0000D0; '
             ),
         'REGEXPS' => array(
-            1 => 'color: #00A000; font-weight: bold;',  // Math inner
-            2 => 'color: #800000; font-weight: normal;', // \keyword #202020
-            3 => 'color: #2222D0; font-weight: normal;', // {...}
-            4 => 'color: #2222D0; font-weight: normal;', // [Option]
-            5 => 'color: #00A000; font-weight: normal;', // Mathe #CCF020
-            6 => 'color: #F00000; font-weight: normal;', // Structure \begin
-            7 => 'color: #F00000; font-weight: normal;', // Structure \end
-            8 => 'color: #F00000; font-weight: normal;', // Structure: Labels
-            //9 => 'color: #F00000; font-weight: normal;',  // Structure
-            10 => 'color: #0000D0; font-weight: bold;',  // Environment
-            11 => 'color: #0000D0; font-weight: bold;',  // Environment
+            1 => 'color: #8020E0; font-weight: normal;',  // Math inner
+            2 => 'color: #C08020; font-weight: normal;', // [Option]
+            3 => 'color: #8020E0; font-weight: normal;', // Maths
+            4 => 'color: #800000; font-weight: normal;', // Structure: Labels
+            5 => 'color: #00008B; font-weight: bold;',  // Structure (\section{->x<-})
+            6 => 'color: #800000; font-weight: normal;', // Structure (\section)
+            7 => 'color: #0000D0; font-weight: normal;', // Environment \end or \begin{->x<-} (brighter blue)
+            8 => 'color: #C00000; font-weight: normal;', // Structure \end or \begin
+            9 => 'color: #2020C0; font-weight: normal;', // {...}
+            10 => 'color: #800000; font-weight: normal;', // \%, \& etc.
+            11 => 'color: #E00000; font-weight: normal;', // \@keyword
+            12 => 'color: #800000; font-weight: normal;', // \keyword
         ),
         'SCRIPT' => array(
             )
@@ -90,92 +113,64 @@
     'REGEXPS' => array(
         // Math inner
         1 => array(
-            GESHI_SEARCH => "(\\\\begin\\{)(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|alignat|flalign )(\\})(.*)(\\\\end\\{)(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|alignat|flalign)(\\})",
-            GESHI_REPLACE => '\\4',
-            GESHI_MODIFIERS => 's',
-            GESHI_BEFORE => '\1\2\3',
-            GESHI_AFTER => '\5\6\7'
+            GESHI_SEARCH => "(\\\\begin\\{(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|alignat|flalign)\\})(.*)(\\\\end\\{\\2\\})",
+            GESHI_REPLACE => '\3',
+            GESHI_MODIFIERS => 'Us',
+            GESHI_BEFORE => '\1',
+            GESHI_AFTER => '\4'
             ),
-        //  \keywords
+        // [options]
         2 => array(
-            GESHI_SEARCH => "(\\\\)([a-zA-Z]+)",
-            GESHI_REPLACE => '\1\2',
-            GESHI_MODIFIERS => '',
+            GESHI_SEARCH => "(?<=\[).+(?=\])",
+            GESHI_REPLACE => '\0',
+            GESHI_MODIFIERS => 'Us',
             GESHI_BEFORE => '',
             GESHI_AFTER => ''
             ),
-        // {parameters}
+        // Math mode with $ ... $
         3 => array(
-            GESHI_SEARCH => "(\\{)(.*)(\\})",
-            GESHI_REPLACE => '\2',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '\1',
-            GESHI_AFTER => '\3'
-            ),
-        // [Option]
-        4 => array(
-            GESHI_SEARCH => "(\[)(.+)(\])",
-            GESHI_REPLACE => '\2',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '\1',
-            GESHI_AFTER => '\3'
-            ),
-        // Mathe  mit $ ... $
-        5 => array(
-            GESHI_SEARCH => "(\\$)(.+)(\\$)",
-            GESHI_REPLACE => '\1\2\3',
-            GESHI_MODIFIERS => '',
+            GESHI_SEARCH => "\\$.+\\$",
+            GESHI_REPLACE => '\0',
+            GESHI_MODIFIERS => 'Us',
             GESHI_BEFORE => '',
             GESHI_AFTER => ''
             ),
-        // Structure begin
-        6 => array(
-            GESHI_SEARCH => "(\\\\begin)(?=[^a-zA-Z])",
-            GESHI_REPLACE => '\\1',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '',
-            GESHI_AFTER => '\\2'
-            ),
-        // Structure end
-        7 => array(
-            GESHI_SEARCH => "(\\\\end)(?=[^a-zA-Z])",
-            GESHI_REPLACE => '\\1',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '',
-            GESHI_AFTER => '\\2'
+        // Structure: Label
+        4 => "\\\\(?:label|pageref|ref|cite)(?=[^a-zA-Z])",
+        // Structure: sections
+        5 => array(
+            GESHI_SEARCH => "(\\\\(?:part|chapter|(?:sub){0,2}section|(?:sub)?paragraph|addpart|addchap|addsec)\*?\\{)(.*)(?=\\})",
+            GESHI_REPLACE => '\\2',
+            GESHI_MODIFIERS => 'U',
+            GESHI_BEFORE => '\\1',
+            GESHI_AFTER => ''
             ),
-        //Structure: Label
-        8 => array(
-            GESHI_SEARCH => "(\\\\)(label|pageref|ref|cite)(?=[^a-zA-Z])",
-            GESHI_REPLACE => '\\1\\2',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '',
-            GESHI_AFTER => '\\3'
+        // Structure: sections
+        6 => "\\\\(?:part|chapter|(?:sub){0,2}section|(?:sub)?paragraph|addpart|addchap|addsec)\*?(?=[^a-zA-Z])",
+        // environment \begin{} and \end{} (i.e. the things inside the {})
+        7 => array(
+            GESHI_SEARCH => "(\\\\(?:begin|end)\\{)(.*)(?=\\})",
+            GESHI_REPLACE => '\\2',
+            GESHI_MODIFIERS => 'U',
+            GESHI_BEFORE => '\\1',
+            GESHI_AFTER => ''
             ),
-// Structure: sections
-/*9 => array(
-            GESHI_SEARCH => "(\\\\)(part|chapter|section|subsection|subsubsection|paragraph|subparagraph)(?=[^a-zA-Z])",
-            GESHI_REPLACE => '\1\\2',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '',
-            GESHI_AFTER => '\\3'
-            ),*/
-// environment begin
-10 => array(
-            GESHI_SEARCH => "(\\\\begin)(\\{)(.*)(\\})",
-            GESHI_REPLACE => '\\3',
-            GESHI_MODIFIERS => '',
+        // Structure \begin and \end
+        8 => "\\\\(?:end|begin)(?=[^a-zA-Z])",
+        // {parameters}
+        9 => array(
+            GESHI_SEARCH => "(?<=\\{)(?!<\|!REG3XP5!>).*(?=\\})",
+            GESHI_REPLACE => '\0',
+            GESHI_MODIFIERS => 'Us',
             GESHI_BEFORE => '',
             GESHI_AFTER => ''
             ),
-// environment end
-11 => array(
-            GESHI_SEARCH => "(\\\\end)(\\{)(.*)(\\})",
-            GESHI_REPLACE => '\\3',
-            GESHI_MODIFIERS => '',
-            GESHI_BEFORE => '',
-            GESHI_AFTER => ''
-            ),
+        // \%, \& usw.
+        10 => "\\\\(?:[_$%]|&amp;)",
+        //  \@keywords
+        11 => "(?<!<\|!REG3XP[8]!>)\\\\@[a-zA-Z]+\*?",
+        // \keywords
+        12 => "(?<!<\|!REG3XP[468]!>)\\\\[a-zA-Z]+\*?",
 
 // ---------------------------------------------
         ),
@@ -183,7 +178,16 @@
     'SCRIPT_DELIMITERS' => array(
         ),
     'HIGHLIGHT_STRICT_BLOCK' => array(
+        ),
+    'PARSER_CONTROL' => array(
+        'COMMENTS' => array(
+            'DISALLOWED_BEFORE' => '\\'
+        ),
+        'ENABLE_FLAGS' => array(
+            'NUMBERS' => GESHI_NEVER,
+            'BRACKETS' => GESHI_NEVER
         )
+    )
 );
 
 ?>