From 7e830706e727ffd3d0609b637baa0384020d8efa Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 25 May 2014 14:04:46 +0000 Subject: [PATCH] Added ada syntax highlighting --- codepot/src/codepot/views/code_blame.php | 11 +- codepot/src/codepot/views/code_file.php | 11 +- codepot/src/js/prettify/Makefile.am | 19 + codepot/src/js/prettify/lang-basic.js | 32 + codepot/src/js/prettify/lang-css.js | 85 ++- codepot/src/js/prettify/lang-dart.js | 88 +++ codepot/src/js/prettify/lang-erlang.js | 92 +++ codepot/src/js/prettify/lang-lisp.js | 3 +- codepot/src/js/prettify/lang-llvm.js | 61 ++ codepot/src/js/prettify/lang-matlab.js | 180 ++++++ codepot/src/js/prettify/lang-mumps.js | 139 +++++ codepot/src/js/prettify/lang-n.js | 45 +- codepot/src/js/prettify/lang-pascal.js | 32 + codepot/src/js/prettify/lang-r.js | 57 ++ codepot/src/js/prettify/lang-rd.js | 47 ++ codepot/src/js/prettify/lang-sql.js | 7 +- codepot/src/js/prettify/lang-tcl.js | 62 ++ codepot/src/js/prettify/lang-tex.js | 20 +- codepot/src/js/prettify/lang-vb.js | 13 +- codepot/src/js/prettify/prettify.js | 718 ++++++++++++++--------- 20 files changed, 1407 insertions(+), 315 deletions(-) create mode 100644 codepot/src/js/prettify/lang-basic.js create mode 100644 codepot/src/js/prettify/lang-dart.js create mode 100644 codepot/src/js/prettify/lang-erlang.js create mode 100644 codepot/src/js/prettify/lang-llvm.js create mode 100644 codepot/src/js/prettify/lang-matlab.js create mode 100644 codepot/src/js/prettify/lang-mumps.js create mode 100644 codepot/src/js/prettify/lang-pascal.js create mode 100644 codepot/src/js/prettify/lang-r.js create mode 100644 codepot/src/js/prettify/lang-rd.js create mode 100644 codepot/src/js/prettify/lang-tcl.js diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index a4e07cc1..a1a783ad 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -6,9 +6,12 @@ + + + @@ -173,14 +176,18 @@ print anchor ("code/fetch/{$project->id}/${xpar}{$revreq}", $this->lang->line('D code_hide_line_num == 'Y') $prettyprint_linenums = ''; ?> -
+
 " />
 
 
+
+
 
 
 
+
 
 
 
@@ -176,14 +179,18 @@ $this->load->view (
 
 code_hide_line_num == 'Y') $prettyprint_linenums = '';
 ?>
 
-
+
 
 
diff --git a/codepot/src/js/prettify/Makefile.am b/codepot/src/js/prettify/Makefile.am index 5ba1ddf2..79d4bc55 100644 --- a/codepot/src/js/prettify/Makefile.am +++ b/codepot/src/js/prettify/Makefile.am @@ -1,15 +1,34 @@ wwwdir=$(WWWDIR)/js/prettify www_DATA = \ + lang-ada.js \ lang-apollo.js \ + lang-basic.js \ + lang-clj.js \ lang-css.js \ + lang-dart.js \ + lang-erlang.js \ + lang-go.js \ lang-hs.js \ lang-lisp.js \ + lang-llvm.js \ lang-lua.js \ + lang-matlab.js \ lang-ml.js \ + lang-mumps.js \ + lang-n.js \ + lang-pascal.js \ lang-proto.js \ + lang-r.js \ + lang-rd.js \ + lang-scala.js \ lang-sql.js \ + lang-tcl.js \ + lang-tex.js \ lang-vb.js \ + lang-vhdl.js \ lang-wiki.js \ + lang-xq.js \ + lang-yaml.js \ prettify.css \ prettify.js diff --git a/codepot/src/js/prettify/lang-basic.js b/codepot/src/js/prettify/lang-basic.js new file mode 100644 index 00000000..b3c33fdd --- /dev/null +++ b/codepot/src/js/prettify/lang-basic.js @@ -0,0 +1,32 @@ +// Contributed by peter dot kofler at code minus cop dot org + +/** + * @fileoverview + * Registers a language handler for Basic. + * + * To use, include prettify.js and this file in your HTML page. + * Then put your code in an HTML tag like + *
(my BASIC code)
+ * + * @author peter dot kofler at code minus cop dot org + */ + +PR.registerLangHandler( + PR.createSimpleLexer( + [ // shortcutStylePatterns + // "single-line-string" + [PR.PR_STRING, /^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/, null, '"'], + // Whitespace + [PR.PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0'] + ], + [ // fallthroughStylePatterns + // A line comment that starts with REM + [PR.PR_COMMENT, /^REM[^\r\n]*/, null], + [PR.PR_KEYWORD, /^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/, null], + [PR.PR_PLAIN, /^[A-Z][A-Z0-9]?(?:\$|%)?/i, null], + // Literals .0, 0, 0.0 0E13 + [PR.PR_LITERAL, /^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, null, '0123456789'], + [PR.PR_PUNCTUATION, /^.[^\s\w\.$%"]*/, null] + // [PR.PR_PUNCTUATION, /^[-,:;!<>=\+^\/\*]+/] + ]), + ['basic','cbm']); diff --git a/codepot/src/js/prettify/lang-css.js b/codepot/src/js/prettify/lang-css.js index 034bd595..879dad20 100644 --- a/codepot/src/js/prettify/lang-css.js +++ b/codepot/src/js/prettify/lang-css.js @@ -30,19 +30,95 @@ * @author mikesamuel@gmail.com */ +// This file is a call to a function defined in prettify.js which defines a +// lexical scanner for CSS and maps tokens to styles. + +// The call to PR['registerLangHandler'] is quoted so that Closure Compiler +// will not rename the call so that this language extensions can be +// compiled/minified separately from one another. Other symbols defined in +// prettify.js are similarly quoted. + +// The call is structured thus: +// PR['registerLangHandler']( +// PR['createSimpleLexer']( +// shortcutPatterns, +// fallThroughPatterns), +// [languageId0, ..., languageIdN]) + +// Langugage IDs +// ============= +// The language IDs are typically the file extensions of source files for +// that language so that users can syntax highlight arbitrary files based +// on just the extension. This is heuristic, but works pretty well in +// practice. + +// Patterns +// ======== +// Lexers are typically implemented as a set of regular expressions. +// The SimpleLexer function takes regular expressions, styles, and some +// pragma-info and produces a lexer. A token description looks like +// [STYLE_NAME, /regular-expression/, pragmas] + +// Initially, simple lexer's inner loop looked like: + +// while sourceCode is not empty: +// try each regular expression in order until one matches +// remove the matched portion from sourceCode + +// This was really slow for large files because some JS interpreters +// do a buffer copy on the matched portion which is O(n*n) + +// The current loop now looks like + +// 1. use js-modules/combinePrefixPatterns.js to +// combine all regular expressions into one +// 2. use a single global regular expresion match to extract all tokens +// 3. for each token try regular expressions in order until one matches it +// and classify it using the associated style + +// This is a lot more efficient but it does mean that lookahead and lookbehind +// can't be used across boundaries to classify tokens. + +// Sometimes we need lookahead and lookbehind and sometimes we want to handle +// embedded language -- JavaScript or CSS embedded in HTML, or inline assembly +// in C. + +// If a particular pattern has a numbered group, and its style pattern starts +// with "lang-" as in +// ['lang-js', /