1/** 2 * @license 3 * Copyright (C) 2011 Martin S. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19 * @fileoverview 20 * Support for tex highlighting as discussed on 21 * <a href="http://meta.tex.stackexchange.com/questions/872/text-immediate-following-double-backslashes-is-highlighted-as-macro-inside-a-code/876#876">meta.tex.stackexchange.com</a>. 22 * 23 * @author Martin S. 24 */ 25 26PR['registerLangHandler']( 27 PR['createSimpleLexer']( 28 [ 29 // whitespace 30 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 31 // all comments begin with '%' 32 [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'] 33 ], 34 [ 35 //[PR['PR_DECLARATION'], /^\\([egx]?def|(new|renew|provide)(command|environment))\b/], 36 // any command starting with a \ and contains 37 // either only letters (a-z,A-Z), '@' (internal macros) 38 [PR['PR_KEYWORD'], /^\\[a-zA-Z@]+/], 39 // or contains only one character 40 [PR['PR_KEYWORD'], /^\\./], 41 // Highlight dollar for math mode and ampersam for tabular 42 [PR['PR_TYPE'], /^[$&]/], 43 // numeric measurement values with attached units 44 [PR['PR_LITERAL'], 45 /[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i], 46 // punctuation usually occurring within commands 47 [PR['PR_PUNCTUATION'], /^[{}()\[\]=]+/] 48 ]), 49 ['latex', 'tex']); 50