| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 | |
| 16 /** | |
| 17 * @fileoverview | |
| 18 * Registers a language handler for Wiki pages. | |
| 19 * | |
| 20 * Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax | |
| 21 * | |
| 22 * @author mikesamuel@gmail.com | |
| 23 */ | |
| 24 | |
| 25 PR['registerLangHandler']( | |
| 26 PR['createSimpleLexer']( | |
| 27 [ | |
| 28 // Whitespace | |
| 29 [PR['PR_PLAIN'], /^[\t \xA0a-gi-z0-9]+/, null, | |
| 30 '\t \xA0abcdefgijklmnopqrstuvwxyz0123456789'], | |
| 31 // Wiki formatting | |
| 32 [PR['PR_PUNCTUATION'], /^[=*~\^\[\]]+/, null, '=*~^[]'] | |
| 33 ], | |
| 34 [ | |
| 35 // Meta-info like #summary, #labels, etc. | |
| 36 ['lang-wiki.meta', /(?:^^|\r\n?|\n)(#[a-z]+)\b/], | |
| 37 // A WikiWord | |
| 38 [PR['PR_LITERAL'], /^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\
b/ | |
| 39 ], | |
| 40 // A preformatted block in an unknown language | |
| 41 ['lang-', /^\{\{\{([\s\S]+?)\}\}\}/], | |
| 42 // A block of source code in an unknown language | |
| 43 ['lang-', /^`([^\r\n`]+)`/], | |
| 44 // An inline URL. | |
| 45 [PR['PR_STRING'], | |
| 46 /^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i], | |
| 47 [PR['PR_PLAIN'], /^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/] | |
| 48 ]), | |
| 49 ['wiki']); | |
| 50 | |
| 51 PR['registerLangHandler']( | |
| 52 PR['createSimpleLexer']([[PR['PR_KEYWORD'], /^#[a-z]+/i, null, '#']], []), | |
| 53 ['wiki.meta']); | |
| OLD | NEW |