lang-wiki.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. * @fileoverview
  16. * Registers a language handler for Wiki pages.
  17. *
  18. * Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax
  19. *
  20. * @author mikesamuel@gmail.com
  21. */
  22. PR['registerLangHandler'](
  23. PR['createSimpleLexer'](
  24. [
  25. // Whitespace
  26. [PR['PR_PLAIN'], /^[\t \xA0a-gi-z0-9]+/, null,
  27. '\t \xA0abcdefgijklmnopqrstuvwxyz0123456789'],
  28. // Wiki formatting
  29. [PR['PR_PUNCTUATION'], /^[=*~\^\[\]]+/, null, '=*~^[]']
  30. ],
  31. [
  32. // Meta-info like #summary, #labels, etc.
  33. ['lang-wiki.meta', /(?:^^|\r\n?|\n)(#[a-z]+)\b/],
  34. // A WikiWord
  35. [PR['PR_LITERAL'], /^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/
  36. ],
  37. // A preformatted block in an unknown language
  38. ['lang-', /^\{\{\{([\s\S]+?)\}\}\}/],
  39. // A block of source code in an unknown language
  40. ['lang-', /^`([^\r\n`]+)`/],
  41. // An inline URL.
  42. [PR['PR_STRING'],
  43. /^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],
  44. [PR['PR_PLAIN'], /^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]
  45. ]),
  46. ['wiki']);
  47. PR['registerLangHandler'](
  48. PR['createSimpleLexer']([[PR['PR_KEYWORD'], /^#[a-z]+/i, null, '#']], []),
  49. ['wiki.meta']);