diff --git a/.gitignore b/.gitignore index a8e55f6..80af35e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .sass-cache - +gems.locked diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 1cd4f24..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,15 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - rake (11.3.0) - sass (3.4.22) - -PLATFORMS - ruby - -DEPENDENCIES - rake - sass - -BUNDLED WITH - 1.13.6 diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 9b5827a..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011 Samuel G. D. Williams. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/Rakefile b/bake.rb similarity index 72% rename from Rakefile rename to bake.rb index b134529..5919560 100644 --- a/Rakefile +++ b/bake.rb @@ -9,24 +9,30 @@ require 'pathname' require 'yaml' -require './ext/theme' +require 'closure-compiler' + +require_relative 'ext/theme' -JSMIN_EXEC = ["java", "-jar", File.dirname(__FILE__) + "/ext/closure/compiler.jar"] CACHE_FILE = "jquery.syntax.cache.js" MINIFIED_FILE = "jquery.syntax.min.js" + LICENSE = < [:update_aliases] do - IO.popen(JSMIN_EXEC, "r+") do |min| - ["jquery.syntax.js", "jquery.syntax.cache.js"].each do |path| - min.write(File.read(path)) - end +def build_combined + self.update_aliases - min.close_write + compiler = Closure::Compiler.new - buf = min.read + output = compiler.compile_files( + ["jquery.syntax.js", "jquery.syntax.cache.js"] + ) - File.open(MINIFIED_FILE, "w") do |fp| - fp.write(LICENSE) - fp.write(buf) - end + File.open(MINIFIED_FILE, "w") do |file| + file.write(LICENSE) + file.write(output) end end # Note... this is one way ! -task :compress_all => [:build_combined] do +def compress_all + self.build_combined + files = Dir["jquery.syntax*.js"] + compiler = Closure::Compiler.new puts "Minifying JavaScript..." files.each do |path| - # puts "Minifying #{File.basename(path)}..." - IO.popen(JSMIN_EXEC, "r+") do |min| - min.write(File.read(path)) - - min.close_write - - File.open(path, "w") do |fp| - fp.write(LICENSE) - fp.write(min.read) - end + puts "Minifying #{File.basename(path)}..." + + output = compiler.compile_files([path]) + + File.open(path, "w") do |file| + file.write(LICENSE) + file.write(output) end end end -task :setup_prefix do +def setup_prefix if ENV['CONFIG'] config_path = BASE_PATH + ENV['CONFIG'] else @@ -161,10 +164,10 @@ end puts "Using configuration #{config_path}" - $config = YAML::load_file(config_path) + @config = YAML::load_file(config_path) - if $config['prefix'] && !ENV['PREFIX'] - prefix = config_path.dirname + ($config['prefix'] || DIST_PATH) + if @config['prefix'] && !ENV['PREFIX'] + prefix = config_path.dirname + (@config['prefix'] || DIST_PATH) elsif ENV['PREFIX'] prefix = BASE_PATH + ENV['PREFIX'] else @@ -179,11 +182,12 @@ puts "Working in #{Dir.getwd}..." end -task :install => :setup_prefix do |task, arguments| - Rake::Task[:clean].invoke(arguments[:config]) +def install + self.setup_prefix + self.clean - $config['themes'].each do |theme| - Rake::Task[:generate_stylesheets].execute(:theme => theme) + @config['themes'].each do |theme| + self.generate_stylesheets(theme: theme) end js_files = Dir[BASE_PATH + "source/jquery.syntax*.js"] @@ -196,16 +200,20 @@ FileUtils.cp(path, output_path) end - Rake::Task[:build_combined].invoke - Rake::Task[:compress_all].invoke if $config['minify'] + self.build_combined + self.compress_all if @config['minify'] puts "Install into #{Dir.getwd} finished." end -task :clean => :setup_prefix do |task, arguments| +def clean + self.setup_prefix + Dir.glob("*") do |path| FileUtils.rm_r path end end -task :default => :install +def default + self.install +end \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index 79543da..0000000 --- a/bower.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "jquery-syntax", - "dependencies": { - "jquery": ">=1.4.1" - }, - "description": "jQuery.Syntax is an extremely fast and lightweight syntax highlighter written in JavaScript. It has dynamic loading of syntax source files and integrates cleanly using CSS or modelines.", - "main": "dist/jquery.syntax.js", - "authors": [ - "Samuel Williams ["/"], :root => "./" + +run lambda { |env| $stderr.puts("404 #{env['REQUEST_PATH']}"); [404, {}, []] } diff --git a/dist/base/jquery.syntax.brush.apache.css b/dist/base/jquery.syntax.brush.apache.css index 24832b3..dfe774f 100644 --- a/dist/base/jquery.syntax.brush.apache.css +++ b/dist/base/jquery.syntax.brush.apache.css @@ -4,3 +4,9 @@ color: #00f; } .syntax-theme-base .apache .tag-name { font-weight: bold; } + +@media (prefers-color-scheme: dark) { + .syntax-theme-base .apache .tag { + color: #6666ff; } + .syntax-theme-base .apache .tag-name { + color: #9999ff; } } diff --git a/dist/base/jquery.syntax.brush.bash-script.css b/dist/base/jquery.syntax.brush.bash-script.css index fc90f7a..6105a18 100644 --- a/dist/base/jquery.syntax.brush.bash-script.css +++ b/dist/base/jquery.syntax.brush.bash-script.css @@ -1,5 +1,3 @@ -.syntax-theme-base .bash-script .function { - font-weight: bold; } .syntax-theme-base .bash-script .option { color: #03f; } .syntax-theme-base .bash-script .env { diff --git a/dist/base/jquery.syntax.brush.bash.css b/dist/base/jquery.syntax.brush.bash.css index 25fb6ae..3c69f7e 100644 --- a/dist/base/jquery.syntax.brush.bash.css +++ b/dist/base/jquery.syntax.brush.bash.css @@ -1,10 +1,2 @@ -.syntax-theme-base .bash { - color: #555; } - .syntax-theme-base .bash .prompt { - color: #0c0; - font-weight: bold; } - .syntax-theme-base .bash .bash-script { - font-style: normal; - color: black; } - .syntax-theme-base .bash .stderr { - color: red; } +.syntax-theme-base .bash .stderr { + color: red; } diff --git a/dist/base/jquery.syntax.brush.clang.css b/dist/base/jquery.syntax.brush.clang.css index 75698f3..012433b 100644 --- a/dist/base/jquery.syntax.brush.clang.css +++ b/dist/base/jquery.syntax.brush.clang.css @@ -1,3 +1,6 @@ .syntax-theme-base .preprocessor { - color: #63381f; - font-style: italic; } + color: #63381f; } + +@media (prefers-color-scheme: dark) { + .syntax-theme-base .preprocessor { + color: #c97e52; } } diff --git a/dist/base/jquery.syntax.brush.html.css b/dist/base/jquery.syntax.brush.html.css index 138c9ca..f720801 100644 --- a/dist/base/jquery.syntax.brush.html.css +++ b/dist/base/jquery.syntax.brush.html.css @@ -1,5 +1,3 @@ .syntax-theme-base .html .doctype { font-weight: bold; color: #938; } -.syntax-theme-base .html .javascript, .syntax-theme-base .html .css { - font-style: italic; } diff --git a/dist/base/jquery.syntax.brush.ruby.css b/dist/base/jquery.syntax.brush.ruby.css index d8ac9b4..97c50cf 100644 --- a/dist/base/jquery.syntax.brush.ruby.css +++ b/dist/base/jquery.syntax.brush.ruby.css @@ -1,2 +1,2 @@ .syntax-theme-base .ruby .string .ruby { - color: #000; } + color: #808080; } diff --git a/dist/base/jquery.syntax.brush.xml.css b/dist/base/jquery.syntax.brush.xml.css index 218f805..0d3f20e 100644 --- a/dist/base/jquery.syntax.brush.xml.css +++ b/dist/base/jquery.syntax.brush.xml.css @@ -16,3 +16,20 @@ color: #666; background-color: #ddd; border-radius: 0.5em; } + +@media (prefers-color-scheme: dark) { + .syntax-theme-base .xml .cdata-content { + color: #a46; } + .syntax-theme-base .xml .xml-tag, .syntax-theme-base .xml .cdata { + color: #c59de7; } + .syntax-theme-base .xml .tag-name, .syntax-theme-base .xml .cdata-tag { + color: #9ae; } + .syntax-theme-base .xml .namespace { + color: #c59de7; } + .syntax-theme-base .xml .attribute { + color: #c59de7; } + .syntax-theme-base .xml .instruction { + color: #c59de7; } + .syntax-theme-base .xml .entity, .syntax-theme-base .xml .percent-escape { + color: #999; + background-color: #333; } } diff --git a/dist/base/jquery.syntax.core.css b/dist/base/jquery.syntax.core.css index 3ba0cd3..1d1f2bc 100644 --- a/dist/base/jquery.syntax.core.css +++ b/dist/base/jquery.syntax.core.css @@ -1,24 +1,21 @@ pre code.syntax-theme-base { display: block; } pre code.syntax-theme-base > span { - display: block; - white-space: pre-wrap; } + display: flex; } pre code.syntax-theme-base .indent { - display: block; - float: left; } + flex-grow: 0; + flex-shrink: 0; } pre code.syntax-theme-base .text { white-space: pre-wrap; - display: block; - overflow: hidden; - padding-left: 1rem; - text-indent: -1rem; } + padding-left: 2ch; + text-indent: -2ch; } .syntax-theme-base a { text-decoration: none; color: inherit; } .syntax-theme-base .function { color: #33f; } -.syntax-theme-base .keyword, .syntax-theme-base .access { +.syntax-theme-base .keyword, .syntax-theme-base .access, .syntax-theme-base .option { color: #7a0968; } .syntax-theme-base .type { color: #3239D6; } @@ -31,7 +28,7 @@ pre code.syntax-theme-base { .syntax-theme-base .string .escape { color: #f99; } .syntax-theme-base .operator { - color: #000000; } + color: black; } .syntax-theme-base .href { color: #0e0eff; text-decoration: underline; } @@ -39,21 +36,23 @@ pre code.syntax-theme-base { color: #466997; } .syntax-theme-base .highlight { background-color: #fdfdba; } -.syntax-theme-base pre { - overflow: auto; - font-family: inherit; } -.syntax-container.syntax-theme-base { - position: relative; } - .syntax-container.syntax-theme-base .toolbar { - font-size: 80%; - text-align: right; - padding: 0 0.2em 0.2em; } - .syntax-container.syntax-theme-base .toolbar a { - margin-left: 1em; } - .syntax-container.syntax-theme-base pre.raw { - overflow: auto; - padding: 0 0.4em 0 !important; - margin: 0 !important; - background-color: #f0f0f0; - border: 1px solid #aaa; } +@media (prefers-color-scheme: dark) { + .syntax-theme-base .operator { + color: white; } + .syntax-theme-base .function { + color: #c59de7; } + .syntax-theme-base .keyword, .syntax-theme-base .access, .syntax-theme-base .option { + color: #328eff; } + .syntax-theme-base .type { + color: #37a4ff; } + .syntax-theme-base .comment { + color: #849fca; } + .syntax-theme-base .constant { + color: #c9a452; } + .syntax-theme-base .string, .syntax-theme-base .symbol { + color: #ed7f7d; } + .syntax-theme-base .string .escape { + color: #f99; } + .syntax-theme-base .variable { + color: #6e6dff; } } diff --git a/dist/jquery.syntax.brush.bash-script.js b/dist/jquery.syntax.brush.bash-script.js index 0abacd2..1da775d 100644 --- a/dist/jquery.syntax.brush.bash-script.js +++ b/dist/jquery.syntax.brush.bash-script.js @@ -1,4 +1,4 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.register("bash-script",function(a){a.push(["&&","|",";","{","}"],{klass:"operator"});a.push({pattern:/(?:^|\||;|&&)\s*((?:"([^"]|\\")+"|'([^']|\\')+'|\\\n|.|[ \t])+?)(?=$|\||;|&&)/gmi,matches:Syntax.extractMatches({brush:"bash-statement"})})}); Syntax.register("bash-statement",function(a){a.push("break case continue do done elif else eq fi for function ge gt if in le lt ne return then until while".split(" "),{klass:"keyword"});a.push("> < = ` -- { } ( ) [ ]".split(" "),{klass:"operator"});a.push({pattern:/\(\((.*?)\)\)/gmi,klass:"expression",allow:["variable","string","operator","constant"]});a.push({pattern:/`([\s\S]+?)`/gmi,matches:Syntax.extractMatches({brush:"bash-script",debug:!0})});a.push(Syntax.lib.perlStyleComment);a.push({pattern:/^\s*((?:\S+?=\$?(?:\[[^\]]+\]|\(\(.*?\)\)|"(?:[^"]|\\")+"|'(?:[^']|\\')+'|\S+)\s*)*)((?:(\\ |\S)+)?)/gmi, -matches:Syntax.extractMatches({klass:"env",allow:["variable","string","operator","constant","expression"]},{klass:"function",allow:["variable","string"]})});a.push({pattern:/(\S+?)=/gmi,matches:Syntax.extractMatches({klass:"variable"}),only:["env"]});a.push({pattern:/\$\w+/g,klass:"variable"});a.push({pattern:/\s\-+\w+/g,klass:"option"});a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.push(Syntax.lib.webLink)}); +matches:Syntax.extractMatches({klass:"env",allow:["variable","string","operator","constant","expression"]},{klass:"function",allow:["variable","string"]})});a.push({pattern:/(\S+?)=/gmi,matches:Syntax.extractMatches({klass:"variable"}),only:["env"]});a.push({pattern:/\$\w+/g,klass:"variable"});a.push({pattern:/\s\-+[\w-]+/g,klass:"option"});a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.push(Syntax.lib.webLink)}); diff --git a/dist/jquery.syntax.brush.bash.js b/dist/jquery.syntax.brush.bash.js index fa981b2..04efaba 100644 --- a/dist/jquery.syntax.brush.bash.js +++ b/dist/jquery.syntax.brush.bash.js @@ -1,2 +1,2 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -Syntax.brushes.dependency("bash","bash-script");Syntax.register("bash",function(a){a.push({pattern:/^([\w@:~ ]*?[\$|\#])\s+(.*?)$/gm,matches:Syntax.extractMatches({klass:"prompt"},{brush:"bash-script"})});a.push({pattern:/^\-\- .*$/gm,klass:"comment",allow:["href"]});a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.webLink);a.push({klass:"stderr",allow:["string","comment","constant","href"]})}); +Syntax.brushes.dependency("bash","bash-script");Syntax.register("bash",function(a){a.push({pattern:/^([\w@:~ ]*?[\$|#])\s+(.*?)$/gm,matches:Syntax.extractMatches({klass:"prompt"},{brush:"bash-script"})});a.push({pattern:/^\-\- .*$/gm,klass:"comment",allow:["href"]});a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.webLink);a.push({klass:"stderr",allow:["string","comment","constant","href"]})}); diff --git a/dist/jquery.syntax.brush.basic.js b/dist/jquery.syntax.brush.basic.js index cee9da8..e8ac3df 100644 --- a/dist/jquery.syntax.brush.basic.js +++ b/dist/jquery.syntax.brush.basic.js @@ -1,5 +1,5 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.lib.vbStyleComment={pattern:/' .*$/gm,klass:"comment",allow:["href"]}; -Syntax.register("basic",function(a){var b="- & &= * *= / /= \\ = ^ ^= + += = -=".split(" "),b="+ - * / += -= *= /= = := == != ! % ? > < >= <= && || & | ^ . ~ .. >> << >>> <<< >>= <<= >>>= <<<= %= ^= @".split(" ");a.push("CBool CByte CChar CDate CDec CDbl Char CInt CLng CObj Const CShort CSng CStr CType Date Decimal Variant String Short Long Single Double Object Integer Boolean Byte Char".split(" "),{klass:"type"});a.push("AddHandler AddressOf Alias And AndAlso Ansi As Assembly Auto ByRef ByVal Call Case Catch Declare Default Delegate Dim DirectCast Do Each Else ElseIf End Enum Erase Error Event Exit Finally For Function Get GetType GoSub GoTo Handles If Implements Imports In Inherits Interface Is Let Lib Like Loop Mod Module MustOverride Namespace New Next Not On Option Optional Or OrElse Overloads Overridable Overrides ParamArray Preserve Property RaiseEvent ReadOnly ReDim REM RemoveHandler Resume Return Select Set Static Step Stop Structure Sub SyncLock Then Throw To Try TypeOf Unicode Until When While With WithEvents WriteOnly Xor ExternalSource Region Print Class".split(" "),{klass:"keyword", +Syntax.register("basic",function(a){var b="- & &= * *= / /= \\ = ^ ^= + += = -=".split(" ");b="+ - * / += -= *= /= = := == != ! % ? > < >= <= && || & | ^ . ~ .. >> << >>> <<< >>= <<= >>>= <<<= %= ^= @".split(" ");a.push("CBool CByte CChar CDate CDec CDbl Char CInt CLng CObj Const CShort CSng CStr CType Date Decimal Variant String Short Long Single Double Object Integer Boolean Byte Char".split(" "),{klass:"type"});a.push("AddHandler AddressOf Alias And AndAlso Ansi As Assembly Auto ByRef ByVal Call Case Catch Declare Default Delegate Dim DirectCast Do Each Else ElseIf End Enum Erase Error Event Exit Finally For Function Get GetType GoSub GoTo Handles If Implements Imports In Inherits Interface Is Let Lib Like Loop Mod Module MustOverride Namespace New Next Not On Option Optional Or OrElse Overloads Overridable Overrides ParamArray Preserve Property RaiseEvent ReadOnly ReDim REM RemoveHandler Resume Return Select Set Static Step Stop Structure Sub SyncLock Then Throw To Try TypeOf Unicode Until When While With WithEvents WriteOnly Xor ExternalSource Region Print Class".split(" "),{klass:"keyword", options:"gi"});a.push(b,{klass:"operator"});a.push("Public Protected Private Shared Friend Shadows MustInherit NotInheritable NotOverridable".split(" "),{klass:"access"});a.push(["Me","MyClass","MyBase","super","True","False","Nothing",/[A-Z][A-Z0-9_]+/g],{klass:"constant"});a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.camelCaseType);a.push(Syntax.lib.vbStyleComment);a.push(Syntax.lib.webLink);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.postprocess=function(a,b,c){jQuery(".function", b).each(function(){var a=jQuery(this).text();jQuery(this).replaceWith(jQuery("").attr("href","http://social.msdn.microsoft.com/Search/en-us?query="+encodeURIComponent(a)).text(a))});return b}}); diff --git a/dist/jquery.syntax.brush.css.js b/dist/jquery.syntax.brush.css.js index ba9bc0d..0aa079e 100644 --- a/dist/jquery.syntax.brush.css.js +++ b/dist/jquery.syntax.brush.css.js @@ -1,5 +1,5 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -Syntax.register("css",function(a){var d=[].concat(jQuery.map("AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond Blue BlueViolet Brown BurlyWood CadetBlue Chartreuse Chocolate Coral CornflowerBlue Cornsilk Crimson Cyan DarkBlue DarkCyan DarkGoldenRod DarkGray DarkGreen DarkKhaki DarkMagenta DarkOliveGreen Darkorange DarkOrchid DarkRed DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet DeepPink DeepSkyBlue DimGray DodgerBlue FireBrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold GoldenRod Gray Green GreenYellow HoneyDew HotPink IndianRed Indigo Ivory Khaki Lavender LavenderBlush LawnGreen LemonChiffon LightBlue LightCoral LightCyan LightGoldenRodYellow LightGrey LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow Lime LimeGreen Linen Magenta Maroon MediumAquaMarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin NavajoWhite Navy OldLace Olive OliveDrab Orange OrangeRed Orchid PaleGoldenRod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip PeachPuff Peru Pink Plum PowderBlue Purple Red RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen SeaShell Sienna Silver SkyBlue SlateBlue SlateGray Snow SpringGreen SteelBlue Tan Teal Thistle Tomato Turquoise Violet Wheat White WhiteSmoke Yellow YellowGreen".split(" "), -function(a){return"("+Syntax.Brush.convertStringToTokenPattern(a,!0)+")"}),jQuery.map(["#[0-9a-f]{3,6}","rgba?\\(.+?\\)","hsla?\\(.+?\\)"],function(a){return"("+Syntax.Brush.convertStringToTokenPattern(a,!1)+")"}));a.push({pattern:/\(.*?\)/g,allow:"*",disallow:["property"]});a.push({pattern:/\s*([\:\.\[\]\"\'\=\s\w#\.\-,]+)\s+\{/gm,matches:Syntax.extractMatches({klass:"selector",allow:["string"]})});a.push({pattern:RegExp(d.join("|"),"gi"),klass:"color",process:function(a,d){var e=Syntax.innerText(a), -c=document.createElement("span");c.className="colour-box";var b=document.createElement("span");b.className="sample";b.style.backgroundColor=e;b.appendChild(document.createTextNode(" "));c.appendChild(b);a.appendChild(c);return a}});a.push(Syntax.lib.cStyleComment);a.push(Syntax.lib.webLink);a.push({pattern:/\{(.|\n)*?\}/g,klass:"properties",allow:"*"});a.push({pattern:/\:(.*?(?=\})|(.|\n)*?(?=(\}|\;)))/g,matches:Syntax.extractMatches({klass:"value",allow:["color"],only:["properties"]})});a.push({pattern:/([\-\w]+):/g, +Syntax.register("css",function(a){var e=[].concat(jQuery.map("AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond Blue BlueViolet Brown BurlyWood CadetBlue Chartreuse Chocolate Coral CornflowerBlue Cornsilk Crimson Cyan DarkBlue DarkCyan DarkGoldenRod DarkGray DarkGreen DarkKhaki DarkMagenta DarkOliveGreen Darkorange DarkOrchid DarkRed DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet DeepPink DeepSkyBlue DimGray DodgerBlue FireBrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold GoldenRod Gray Green GreenYellow HoneyDew HotPink IndianRed Indigo Ivory Khaki Lavender LavenderBlush LawnGreen LemonChiffon LightBlue LightCoral LightCyan LightGoldenRodYellow LightGrey LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow Lime LimeGreen Linen Magenta Maroon MediumAquaMarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin NavajoWhite Navy OldLace Olive OliveDrab Orange OrangeRed Orchid PaleGoldenRod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip PeachPuff Peru Pink Plum PowderBlue Purple Red RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen SeaShell Sienna Silver SkyBlue SlateBlue SlateGray Snow SpringGreen SteelBlue Tan Teal Thistle Tomato Turquoise Violet Wheat White WhiteSmoke Yellow YellowGreen".split(" "), +function(a){return"("+Syntax.Brush.convertStringToTokenPattern(a,!0)+")"}),jQuery.map(["#[0-9a-f]{3,6}","rgba?\\(.+?\\)","hsla?\\(.+?\\)"],function(a){return"("+Syntax.Brush.convertStringToTokenPattern(a,!1)+")"}));a.push({pattern:/\(.*?\)/g,allow:"*",disallow:["property"]});a.push({pattern:/\s*([:\.\[\]"'=\s\w#\.\-,]+)\s+\{/gm,matches:Syntax.extractMatches({klass:"selector",allow:["string"]})});a.push({pattern:new RegExp(e.join("|"),"gi"),klass:"color",process:function(a,d){d=Syntax.innerText(a); +var c=document.createElement("span");c.className="colour-box";var b=document.createElement("span");b.className="sample";b.style.backgroundColor=d;b.appendChild(document.createTextNode(" "));c.appendChild(b);a.appendChild(c);return a}});a.push(Syntax.lib.cStyleComment);a.push(Syntax.lib.webLink);a.push({pattern:/\{(.|\n)*?\}/g,klass:"properties",allow:"*"});a.push({pattern:/:(.*?(?=\})|(.|\n)*?(?=(\}|;)))/g,matches:Syntax.extractMatches({klass:"value",allow:["color"],only:["properties"]})});a.push({pattern:/([\-\w]+):/g, matches:Syntax.extractMatches({klass:"property",process:Syntax.lib.webLinkProcess("http://cssdocs.org/")})});a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.cStyleFunction)}); diff --git a/dist/jquery.syntax.brush.html.js b/dist/jquery.syntax.brush.html.js index c52e968..8d40e8d 100644 --- a/dist/jquery.syntax.brush.html.js +++ b/dist/jquery.syntax.brush.html.js @@ -1,4 +1,4 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.brushes.dependency("html","xml");Syntax.brushes.dependency("html","javascript");Syntax.brushes.dependency("html","css");Syntax.brushes.dependency("html","php-script");Syntax.brushes.dependency("html","ruby"); -Syntax.register("html",function(a){a.push({pattern:/((.|\n)*?)<\/script>/gmi,matches:Syntax.extractMatches({brush:"javascript"})});a.push({pattern:/((.|\n)*?)<\/style>/gmi,matches:Syntax.extractMatches({brush:"css"})});a.push({pattern:/((<\?php)([\s\S]*?)(\?>))/gm,matches:Syntax.extractMatches({klass:"php-tag",allow:["keyword","php-script"]},{klass:"keyword"},{brush:"php-script"},{klass:"keyword"})});a.push({pattern:/((<\?rb?)([\s\S]*?)(\?>))/gm, -matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.push({pattern:/<%=?(.*?)(%>)/g,klass:"instruction",allow:["string"]});a.push({pattern:/<\!(DOCTYPE(.*?))>/g,matches:Syntax.extractMatches({klass:"doctype"})});a.push({pattern:/(%[0-9a-f]{2})/gi,klass:"percent-escape",only:["html"]});a.derives("xml")}); +Syntax.register("html",function(a){a.push({pattern:/((.|\n)*?)<\/script>/gmi,matches:Syntax.extractMatches({brush:"javascript"})});a.push({pattern:/((.|\n)*?)<\/style>/gmi,matches:Syntax.extractMatches({brush:"css"})});a.push({pattern:/((<\?php)([\s\S]*?)(\?>))/gm,matches:Syntax.extractMatches({klass:"php-tag",allow:["keyword","php-script"]},{klass:"keyword"},{brush:"php-script"},{klass:"keyword"})});a.push({pattern:/((<\?rb?)([\s\S]*?)(\?>))/gm, +matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.push({pattern:/<%=?(.*?)(%>)/g,klass:"instruction",allow:["string"]});a.push({pattern://g,matches:Syntax.extractMatches({klass:"doctype"})});a.push({pattern:/(%[0-9a-f]{2})/gi,klass:"percent-escape",only:["html"]});a.derives("xml")}); diff --git a/dist/jquery.syntax.brush.javascript.js b/dist/jquery.syntax.brush.javascript.js index 21579fa..4af2fa2 100644 --- a/dist/jquery.syntax.brush.javascript.js +++ b/dist/jquery.syntax.brush.javascript.js @@ -1,3 +1,3 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -Syntax.register("javascript",function(a){a.push(["this","true","false","null"],{klass:"constant"});a.push("function break case catch continue default delete do else for if in instanceof new return super switch throw true try typeof var while with prototype".split(" "),{klass:"keyword"});a.push("+*/-&|~!%<=>".split(""),{klass:"operator"});a.push(Syntax.lib.perlStyleRegularExpression);a.push(Syntax.lib.camelCaseType);a.push(Syntax.lib.cStyleComment);a.push(Syntax.lib.cppStyleComment);a.push(Syntax.lib.webLink); -a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.push(Syntax.lib.cStyleFunction)}); +Syntax.register("javascript",function(a){a.push(["this","true","false","null"],{klass:"constant"});a.push("async await break case catch class const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield".split(" "),{klass:"keyword"});a.push("+*/-&|~!%<=>".split(""),{klass:"operator"});a.push("implements package protected interface private public".split(" "),{klass:"access"});a.push(Syntax.lib.perlStyleRegularExpression); +a.push(Syntax.lib.camelCaseType);a.push(Syntax.lib.cStyleComment);a.push(Syntax.lib.cppStyleComment);a.push(Syntax.lib.webLink);a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.push(Syntax.lib.cStyleFunction)}); diff --git a/dist/jquery.syntax.brush.python.js b/dist/jquery.syntax.brush.python.js index 77ad519..36e73c7 100644 --- a/dist/jquery.syntax.brush.python.js +++ b/dist/jquery.syntax.brush.python.js @@ -1,5 +1,5 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.register("python",function(a){a.push({pattern:/^\s*@\w+/gm,klass:"decorator"});a.push(["self","True","False","None"],{klass:"constant"});a.push("and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield".split(" "),{klass:"keyword"});a.push("!= % %= & &= ( ) * ** **= *= + += , - -= . / // //= /= : ; < << <<= <= <> = == > >= >> >>= @ [ ] ^ ^= ` ` { | |= } ~".split(" "),{klass:"operator"}); a.push("abs all any basestring bin bool callable chr classmethod cmp compile complex delattr dict dir divmod enumerate eval execfile file filter float format frozenset getattr globals hasattr hash help hex id input int isinstance issubclass iter len list locals long map max min next object oct open ord pow print property range raw_input reduce reload repr reversed round set setattr slice sorted staticmethod str sum super tuple type type unichr unicode vars xrange zip __import__ apply buffer coerce intern".split(" "), -{klass:"builtin"});a.push(Syntax.lib.camelCaseType);a.push(Syntax.lib.cStyleFunction);a.push(Syntax.lib.perlStyleComment);a.push({pattern:/(['\"]{3})([^\1])*?\1/gm,klass:"comment"});a.push(Syntax.lib.webLink);a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.processes["function"]=Syntax.lib.webLinkProcess("http://docs.python.org/search.html?q=");a.processes.type=Syntax.lib.webLinkProcess("http://docs.python.org/search.html?q="); +{klass:"builtin"});a.push(Syntax.lib.camelCaseType);a.push(Syntax.lib.cStyleFunction);a.push(Syntax.lib.perlStyleComment);a.push({pattern:/(['"]{3})([^\1])*?\1/gm,klass:"comment"});a.push(Syntax.lib.webLink);a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString);a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.processes["function"]=Syntax.lib.webLinkProcess("http://docs.python.org/search.html?q=");a.processes.type=Syntax.lib.webLinkProcess("http://docs.python.org/search.html?q="); a.processes.builtin=Syntax.lib.webLinkProcess("http://docs.python.org/search.html?q=")}); diff --git a/dist/jquery.syntax.brush.ruby.js b/dist/jquery.syntax.brush.ruby.js index bf1a43c..494e5aa 100644 --- a/dist/jquery.syntax.brush.ruby.js +++ b/dist/jquery.syntax.brush.ruby.js @@ -1,5 +1,5 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.lib.rubyStyleFunction={pattern:/(?:def\s+|\.)([a-z_][a-z0-9_]+)/gi,matches:Syntax.extractMatches({klass:"function"})};Syntax.lib.rubyStyleSymbol={pattern:/([:]?):\w+/g,klass:"constant",matches:function(a,b){return""!=a[1]?[]:[new Syntax.Match(a.index,a[0].length,b,a[0])]}}; -Syntax.register("ruby",function(a){a.push(["private","protected","public"],{klass:"access"});a.push(["self","super","true","false","nil"],{klass:"constant"});a.push({pattern:/(\%[\S])(\{[\s\S]*?\})/g,matches:Syntax.extractMatches({klass:"function"},{klass:"constant"})});a.push({pattern:/`[^`]+`/g,klass:"string"});a.push({pattern:/\#\{([^\}]*)\}/g,matches:Syntax.extractMatches({brush:"ruby",only:["string"]})});a.push(Syntax.lib.rubyStyleRegularExpression);a.push({pattern:/(@+|\$)[\w]+/g,klass:"variable"}); +Syntax.register("ruby",function(a){a.push(["private","protected","public"],{klass:"access"});a.push(["self","super","true","false","nil"],{klass:"constant"});a.push({pattern:/(%[\S])(\{[\s\S]*?\})/g,matches:Syntax.extractMatches({klass:"function"},{klass:"constant"})});a.push({pattern:/`[^`]+`/g,klass:"string"});a.push({pattern:/#\{([^\}]*)\}/g,matches:Syntax.extractMatches({brush:"ruby",only:["string"]})});a.push(Syntax.lib.rubyStyleRegularExpression);a.push({pattern:/(@+|\$)[\w]+/g,klass:"variable"}); a.push(Syntax.lib.camelCaseType);a.push("alias and begin break case class def define_method defined? do else elsif end ensure false for if in module next not or raise redo rescue retry return then throw undef unless until when while yield block_given?".split(" "),{klass:"keyword"});a.push("+*/-&|~!%<=>".split(""),{klass:"operator"});a.push(Syntax.lib.rubyStyleSymbol);a.push(Syntax.lib.perlStyleComment);a.push(Syntax.lib.webLink);a.push(Syntax.lib.singleQuotedString);a.push(Syntax.lib.doubleQuotedString); a.push(Syntax.lib.stringEscape);a.push(Syntax.lib.decimalNumber);a.push(Syntax.lib.hexNumber);a.push(Syntax.lib.rubyStyleFunction);a.push(Syntax.lib.cStyleFunction)}); diff --git a/dist/jquery.syntax.brush.trenni.js b/dist/jquery.syntax.brush.trenni.js deleted file mode 100644 index ebd9b5e..0000000 --- a/dist/jquery.syntax.brush.trenni.js +++ /dev/null @@ -1,2 +0,0 @@ -// This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -Syntax.brushes.dependency("trenni","xml");Syntax.brushes.dependency("trenni","ruby");Syntax.register("trenni",function(a){a.push({pattern:/((<\?r)([\s\S]*?)(\?>))/gm,matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.push({pattern:/((#{)([\s\S]*?)(}))/gm,matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.derives("xml")}); diff --git a/dist/jquery.syntax.brush.xrb.js b/dist/jquery.syntax.brush.xrb.js new file mode 100644 index 0000000..6a4fb0c --- /dev/null +++ b/dist/jquery.syntax.brush.xrb.js @@ -0,0 +1,2 @@ +// This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. +Syntax.brushes.dependency("xrb","xml");Syntax.brushes.dependency("xrb","ruby");Syntax.register("xrb",function(a){a.push({pattern:/((<\?r)([\s\S]*?)(\?>))/gm,matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.push({pattern:/((#{)([\s\S]*?)(}))/gm,matches:Syntax.extractMatches({klass:"ruby-tag",allow:["keyword","ruby"]},{klass:"keyword"},{brush:"ruby"},{klass:"keyword"})});a.derives("xml")}); diff --git a/dist/jquery.syntax.cache.js b/dist/jquery.syntax.cache.js index 5e0a209..fcbb3e9 100644 --- a/dist/jquery.syntax.cache.js +++ b/dist/jquery.syntax.cache.js @@ -1,7 +1,7 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. Syntax.alias("apache",[]);Syntax.alias("applescript",[]);Syntax.alias("assembly",["asm"]);Syntax.alias("bash-script",[]);Syntax.alias("bash",[]);Syntax.alias("basic",["vb"]);Syntax.alias("clang",["cpp","c++","c","objective-c"]);Syntax.alias("csharp",["c-sharp","c#"]);Syntax.alias("css",[]);Syntax.alias("diff",["patch"]);Syntax.alias("go",[]);Syntax.alias("haskell",[]);Syntax.alias("html",[]);Syntax.alias("io",[]);Syntax.alias("java",[]);Syntax.alias("javascript",["js","actionscript"]); Syntax.alias("kai",[]);Syntax.alias("lisp",["scheme","clojure"]);Syntax.alias("lua",[]);Syntax.alias("nginx",[]);Syntax.alias("ocaml",["ml","sml","fsharp"]);Syntax.alias("ooc",[]);Syntax.alias("pascal",["delphi"]);Syntax.alias("perl5",[]);Syntax.alias("php-script",[]);Syntax.alias("php",[]);Syntax.alias("plain",["text"]);Syntax.alias("protobuf",[]);Syntax.alias("python",[]);Syntax.alias("ruby",[]);Syntax.alias("scala",[]);Syntax.alias("smalltalk",[]);Syntax.alias("sql",[]); -Syntax.alias("super-collider",["sc"]);Syntax.alias("swift",[]);Syntax.alias("html",[]);Syntax.alias("xml",[]);Syntax.alias("yaml",[]);Syntax.styles["jquery.syntax.brush.apache"]=["base/jquery.syntax.brush.apache.css"];Syntax.styles["jquery.syntax.brush.applescript"]=["base/jquery.syntax.brush.applescript.css"];Syntax.styles["jquery.syntax.brush.assembly"]=["base/jquery.syntax.brush.assembly.css"];Syntax.styles["jquery.syntax.brush.bash-script"]=["base/jquery.syntax.brush.bash-script.css"]; +Syntax.alias("super-collider",["sc"]);Syntax.alias("swift",[]);Syntax.alias("xml",[]);Syntax.alias("xrb",["trenni"]);Syntax.alias("yaml",[]);Syntax.styles["jquery.syntax.brush.apache"]=["base/jquery.syntax.brush.apache.css"];Syntax.styles["jquery.syntax.brush.applescript"]=["base/jquery.syntax.brush.applescript.css"];Syntax.styles["jquery.syntax.brush.assembly"]=["base/jquery.syntax.brush.assembly.css"];Syntax.styles["jquery.syntax.brush.bash-script"]=["base/jquery.syntax.brush.bash-script.css"]; Syntax.styles["jquery.syntax.brush.bash"]=["base/jquery.syntax.brush.bash.css"];Syntax.styles["jquery.syntax.brush.clang"]=["base/jquery.syntax.brush.clang.css"];Syntax.styles["jquery.syntax.brush.css"]=["base/jquery.syntax.brush.css.css"];Syntax.styles["jquery.syntax.brush.diff"]=["base/jquery.syntax.brush.diff.css"];Syntax.styles["jquery.syntax.brush.html"]=["base/jquery.syntax.brush.html.css"];Syntax.styles["jquery.syntax.brush.ocaml"]=["base/jquery.syntax.brush.ocaml.css"]; Syntax.styles["jquery.syntax.brush.protobuf"]=["base/jquery.syntax.brush.protobuf.css"];Syntax.styles["jquery.syntax.brush.python"]=["base/jquery.syntax.brush.python.css"];Syntax.styles["jquery.syntax.brush.ruby"]=["base/jquery.syntax.brush.ruby.css"];Syntax.styles["jquery.syntax.brush.xml"]=["base/jquery.syntax.brush.xml.css"];Syntax.styles["jquery.syntax.core"]=["base/jquery.syntax.core.css","bright/jquery.syntax.core.css","paper/jquery.syntax.core.css"];Syntax.styles["jquery.syntax.editor"]=["base/jquery.syntax.editor.css"]; Syntax.themes.base=[];Syntax.themes.bright=["base"];Syntax.themes.paper=["base"]; diff --git a/dist/jquery.syntax.core.js b/dist/jquery.syntax.core.js index ffc3e8b..a3025ce 100644 --- a/dist/jquery.syntax.core.js +++ b/dist/jquery.syntax.core.js @@ -1,33 +1,34 @@ // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -RegExp.prototype.indexOf||(RegExp.indexOf=function(a,b){return a[0].indexOf(a[b])+a.index});RegExp.prototype.escape||(RegExp.escape=function(a){return a.replace(/[\-\[\]{}()*+?.\\\^$|,#\s]/g,"\\$&")});String.prototype.repeat||(String.prototype.repeat=function(a){return Array(a+1).join(this)});Syntax.innerText=function(a){var b;if(!a)return"";if("BR"==a.nodeName)return"\n";a.textContent?b=a.textContent:document.body.innerText&&(b=a.innerText);return b.replace(/\r\n?/g,"\n")}; -Syntax.extractElementMatches=function(a,b){var c=[];b=b||0;(function(a){for(var e=0;a[e];e++){var f=null,g=a[e];3===g.nodeType||4===g.nodeType?b+=g.nodeValue.length:1===g.nodeType&&(f=Syntax.innerText(g),c.push(new Syntax.Match(b,f.length,{klass:g.className,force:!0,element:g,allow:"*"},f)));8!==g.nodeType&&g.children&&arguments.callee(g.childNodes,b)}})(a);c.shift();return c}; -Syntax.extractMatches=function(){var a=arguments;return function(b,c){for(var d=[],e=0;e)/gm,klass:"comment"};Syntax.lib.webLink={pattern:/\w+:\/\/[\w\-.\/?%&=@:;#]*/g,klass:"href"};Syntax.lib.hexNumber={pattern:/\b0x[0-9a-fA-F]+/g,klass:"constant"};Syntax.lib.decimalNumber={pattern:/\b[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/g,klass:"constant"}; Syntax.lib.doubleQuotedString={pattern:/"([^\\"\n]|\\.)*"/g,klass:"string"};Syntax.lib.singleQuotedString={pattern:/'([^\\'\n]|\\.)*'/g,klass:"string"};Syntax.lib.multiLineDoubleQuotedString={pattern:/"([^\\"]|\\.)*"/g,klass:"string"};Syntax.lib.multiLineSingleQuotedString={pattern:/'([^\\']|\\.)*'/g,klass:"string"};Syntax.lib.stringEscape={pattern:/\\./g,klass:"escape",only:["string"]}; -Syntax.Match=function(a,b,c,d){this.offset=a;this.endOffset=a+b;this.length=b;this.expression=c;this.value=d;this.children=[];this.next=this.parent=null};Syntax.Match.prototype.shift=function(a,b){this.adjust(a,null,b);for(var c=0;c=this.offset&&a.endOffset<=this.endOffset};Syntax.Match.defaultReduceCallback=function(a,b){"string"===typeof a&&(a=document.createTextNode(a));b.appendChild(a)}; -Syntax.Match.prototype.reduce=function(a,b){var c=this.offset,d=document.createElement("span");a=a||Syntax.Match.defaultReduceCallback;this.expression&&this.expression.klass&&(0this.endOffset&&console.log("Syntax Warning: Start position "+c+" exceeds end of value "+this.endOffset);b&&(d=b(d,this));return d}; -Syntax.Match.prototype.canContain=function(a){return a.expression.force?!0:this.complete?!1:a.expression.only?!0:"undefined"===typeof this.expression.allow||jQuery.isArray(this.expression.disallow)&&-1!==jQuery.inArray(a.expression.klass,this.expression.disallow)?!1:"*"===this.expression.allow||jQuery.isArray(this.expression.allow)&&-1!==jQuery.inArray(a.expression.klass,this.expression.allow)?!0:!1}; -Syntax.Match.prototype.canHaveChild=function(a){if(a=a.expression.only){for(var b=this;null!==b;){if(-1!==jQuery.inArray(b.expression.klass,a))return!0;if((b=b.parent)&&b.complete)break}return!1}return!0};Syntax.Match.prototype._splice=function(a,b){return this.canHaveChild(b)?(this.children.splice(a,0,b),b.parent=this,b.expression.owner||(b.expression.owner=this.expression.owner),this):null}; -Syntax.Match.prototype.insert=function(a,b){if(!this.contains(a))return null;if(b){for(var c=this,d=0;d<=c.endOffset?c.insertAtEnd(a):a.force?this._insert(a):null:this._splice(b+1,a)}return this._splice(0,a)}; -Syntax.Match.prototype._insert=function(a){if(0==this.children.length)return this._splice(0,a);for(var b=0;b=c.endOffset)){if(c.contains(a))return c._insert(a);a=a.bisectAtOffsets([c.offset,c.endOffset]);a[0]&&this._splice(b,a[0]);a[1]&&c.insert(a[1]);if(a[2])a=a[2];else return this}}this._splice(this.children.length,a)}; -Syntax.Match.prototype.bisectAtOffsets=function(a){var b=[],c=this.offset,d=null,e=jQuery.merge([],this.children);a=a.slice(0);a.push(this.endOffset);a.sort(function(a,b){return a-b});for(var f=0;fthis.endOffset)break;g").attr("href",this.innerHTML).text(this.innerHTML))});e(g,b,a,d)})}; -Syntax.extractBrushName=function(a){a=a.toLowerCase();var b=a.match(/(brush|language)-([\S]+)/);if(b)return b[2];a=a.split(/ /);if(-1!==jQuery.inArray("syntax",a))for(b=0;b=this.offset&&b.endOffset<=this.endOffset};Syntax.Match.defaultReduceCallback=function(b,a){"string"===typeof b&&(b=document.createTextNode(b));a.appendChild(b)}; +Syntax.Match.prototype.reduce=function(b,a){var c=this.offset;var d=this.expression&&this.expression.element?this.expression.element.cloneNode(!1):document.createElement("span");b=b||Syntax.Match.defaultReduceCallback;this.expression&&this.expression.klass&&(0this.endOffset&&console.log("Syntax Warning: Start position "+c+" exceeds end of value "+this.endOffset);a&&(d=a(d,this));return d}; +Syntax.Match.prototype.canContain=function(b){return b.expression.force?!0:this.complete?!1:b.expression.only?!0:"undefined"===typeof this.expression.allow||jQuery.isArray(this.expression.disallow)&&-1!==jQuery.inArray(b.expression.klass,this.expression.disallow)?!1:"*"===this.expression.allow||jQuery.isArray(this.expression.allow)&&-1!==jQuery.inArray(b.expression.klass,this.expression.allow)?!0:!1}; +Syntax.Match.prototype.canHaveChild=function(b){if(b=b.expression.only){for(var a=this;null!==a;){if(-1!==jQuery.inArray(a.expression.klass,b))return!0;if((a=a.parent)&&a.complete)break}return!1}return!0};Syntax.Match.prototype._splice=function(b,a){return this.canHaveChild(a)?(this.children.splice(b,0,a),a.parent=this,a.expression.owner||(a.expression.owner=this.expression.owner),this):null}; +Syntax.Match.prototype.insert=function(b,a){if(!this.contains(b))return null;if(a){a=this;for(var c=0;c<=c.endOffset?c.insertAtEnd(b):b.force?this._insert(b):null:this._splice(a+1,b)}return this._splice(0,b)}; +Syntax.Match.prototype._insert=function(b){if(0==this.children.length)return this._splice(0,b);for(var a=0;a=c.endOffset)){if(c.contains(b))return c._insert(b);b=b.bisectAtOffsets([c.offset,c.endOffset]);b[0]&&this._splice(a,b[0]);b[1]&&c.insert(b[1]);if(b[2])b=b[2];else return this}}this._splice(this.children.length,b)}; +Syntax.Match.prototype.bisectAtOffsets=function(b){var a=[],c=this.offset,d=null,e=jQuery.merge([],this.children);b=b.slice(0);b.push(this.endOffset);b.sort(function(a,b){return a-b});for(var f=0;fthis.endOffset)break;g").attr("href",this.innerHTML).text(this.innerHTML))});e(f,a,b,d)})}; +Syntax.extractBrushName=function(b){b=b.toLowerCase();var a=b.match(/(brush|language)-([\S]+)/);if(a)return a[2];b=b.split(/ /);if(-1!==jQuery.inArray("syntax",b))for(a=0;aa.start&&d>a.start;)if(this.current.lines[b-1]==c.lines[d-1])b-=1,d-=1;else break;a.end=d;a.originalEnd=b;for(a.difference=c.lines.length-this.current.lines.length;0< -c.lines.length-1&&c.offsets[a.end-1]!=c.offsets[a.end];)a.end+=1,a.originalEnd+=1;this.current=c;return this.changed=a};Syntax.Editor.prototype.textForLines=function(a,c){return this.current.lines.slice(a,c).join("\n")+"\n"}; -Syntax.Editor.prototype.updateLines=function(a,c){if(a.start!=a.end){var b=a.start,d=a.end,b=b+this.current.offsets[b],d=d+this.current.offsets[d],b=Array.prototype.slice.call(this.container.childNodes,b,d);$(b).replaceWith(c)}else 0==a.start?$(this.container).prepend(c):(b=a.start,b+=this.current.offsets[b],$(this.container.childNodes[b]).after(c))}; -Syntax.Editor.getCharacterOffset=function(a){var c=0;if("undefined"!=typeof window.getSelection){var c=window.getSelection().getRangeAt(0),b=c.cloneRange();b.selectNodeContents(a);b.setEnd(c.endContainer,c.endOffset);c=b.toString().length}else"undefined"!=typeof document.selection&&"Control"!=document.selection.type&&(c=document.selection.createRange(),b=document.body.createTextRange(),b.moveToElementText(a),b.setEndPoint("EndToEnd",c),c=b.text.length);return c}; -Syntax.Editor.getNodesForCharacterOffsets=function(a,c){for(var b=document.createTreeWalker(c,NodeFilter.SHOW_TEXT,function(a){return NodeFilter.FILTER_ACCEPT},!1),d=[],f=0,g=0;g');b.append(c.children());var d=new Syntax.Editor(b.get(0)),f=function(b){var c=d.getClientState(),e=d.updateChangedLines();0>e.difference&&0
').append(b)}; +Syntax.Editor=function(a,b){this.container=a;this.current=this.getLines()};Syntax.Editor.prototype.getLines=function(){for(var a=this.container.childNodes,b=[],c=[],d="",f=0,e=0;ea.start&&d>a.start;)if(this.current.lines[c-1]==b.lines[d-1])--c,--d;else break;a.end=d;a.originalEnd=c;for(a.difference=b.lines.length-this.current.lines.length;0< +b.lines.length-1&&b.offsets[a.end-1]!=b.offsets[a.end];)a.end+=1,a.originalEnd+=1;this.current=b;return this.changed=a};Syntax.Editor.prototype.textForLines=function(a,b){return this.current.lines.slice(a,b).join("\n")+"\n"}; +Syntax.Editor.prototype.updateLines=function(a,b){if(a.start!=a.end){var c=a.start;a=a.end;c+=this.current.offsets[c];a+=this.current.offsets[a];c=Array.prototype.slice.call(this.container.childNodes,c,a);$(c).replaceWith(b)}else 0==a.start?$(this.container).prepend(b):(c=a.start,c+=this.current.offsets[c],$(this.container.childNodes[c]).after(b))}; +Syntax.Editor.getCharacterOffset=function(a){var b=0;if("undefined"!=typeof window.getSelection){b=window.getSelection().getRangeAt(0);var c=b.cloneRange();c.selectNodeContents(a);c.setEnd(b.endContainer,b.endOffset);b=c.toString().length}else"undefined"!=typeof document.selection&&"Control"!=document.selection.type&&(b=document.selection.createRange(),c=document.body.createTextRange(),c.moveToElementText(a),c.setEndPoint("EndToEnd",b),b=c.text.length);return b}; +Syntax.Editor.getNodesForCharacterOffsets=function(a,b){b=document.createTreeWalker(b,NodeFilter.SHOW_TEXT,function(a){return NodeFilter.FILTER_ACCEPT},!1);for(var c=[],d=0,f=0;f');c.append(b.children());var d=new Syntax.Editor(c.get(0)),f=function(b){var c=d.getClientState(),e=d.updateChangedLines();0>e.difference&&0
').append(c)}; diff --git a/dist/jquery.syntax.js b/dist/jquery.syntax.js index 634baeb..03cc180 100644 --- a/dist/jquery.syntax.js +++ b/dist/jquery.syntax.js @@ -3,6 +3,6 @@ Function.prototype.bind||(Function.prototype.bind=function(a){var b=Array.protot ResourceLoader.prototype._loaded=function(a){var b=this[a],c=this.loading[a];this.loading[a]=null;if(b)for(a=0;a");jQuery("head").append(b);Syntax.cacheStyleSheets||(a=a+"?"+Math.random());b.attr({rel:"stylesheet", -type:"text/css",href:a})},getScript:function(a,b){var c=document.createElement("script");c.onreadystatechange=function(){if(this.onload&&("loaded"==this.readyState||"complete"==this.readyState))this.onload(),this.onload=null};c.onload=b;c.type="text/javascript";Syntax.cacheScripts||(a=a+"?"+Math.random());c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},getResource:function(a,b,c){Syntax.detectRoot();a=a+"."+b;if(b=this.styles[a])for(var d=0;d");jQuery("head").append(b);Syntax.cacheStyleSheets||(a=a+"?"+Math.random());b.attr({rel:"stylesheet", -type:"text/css",href:a})},getScript:function(a,b){var c=document.createElement("script");c.onreadystatechange=function(){if(this.onload&&("loaded"==this.readyState||"complete"==this.readyState))this.onload(),this.onload=null};c.onload=b;c.type="text/javascript";Syntax.cacheScripts||(a=a+"?"+Math.random());c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},getResource:function(a,b,c){Syntax.detectRoot();a=a+"."+b;if(b=this.styles[a])for(var d=0;d

C++

// If we increase col by 1, the offset will increase by 1 unsigned rowMajorOffset(unsigned row, unsigned col, unsigned sz) { - return col + row * sz; + return col + row * sz; } // If we increase col by 1, the offset will increase by sz (number of elements per column i.e. number of rows) diff --git a/examples/wrapping-flex.html b/examples/wrapping-flex.html new file mode 100644 index 0000000..3f29162 --- /dev/null +++ b/examples/wrapping-flex.html @@ -0,0 +1,71 @@ + + + + + + + + +

sally

+
			foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar
+			apples = 10
+
+

bob

+ + \ No newline at end of file diff --git a/examples/wrapping.html b/examples/wrapping.html index 9665544..fdfac03 100644 --- a/examples/wrapping.html +++ b/examples/wrapping.html @@ -2,35 +2,180 @@ + + -
			foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar foo = bar
-
+

sally

+
#include <iostream>
+
+// If we increase row by 1, the offset will increase by sz (number of elements per row i.e. number of columns)
+// If we increase col by 1, the offset will increase by 1
+unsigned rowMajorOffset(unsigned row, unsigned col, unsigned sz)
+{
+    return col + row * sz;
+}
+
+// If we increase col by 1, the offset will increase by sz (number of elements per column i.e. number of rows)
+// If we increase row by 1, the offset will increase by 1
+unsigned columnMajorOffset(unsigned row, unsigned col, unsigned sz)
+{
+    return row + col * sz;
+}
+
+template <typename _ValueT, unsigned _R, unsigned _C, bool _ColumnMajor>
+class Matrix {
+protected:
+	enum { ColumnMajor = _ColumnMajor };
+	enum { R = _R };
+	enum { C = _C };
+
+	typedef _ValueT ValueT;
+
+	ValueT m_values[C*R];
+
+public:
+	const ValueT & at (unsigned r, unsigned c) const
+	{
+		if (ColumnMajor)
+			return m_values[columnMajorOffset(r, c, R)];
+		else
+			return m_values[rowMajorOffset(r, c, C)];
+	}
+
+	ValueT & at (unsigned r, unsigned c)
+	{
+		if (ColumnMajor)
+			return m_values[columnMajorOffset(r, c, R)];
+		else
+			return m_values[rowMajorOffset(r, c, C)];
+	}
+
+	void loadTestPattern ()
+	{
+		for (unsigned r = 0; r < R; r += 1)
+			for (unsigned c = 0; c < C; c += 1)
+				at(r, c) = (r+1) * 1000 + (c+1);
+	}
+
+	void debug ()
+	{
+		using namespace std;
+
+		if (ColumnMajor)
+			cout << "Column-Major Matrix " << "(" << R << "," << C << ")" << " @ " << this << endl;
+		else
+			cout << "Row-Major Matrix " << "(" << R << "," << C << ")" << " @ " << this << endl;
+
+		cout << "Memory Offset: ";
+		for (unsigned i = 0; i < (R*C); i += 1)
+			cout << i << "    ";
+		cout << endl;
+
+		cout << "       Values: ";	
+		for (unsigned i = 0; i < (R*C); i += 1)
+			cout << m_values[i] << " ";
+		cout << endl;
+
+		cout << "Standard Mathematical Notation:" << endl;
+		cout << "      ";
+		for (unsigned c = 0; c < C; c += 1)
+			cout << "Col " << c << " ";
+		cout << endl;
+
+		for (unsigned r = 0; r < R; r += 1) {
+			cout << "Row " << r << " ";
+			for (unsigned c = 0; c < C; c += 1)
+				cout << at(r, c) << "  ";
+			cout << endl;
+		}
+		cout << endl;
+	}
+
+	Matrix<ValueT, R, C, !ColumnMajor> transposeStorage () const
+	{
+		Matrix<ValueT, R, C, !ColumnMajor> result;
+
+		for (unsigned r = 0; r < R; r += 1)
+			for (unsigned c = 0; c < C; c += 1)
+				result.at(r, c) = at(r, c);
+
+		return result;
+	}
+
+	Matrix<ValueT, C, R, !ColumnMajor> transposeMatrix () const
+	{
+		Matrix<ValueT, C, R, !ColumnMajor> result;
+
+		memcpy(&result.at(0,0), m_values, sizeof(m_values));
+
+		return result;
+	}
+};
+
+int main (int argc, char * const argv[]) {
+	Matrix<float, 4, 2, false> rowMajorMatrix;
+	Matrix<float, 4, 2, true> columnMajorMatrix;
+
+	rowMajorMatrix.loadTestPattern();
+	rowMajorMatrix.debug();
+
+	columnMajorMatrix.loadTestPattern();
+	columnMajorMatrix.debug();
+
+	rowMajorMatrix = columnMajorMatrix.transposeStorage();
+	rowMajorMatrix.debug();
+
+	Matrix<float, 2, 4, false> transposedMatrix = columnMajorMatrix.transposeMatrix();
+	transposedMatrix.debug();
+
+	return 0;
+}
+

bob

\ No newline at end of file diff --git a/ext/closure/COPYING b/ext/closure/COPYING deleted file mode 100644 index d645695..0000000 --- a/ext/closure/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/ext/closure/README b/ext/closure/README deleted file mode 100644 index 14fc8fe..0000000 --- a/ext/closure/README +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2009 The Closure Compiler Authors. - * - * 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. - */ - -// -// Contents -// - -The Closure Compiler performs checking, instrumentation, and -optimizations on JavaScript code. The purpose of this README is to -explain how to build and run the Closure Compiler. - -The Closure Compiler requires Java 6 or higher. -http://www.java.com/ - - -// -// Building The Closure Compiler -// - -There are three ways to get a Closure Compiler executable. - -1) Use one we built for you. - -Pre-built Closure binaries can be found at -http://code.google.com/p/closure-compiler/downloads/list - - -2) Check out the source and build it with Apache Ant. - -First, check out the full source tree of the Closure Compiler. There -are instructions on how to do this at the project site. -http://code.google.com/p/closure-compiler/source/checkout - -Apache Ant is a cross-platform build tool. -http://ant.apache.org/ - -At the root of the source tree, there is an Ant file named -build.xml. To use it, navigate to the same directory and type the -command - -ant jar - -This will produce a jar file called "build/compiler.jar". - - -3) Check out the source and build it with Eclipse. - -Eclipse is a cross-platform IDE. -http://www.eclipse.org/ - -Under Eclipse's File menu, click "New > Project ..." and create a -"Java Project." You will see an options screen. Give the project a -name, select "Create project from existing source," and choose the -root of the checked-out source tree as the existing directory. Verify -that you are using JRE version 6 or higher. - -Eclipse can use the build.xml file to discover rules. When you -navigate to the build.xml file, you will see all the build rules in -the "Outline" pane. Run the "jar" rule to build the compiler in -build/compiler.jar. - - -// -// Running The Closure Compiler -// - -Once you have the jar binary, running the Closure Compiler is straightforward. - -On the command line, type - -java -jar compiler.jar - -This starts the compiler in interactive mode. Type - -var x = 17 + 25; - -then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux) -and "Enter" again. The Compiler will respond: - -var x=42; - -The Closure Compiler has many options for reading input from a file, -writing output to a file, checking your code, and running -optimizations. To learn more, type - -java -jar compiler.jar --help - -You can read more detailed documentation about the many flags at -http://code.google.com/closure/compiler/docs/gettingstarted_app.html - - -// -// Compiling Multiple Scripts -// - -If you have multiple scripts, you should compile them all together with -one compile command. - -java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js - -The Closure Compiler will concatenate the files in the order they're -passed at the command line. - -If you need to compile many, many scripts together, you may start to -run into problems with managing dependencies between scripts. You -should check out the Closure Library. It contains functions for -enforcing dependencies between scripts, and a tool called calcdeps.py -that knows how to give scripts to the Closure Compiler in the right -order. - -http://code.google.com/p/closure-library/ - -// -// Licensing -// - -Unless otherwise stated, all source files are licensed under -the Apache License, Version 2.0. - - ------ -Code under: -src/com/google/javascript/rhino -test/com/google/javascript/rhino - -URL: http://www.mozilla.org/rhino -Version: 1.5R3, with heavy modifications -License: Netscape Public License and MPL / GPL dual license - -Description: A partial copy of Mozilla Rhino. Mozilla Rhino is an -implementation of JavaScript for the JVM. The JavaScript parser and -the parse tree data structures were extracted and modified -significantly for use by Google's JavaScript compiler. - -Local Modifications: The packages have been renamespaced. All code not -relevant to parsing has been removed. A JsDoc parser and static typing -system have been added. - - ------ -Code in: -lib/rhino - -Rhino -URL: http://www.mozilla.org/rhino -Version: Trunk -License: Netscape Public License and MPL / GPL dual license - -Description: Mozilla Rhino is an implementation of JavaScript for the JVM. - -Local Modifications: Minor changes to parsing JSDoc that usually get pushed -up-stream to Rhino trunk. - - ------ -Code in: -lib/args4j.jar - -Args4j -URL: https://args4j.dev.java.net/ -Version: 2.0.16 -License: MIT - -Description: -args4j is a small Java class library that makes it easy to parse command line -options/arguments in your CUI application. - -Local Modifications: None. - - ------ -Code in: -lib/guava.jar - -Guava Libraries -URL: http://code.google.com/p/guava-libraries/ -Version: 14.0 -License: Apache License 2.0 - -Description: Google's core Java libraries. - -Local Modifications: None. - - ------ -Code in: -lib/jsr305.jar - -Annotations for software defect detection -URL: http://code.google.com/p/jsr-305/ -Version: svn revision 47 -License: BSD License - -Description: Annotations for software defect detection. - -Local Modifications: None. - - ------ -Code in: -lib/jarjar.jar - -Jar Jar Links -URL: http://jarjar.googlecode.com/ -Version: 1.1 -License: Apache License 2.0 - -Description: -A utility for repackaging Java libraries. - -Local Modifications: None. - - ----- -Code in: -lib/junit.jar - -JUnit -URL: http://sourceforge.net/projects/junit/ -Version: 4.10 -License: Common Public License 1.0 - -Description: A framework for writing and running automated tests in Java. - -Local Modifications: None. - - ---- -Code in: -lib/protobuf-java.jar - -Protocol Buffers -URL: http://code.google.com/p/protobuf/ -Version: 2.4.1 -License: New BSD License - -Description: Supporting libraries for protocol buffers, -an encoding of structured data. - -Local Modifications: None - - ---- -Code in: -lib/ant.jar -lib/ant-launcher.jar - -URL: http://ant.apache.org/bindownload.cgi -Version: 1.8.1 -License: Apache License 2.0 -Description: - Ant is a Java based build tool. In theory it is kind of like "make" - without make's wrinkles and with the full portability of pure java code. - -Local Modifications: None - - ---- -Code in: -lib/json.jar -URL: http://json.org/java/index.html -Version: JSON version 20090211 -License: MIT license -Description: -JSON is a set of java files for use in transmitting data in JSON format. - -Local Modifications: None - ---- -Code in: -tools/maven-ant-tasks-2.1.3.jar -URL: http://maven.apache.org -Version 2.1.3 -License: Apache License 2.0 -Description: - Maven Ant tasks are used to manage dependencies and to install/deploy to - maven repositories. - -Local Modifications: None diff --git a/ext/closure/compiler.jar b/ext/closure/compiler.jar deleted file mode 100644 index 39f5172..0000000 Binary files a/ext/closure/compiler.jar and /dev/null differ diff --git a/Gemfile b/gems.rb similarity index 50% rename from Gemfile rename to gems.rb index b9609e3..2a6a049 100644 --- a/Gemfile +++ b/gems.rb @@ -1,5 +1,10 @@ # A sample Gemfile source "https://rubygems.org" -gem "rake" +gem "bake" gem "sass" + +gem "closure-compiler" + +gem "rack" +gem "falcon" diff --git a/package.json b/package.json index 8cbc4b8..bc60d4e 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,14 @@ { "name": "jquery-syntax", - "version": "4.0.0", + "version": "4.4.0", "title": "jQuery.Syntax", "author": { "name": "Samuel Williams", - "email": "samuel@oriontransfer.org", - "url": "http://www.oriontransfer.co.nz/samuel-williams" + "email": "samuel@codeotaku.com", + "url": "https://www.codeotaku.com" }, - "licenses": [ - { - "type": "MIT", - "url": "https://opensource.org/licenses/MIT" - } - ], + "license": "MIT", + "repository": "https://github.com/ioquatix/jquery-syntax", "dependencies": { "jquery": ">=1.4.1" }, diff --git a/README.md b/readme.md similarity index 81% rename from README.md rename to readme.md index e464391..6f5eb3f 100644 --- a/README.md +++ b/readme.md @@ -34,15 +34,15 @@ All syntax highlighters are pretty good these days. But, there are some key diff ## Installation -jQuery.Syntax is easily installed using bower. +jQuery.Syntax is easily installed using `yarn`. - $ bower install jquery-syntax + $ yarn install jquery-syntax It has a `dist/` directory which follows standard conventions. ### Advanced Configuration -jQuery.Syntax compiles and minifies it's code using uses Rake (Ruby) and [Sass](http://sass-lang.com). Please review the included `Rakefile` and `install.yaml` for more details. +jQuery.Syntax compiles and minifies it's code using uses [`bake`](https://github.com/ioquatix/bake) (Ruby) and [Sass](http://sass-lang.com). Please review the included `bake.rb` and `install.yaml` for more details. ## Usage @@ -62,6 +62,41 @@ jQuery.Syntax is typically used to highlight both block code elements and inline
puts "Hello World"
+### Stylesheet Compatibility + +The following stylesheet sets some useful defaults and enables responsive tab-size indentation. + +```css +html { + font-size: 16px; + + /* Fix odd text-size in `display: flex` elements on Safari iOS */ + text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} + +@media (min-width: 40em) { + html { + font-size: 18px; + --tab-size: 4; + } +} + +@media (min-width: 80em) { + html { + font-size: 20px; + --tab-size: 4; + } +} + +pre { + /* -moz-tab-size is still required by Firefox */ + --tab-size: 2; + tab-size: var(--tab-size); + -moz-tab-size: var(--tab-size); +} +``` + ## Contributing 1. Fork it @@ -74,7 +109,7 @@ jQuery.Syntax is typically used to highlight both block code elements and inline Released under the MIT license. -Copyright, 2016, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams). +Copyright, 2011-2020, by [Samuel G. D. Williams](https://www.codeotaku.com/). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/source/jquery.syntax.brush.bash-script.js b/source/jquery.syntax.brush.bash-script.js index f2c6699..2e96bda 100644 --- a/source/jquery.syntax.brush.bash-script.js +++ b/source/jquery.syntax.brush.bash-script.js @@ -55,7 +55,7 @@ Syntax.register('bash-statement', function(brush) { klass: 'variable' }); - brush.push({pattern: /\s\-+\w+/g, klass: 'option'}) + brush.push({pattern: /\s\-+[\w-]+/g, klass: 'option'}) brush.push(Syntax.lib.singleQuotedString); brush.push(Syntax.lib.doubleQuotedString); diff --git a/source/jquery.syntax.brush.javascript.js b/source/jquery.syntax.brush.javascript.js index d0ad541..232e9f1 100644 --- a/source/jquery.syntax.brush.javascript.js +++ b/source/jquery.syntax.brush.javascript.js @@ -1,18 +1,21 @@ // brush: "javascript" aliases: ["js", "actionscript"] // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -// Copyright (c) 2011 Samuel G. D. Williams. +// Copyright (c) 2019 Samuel G. D. Williams. // See for licensing details. Syntax.register('javascript', function(brush) { - var keywords = ["function", "break", "case", "catch", "continue", "default", "delete", "do", "else", "for", "if", "in", "instanceof", "new", "return", "super", "switch", "throw", "true", "try", "typeof", "var", "while", "with", "prototype"]; + var keywords = ["async", "await", "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "export", "extends", "finally", "for", "function", "if", "import", "in", "instanceof", "let", "new", "return", "super", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "yield"]; var operators = ["+", "*", "/", "-", "&", "|", "~", "!", "%", "<", "=", ">"]; var values = ["this", "true", "false", "null"]; + var access = ["implements", "package", "protected", "interface", "private", "public"]; + brush.push(values, {klass: 'constant'}); brush.push(keywords, {klass: 'keyword'}); brush.push(operators, {klass: 'operator'}); + brush.push(access, {klass: 'access'}); // Regular expressions brush.push(Syntax.lib.perlStyleRegularExpression); @@ -37,4 +40,3 @@ Syntax.register('javascript', function(brush) { // Functions brush.push(Syntax.lib.cStyleFunction); }); - diff --git a/source/jquery.syntax.brush.trenni.js b/source/jquery.syntax.brush.xrb.js similarity index 84% rename from source/jquery.syntax.brush.trenni.js rename to source/jquery.syntax.brush.xrb.js index c787f1d..d3f3614 100644 --- a/source/jquery.syntax.brush.trenni.js +++ b/source/jquery.syntax.brush.xrb.js @@ -1,13 +1,13 @@ -// brush: "html" aliases: [] +// brush: "xrb" aliases: ["trenni"] // This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. // Copyright (c) 2011 Samuel G. D. Williams. // See for licensing details. -Syntax.brushes.dependency('trenni', 'xml'); -Syntax.brushes.dependency('trenni', 'ruby'); +Syntax.brushes.dependency('xrb', 'xml'); +Syntax.brushes.dependency('xrb', 'ruby'); -Syntax.register('trenni', function(brush) { +Syntax.register('xrb', function(brush) { brush.push({ pattern: /((<\?r)([\s\S]*?)(\?>))/gm, matches: Syntax.extractMatches( diff --git a/source/jquery.syntax.core.js b/source/jquery.syntax.core.js index 904ffde..47ae6de 100644 --- a/source/jquery.syntax.core.js +++ b/source/jquery.syntax.core.js @@ -42,6 +42,29 @@ Syntax.innerText = function(element) { return text.replace(/\r\n?/g, '\n'); } +Syntax.extractTextFromSelection = function(selection) { + var buffer = ""; + + for (var i = 0; i < selection.rangeCount; i += 1) { + var range = selection.getRangeAt(i), + text = range.toString(); + + buffer += text; + } + + return buffer; +} + +Syntax.copyCode = function(event) { + var + selection = window.getSelection(), + text = Syntax.extractTextFromSelection(selection); + + event.clipboardData.setData('text/plain', text); + + return false; +} + // Convert to stack based implementation Syntax.extractElementMatches = function (elems, offset) { var matches = [], current = [elems]; @@ -236,7 +259,13 @@ Syntax.Match.defaultReduceCallback = function (node, container) { // Convert a tree of matches into some flat form (typically HTML nodes). Syntax.Match.prototype.reduce = function (append, process) { var start = this.offset; - var container = document.createElement('span'); + var container = null; + + if (this.expression && this.expression.element) { + container = this.expression.element.cloneNode(false); + } else { + container = document.createElement('span'); + } append = append || Syntax.Match.defaultReduceCallback; @@ -1047,7 +1076,7 @@ Syntax.highlight = function (elements, options, callback) { var container = jQuery(this); var brush = options.brush || Syntax.extractBrushName(this.className); var text = Syntax.innerText(this); - + // We can augment the plain text to extract existing annotations (e.g. ...). var matches = Syntax.extractElementMatches(container); @@ -1056,8 +1085,10 @@ Syntax.highlight = function (elements, options, callback) { } Syntax.highlightText(text, brush, matches, options, function(html, brush/*, text, options*/) { + html.oncopy = Syntax.copyCode; + html = jQuery(html); - + // If there is a theme specified, ensure it is added to the top level class. if (options.theme) { // Load dependencies diff --git a/source/jquery.syntax.js b/source/jquery.syntax.js index d1adb30..b909666 100644 --- a/source/jquery.syntax.js +++ b/source/jquery.syntax.js @@ -151,17 +151,6 @@ var Syntax = { getScript: function (path, callback) { var script = document.createElement('script'); - // Internet Exploder - script.onreadystatechange = function() { - if (this.onload && (this.readyState == 'loaded' || this.readyState == 'complete')) { - this.onload(); - - // Ensure the function is only called once. - this.onload = null; - } - }; - - // Every other modern browser script.onload = callback; script.type = "text/javascript"; diff --git a/themes/base/_layout.scss b/themes/base/_layout.scss deleted file mode 100644 index 43a1e76..0000000 --- a/themes/base/_layout.scss +++ /dev/null @@ -1,18 +0,0 @@ -// This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -// Copyright (c) 2011 Samuel G. D. Williams. -// See for licensing details. - -@mixin pre-wrap { - /* CSS2.1 */ - white-space: pre-wrap; - - /* Mozilla, since 1999 */ - white-space: -moz-pre-wrap; - - /* Opera 7 */ - white-space: -o-pre-wrap; - - /* Internet Explorer 5.5+ */ - word-wrap: break-word; - _white-space: pre; -} diff --git a/themes/base/jquery.syntax.brush.apache.sass b/themes/base/jquery.syntax.brush.apache.sass index 3a565af..bb9cbe6 100644 --- a/themes/base/jquery.syntax.brush.apache.sass +++ b/themes/base/jquery.syntax.brush.apache.sass @@ -12,3 +12,12 @@ .tag-name font-weight: bold + +@media (prefers-color-scheme: dark) + .syntax-theme-base + .apache + .tag + color: lighten(#00c, 30%) + + .tag-name + color: lighten(#00f, 30%) diff --git a/themes/base/jquery.syntax.brush.bash-script.sass b/themes/base/jquery.syntax.brush.bash-script.sass index e21dade..1cc1ae0 100644 --- a/themes/base/jquery.syntax.brush.bash-script.sass +++ b/themes/base/jquery.syntax.brush.bash-script.sass @@ -4,9 +4,6 @@ .syntax-theme-base .bash-script - .function - font-weight: bold - .option color: #03f diff --git a/themes/base/jquery.syntax.brush.bash.sass b/themes/base/jquery.syntax.brush.bash.sass index 4c06604..a0ce116 100644 --- a/themes/base/jquery.syntax.brush.bash.sass +++ b/themes/base/jquery.syntax.brush.bash.sass @@ -4,15 +4,5 @@ .syntax-theme-base .bash - .prompt - color: #0c0 - font-weight: bold - - color: #555 - - .bash-script - font-style: normal - color: black - .stderr color: red \ No newline at end of file diff --git a/themes/base/jquery.syntax.brush.clang.sass b/themes/base/jquery.syntax.brush.clang.sass index 6cf22d8..1af9b92 100644 --- a/themes/base/jquery.syntax.brush.clang.sass +++ b/themes/base/jquery.syntax.brush.clang.sass @@ -5,4 +5,8 @@ .syntax-theme-base .preprocessor color: #63381f - font-style: italic + +@media (prefers-color-scheme: dark) + .syntax-theme-base + .preprocessor + color: lighten(#63381f, 30%) diff --git a/themes/base/jquery.syntax.brush.html.sass b/themes/base/jquery.syntax.brush.html.sass index 829d295..36ab858 100644 --- a/themes/base/jquery.syntax.brush.html.sass +++ b/themes/base/jquery.syntax.brush.html.sass @@ -7,6 +7,3 @@ .doctype font-weight: bold color: #938 - - .javascript, .css - font-style: italic \ No newline at end of file diff --git a/themes/base/jquery.syntax.brush.ruby.sass b/themes/base/jquery.syntax.brush.ruby.sass index 84b8d3b..327b3b5 100644 --- a/themes/base/jquery.syntax.brush.ruby.sass +++ b/themes/base/jquery.syntax.brush.ruby.sass @@ -6,4 +6,4 @@ .syntax-theme-base .ruby .string .ruby - color: #000 \ No newline at end of file + color: #808080 diff --git a/themes/base/jquery.syntax.brush.xml.sass b/themes/base/jquery.syntax.brush.xml.sass index 9b6aa17..3df01f7 100644 --- a/themes/base/jquery.syntax.brush.xml.sass +++ b/themes/base/jquery.syntax.brush.xml.sass @@ -28,3 +28,28 @@ color: #666 background-color: #ddd border-radius: 0.5em + +@media (prefers-color-scheme: dark) + .syntax-theme-base + .xml + .cdata-content + color: #a46 + + .xml-tag, .cdata + color: #c59de7 + + .tag-name, .cdata-tag + color: #9ae + + .namespace + color: #c59de7 + + .attribute + color: #c59de7 + + .instruction + color: #c59de7 + + .entity, .percent-escape + color: #999 + background-color: #333 diff --git a/themes/base/jquery.syntax.core.sass b/themes/base/jquery.syntax.core.sass index f322719..81abfb3 100644 --- a/themes/base/jquery.syntax.core.sass +++ b/themes/base/jquery.syntax.core.sass @@ -6,20 +6,16 @@ pre code.syntax-theme-base display: block > span - display: block - white-space: pre-wrap + display: flex .indent - display: block - float: left - + flex-grow: 0 + flex-shrink: 0 + .text white-space: pre-wrap - display: block - overflow: hidden - - padding-left: 1rem - text-indent: -1rem + padding-left: 2ch + text-indent: -2ch .syntax-theme-base a @@ -29,7 +25,7 @@ pre code.syntax-theme-base .function color: #33f - .keyword, .access + .keyword, .access, .option color: darken(#a90d91, 10%) .type @@ -48,7 +44,7 @@ pre code.syntax-theme-base color: #f99 .operator - color: #000000 + color: black .href color: #0e0eff @@ -60,22 +56,31 @@ pre code.syntax-theme-base .highlight background-color: opacify(#fdfdba, 0.5) - pre - overflow: auto - font-family: inherit - -.syntax-container.syntax-theme-base - position: relative - .toolbar - font-size: 80% - text-align: right - padding: 0 0.2em 0.2em - a - margin-left: 1em - - pre.raw - overflow: auto - padding: 0 0.4em 0 !important - margin: 0 !important - background-color: $background-primary - border: 1px solid $border-primary \ No newline at end of file +@media (prefers-color-scheme: dark) + .syntax-theme-base + .operator + color: white + + .function + color: #c59de7 + + .keyword, .access, .option + color: darken(#98c6ff, 20%) + + .type + color: #37a4ff + + .comment + color: #849fca + + .constant + color: lighten(#9d7c31, 15%) + + .string, .symbol + color: lighten(#e43c3a, 15%) + + .string .escape + color: #f99 + + .variable + color: #6e6dff diff --git a/themes/base/master.sass b/themes/base/master.sass deleted file mode 100644 index 05a7875..0000000 --- a/themes/base/master.sass +++ /dev/null @@ -1,12 +0,0 @@ -// This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License. -// Copyright (c) 2011 Samuel G. D. Williams. -// See for licensing details. - -$background-primary: #f0f0f0 -$border-primary: #aaa -$code-primary: #333 - -// #f9fbfc, #e3eef9 -// $background-primary: #f9fbfc -// $border-primary: #ccf -// $code-primary: #333 \ No newline at end of file