Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
132 lines (113 sloc) 4.37 KB
// ***** Customization begin
// Contributed by Ryan Grove <ryan@wonko.com>
/**
* @fileoverview
* Registers a language handler for Handlebars.
*
* @author Ryan Grove <ryan@wonko.com>
*/
PR['registerLangHandler'](
PR['createSimpleLexer'](
[],
[
// -- HTML ---------------------------------------------------------------
[PR['PR_DECLARATION'], /^<!\w[^>]*(?:>|$)/],
[PR['PR_COMMENT'], /^<\!--[\s\S]*?(?:-\->|$)/],
[PR['PR_PUNCTUATION'], /^(?:<[%?]|[%?]>)/],
// Unescaped content in an unknown language
['lang-', /^<\?([\s\S]+?)(?:\?>|$)/],
['lang-', /^<%([\s\S]+?)(?:%>|$)/],
['lang-', /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
// Unescaped Handlebars template in JavaScript.
['lang-handlebars', /^<script\b[^>]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
// Unescaped content in javascript. (Or possibly vbscript).
['lang-js', /^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
// Contains unescaped stylesheet content
['lang-css', /^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],
['lang-in.tag', /^(<\/?[a-z][^<>]*>)/i],
// -- Handlebars ---------------------------------------------------------
// Tag (escaped).
[PR['PR_DECLARATION'], /^{{[#^>/]?\s*[\w.][^}]*}}/],
// Tag (unescaped).
[PR['PR_DECLARATION'], /^{{&?\s*[\w.][^}]*}}/],
// Tag (unescaped).
[PR['PR_DECLARATION'], /^{{{>?\s*[\w.][^}]*}}}/],
// Comment.
[PR['PR_COMMENT'], /^{{![^}]*}}/]
]),
['handlebars', 'hbs']);
// Copyright (C) 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview
* Registers a language handler for CSS.
*
*
* To use, include prettify.js and this file in your HTML page.
* Then put your code in an HTML tag like
* <pre class="prettyprint lang-css"></pre>
*
*
* http://www.w3.org/TR/CSS21/grammar.html Section G2 defines the lexical
* grammar. This scheme does not recognize keywords containing escapes.
*
* @author mikesamuel@gmail.com
*/
PR['registerLangHandler'](
PR['createSimpleLexer'](
[
// The space production <s>
[PR['PR_PLAIN'], /^[ \t\r\n\f]+/, null, ' \t\r\n\f']
],
[
// Quoted strings. <string1> and <string2>
[PR['PR_STRING'],
/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null],
[PR['PR_STRING'],
/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null],
['lang-css-str', /^url\(([^\)\"\']*)\)/i],
[PR['PR_KEYWORD'],
/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,
null],
// A property name -- an identifier followed by a colon.
['lang-css-kw', /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],
// A C style block comment. The <comment> production.
[PR['PR_COMMENT'], /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],
// Escaping text spans
[PR['PR_COMMENT'], /^(?:<!--|-->)/],
// A number possibly containing a suffix.
[PR['PR_LITERAL'], /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
// A hex color
[PR['PR_LITERAL'], /^#(?:[0-9a-f]{3}){1,2}/i],
// An identifier
[PR['PR_PLAIN'],
/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],
// A run of punctuation
[PR['PR_PUNCTUATION'], /^[^\s\w\'\"]+/]
]),
['css']);
PR['registerLangHandler'](
PR['createSimpleLexer']([],
[
[PR['PR_KEYWORD'],
/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]
]),
['css-kw']);
PR['registerLangHandler'](
PR['createSimpleLexer']([],
[
[PR['PR_STRING'], /^[^\)\"\']+/]
]),
['css-str']);
// ****** Customization end