Merge pull request #772 from warpc/762-ui_and_refactoring

[refs #762] ui and refactoring for mass build; fix syntax highlight
This commit is contained in:
Vladimir Sharshov 2012-12-11 14:19:56 -08:00
commit 59c1d75a36
51 changed files with 382 additions and 237 deletions

View File

@ -0,0 +1,29 @@
$(document).ready(function() {
var projects_list = $('.form.mass_build #projects_list');
var repositories = $(".form.mass_build input:checkbox");
repositories.click(function(){
if (this.checked){
$(this).attr('disabled',true);
$.ajax({
type: 'GET',
url: $(this).attr('href'),
success: function(data){
var text = projects_list.val();
if(text.length > 0 && text.slice(-1) != '\n') {text = text + "\n"}
projects_list.val(text+data);
},
error: function(data){
alert('Error :(') // TODO remove
}
});
}
return true;
});
projects_list.keyup(function(){
if($(this).val().length == 0) {
repositories.attr('disabled',false)
.attr('checked', false);
}
});
});

View File

@ -1101,12 +1101,21 @@ div#advisory_search_block div.continue_input {
margin-bottom: 20px;
}
form.mass_build section.left {
margin-left: 50px;
}
form.mass_build {
section.left {
margin-left: 10px;
width: 350px;
}
form.mass_build section.right {
margin-right: 50px;
section.right {
margin-right: 50px;
}
input[type="submit"] {
margin: 10px 0 10px 0;
}
#projects_list {
min-width:315px;
}
}
.toggle {

View File

@ -10,8 +10,7 @@ class Platforms::MassBuildsController < Platforms::BaseController
skip_authorize_resource :platform, :only => [:create, :index]
def create
mass_build = @platform.mass_builds.new(:repositories => params[:repositories],
:arches => params[:arches],
mass_build = @platform.mass_builds.new(:arches => params[:arches],
:auto_publish => params[:auto_publish] || false,
:projects_list => params[:projects_list])
mass_build.user = current_user

View File

@ -97,6 +97,7 @@ class Platforms::RepositoriesController < Platforms::BaseController
end
def projects_list
render(:text => @repository.projects.map(&:name).join("\n")) && return if params[:text] == 'true'
owner_subquery = "
INNER JOIN (

View File

@ -6,11 +6,10 @@ class MassBuild < ActiveRecord::Base
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
attr_accessor :repositories, :arches
attr_accessible :repositories, :arches, :auto_publish, :projects_list
attr_accessor :arches
attr_accessible :arches, :auto_publish, :projects_list
validates :platform_id, :arch_names, :name, :user_id, :presence => true
validate :rep_names, :repositories, :presence => true, :if => Proc.new {|mb| mb.projects_list.blank?}
validates :platform_id, :arch_names, :name, :user_id, :projects_list, :presence => true
validates_inclusion_of :auto_publish, :in => [true, false]
after_create :build_all
@ -25,26 +24,33 @@ class MassBuild < ActiveRecord::Base
:build_error
]
# ATTENTION: repositories and arches must be set before calling this method!
def build_all
# later with resque
if projects_list.present?
platform.build_from_list(
:mass_build_id => self.id,
:user => self.user,
:arches => self.arches,
:auto_publish => self.auto_publish
)
else
platform.build_all(
:mass_build_id => self.id,
:user => self.user,
:repositories => self.repositories,
:arches => self.arches,
:auto_publish => self.auto_publish
)
arches_list = arches ? Arch.where(:id => arches) : Arch.all
auto_publish ||= false
projects_list.lines.each do |name|
next if name.blank?
name.chomp!; name.strip!
if project = Project.joins(:repositories).where('repositories.id in (?)', platform.repository_ids).find_by_name(name)
begin
return if self.reload.stop_build
arches_list.each do |arch|
rep = (project.repositories & platform.repositories).first
project.build_for(platform, rep.id, user, arch, auto_publish, self.id)
end
rescue RuntimeError, Exception
end
else
MassBuild.increment_counter :missed_projects_count, id
list = (missed_projects_list || '') << "#{name}\n"
update_column :missed_projects_list, list
end
sleep 1
end
end
later :build_all, :loner => true, :queue => :clone_build
def generate_failed_builds_list
report = ""
@ -67,10 +73,8 @@ class MassBuild < ActiveRecord::Base
def set_data
if new_record?
self.rep_names = Repository.where(:id => self.repositories).map(&:name).join(", ")
self.name = "#{Time.now.utc.to_date.strftime("%d.%b")}-#{platform.name}"
self.arch_names = Arch.where(:id => self.arches).map(&:name).join(", ")
end
end
end

View File

@ -178,66 +178,6 @@ class Platform < ActiveRecord::Base
end
end
def build_all(opts={})
# Set options to build all need
repositories = opts[:repositories] ? self.repositories.where(:id => opts[:repositories]) : self.repositories
arches = opts[:arches] ? Arch.where(:id => opts[:arches]) : Arch.all
auto_publish = opts[:auto_publish] || false
user = opts[:user]
mass_build_id = opts[:mass_build_id]
mass_build = MassBuild.find mass_build_id
repositories.each do |rep|
rep.projects.find_in_batches(:batch_size => 2) do |group|
sleep 1
group.each do |p|
arches.map(&:name).each do |arch|
begin
return if mass_build.reload.stop_build
p.build_for(self, rep.id, user, arch, auto_publish, mass_build_id)
rescue RuntimeError, Exception
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
end
end
end
end
end
end
later :build_all, :loner => true, :queue => :clone_build
def build_from_list(opts={})
mass_build = MassBuild.find opts[:mass_build_id]
arches = opts[:arches] ? Arch.where(:id => opts[:arches]) : Arch.all
auto_publish = opts[:auto_publish] || false
user = opts[:user]
mass_build.projects_list.lines.each do |name|
name.chomp!; name.strip!
project = ""
Project.where(:name => name).each do |pr|
project = pr if (pr.repository_ids & self.repository_ids).present?
end
if project
begin
return if mass_build.reload.stop_build
arches.map(&:name).each do |arch|
rep = (project.repositories & self.repositories).first
project.build_for(self, rep.id, user, arch, auto_publish, mass_build.id)
end
rescue RuntimeError, Exception
end
else
MassBuild.increment_counter :missed_projects_count, mass_build.id
list = (mass_build.missed_projects_list || '') << "#{name}\n"
mass_build.update_column :missed_projects_list, list
end
sleep 1
end
end
later :build_from_list, :loner => true, :queue => :clone_build
def destroy
with_skip {super} # avoid cascade XML RPC requests
end

View File

@ -124,14 +124,13 @@ class Project < ActiveRecord::Base
#path #share by NFS
end
def build_for(platform, repository_id, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0)
def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0)
# Select main and project platform repository(contrib, non-free and etc)
# If main does not exist, will connect only project platform repository
# If project platform repository is main, only main will be connect
main_rep_id = platform.repositories.find_by_name('main').try(:id)
build_reps_ids = [main_rep_id, repository_id].compact.uniq
arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
build_lists.create do |bl|
bl.save_to_platform = platform
bl.build_for_platform = platform

View File

@ -0,0 +1,8 @@
%h3=t("layout.mass_builds.repositories")
-@platform.repositories.each do |rep|
.both
=check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), :id => "repositories_#{rep.id}", :href => "#{projects_list_platform_repository_path(@platform, rep)}?text=true"
=label_tag "repositories_#{rep.id}", rep.name
%h3=t("layout.mass_builds.projects_list")
=text_area_tag :projects_list, nil

View File

@ -3,13 +3,7 @@
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
%section.left
%h3= t("layout.mass_builds.repositories")
- @platform.repositories.each do |rep|
.both
= check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), :id => "repositories_#{rep.id}"
= label_tag "repositories_#{rep.id}", rep.name
%h3= t("layout.mass_builds.projects_list")
= text_area_tag :projects_list, nil
=render 'repos_or_list_choice'
%br
= f.submit t("layout.projects.build_button")
%section.right

View File

@ -13,7 +13,8 @@ Mime::Type.register "text/plain", 'patch'
["text/x-rpm-spec", ['spec'], '8bit'],
["text/x-csrc", ['h', 'c'], '8bit'],
["text/x-c++src", ['cpp'], '8bit'],
["text/x-diff", ['diff'], '8bit']
["text/x-diff", ['diff'], '8bit'],
["text/x-markdown", ['md'], '8bit']
].each do |type|
MIME::Types.add MIME::Type.from_array(type)
end

View File

@ -22,4 +22,3 @@ en:
user: User
auto_publish: Auto Publish
repositories: Repositories
rep_names: Repositories

View File

@ -22,4 +22,3 @@ ru:
user: Пользователь
auto_publish: Авто Публикация
repositories: Репозитории
rep_names: Репозитории

View File

@ -0,0 +1,5 @@
class RemoveRepNamesFromMassBuild < ActiveRecord::Migration
def change
remove_column :mass_builds, :rep_names
end
end

View File

@ -0,0 +1,6 @@
class AddIndexes < ActiveRecord::Migration
def change
add_index :project_to_repositories, [:repository_id, :project_id], :unique => true
add_index :repositories, :platform_id
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121206143724) do
ActiveRecord::Schema.define(:version => 20121211132948) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -250,7 +250,6 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.integer "build_started_count", :default => 0, :null => false
t.integer "build_publish_count", :default => 0, :null => false
t.integer "build_error_count", :default => 0, :null => false
t.string "rep_names"
t.boolean "stop_build", :default => false, :null => false
t.text "projects_list"
t.integer "missed_projects_count", :default => 0, :null => false
@ -330,6 +329,8 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.datetime "updated_at", :null => false
end
add_index "project_to_repositories", ["repository_id", "project_id"], :name => "index_project_to_repositories_on_repository_id_and_project_id", :unique => true
create_table "projects", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
@ -403,6 +404,8 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.boolean "publish_without_qa", :default => true
end
add_index "repositories", ["platform_id"], :name => "index_repositories_on_platform_id"
create_table "settings_notifiers", :force => true do |t|
t.integer "user_id", :null => false
t.boolean "can_notify", :default => true

View File

@ -37,7 +37,7 @@ shared_examples_for 'mass_build platform owner' do
Platform.update_all("platform_type = 'personal'")
end
[:cancel, :failed_builds_list, :create].each do |action|
[:cancel, :get_list, :create].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform, :id => @mass_build.id
response.should redirect_to(forbidden_path)
@ -54,7 +54,7 @@ shared_examples_for 'mass_build platform reader' do
end
end
[:cancel, :failed_builds_list].each do |action|
[:cancel, :get_list].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform, :id => @mass_build.id
response.should redirect_to(forbidden_path)
@ -81,14 +81,17 @@ describe Platforms::MassBuildsController do
@repository = FactoryGirl.create(:repository, :platform => @platform)
@personal_platform = FactoryGirl.create(:platform, :platform_type => 'personal')
@user = FactoryGirl.create(:user)
project = FactoryGirl.create(:project, :owner => @user)
@repository.projects << project
@create_params = {
:platform_id => @platform,
:repositories => [@platform.repositories.first.id],
:projects_list => @repository.projects.map(&:name).join("\n"),
:arches => [Arch.first.id],
:auto_publish => true
}
@mass_build = FactoryGirl.create(:mass_build, :platform => @platform, :user => @user)
@mass_build = FactoryGirl.create(:mass_build, :platform => @platform, :user => @user, :projects_list => project.name)
end
context 'for guest' do
@ -99,8 +102,8 @@ describe Platforms::MassBuildsController do
end
end
it "should not be able to perform failed_builds_list action" do
get :failed_builds_list, :platform_id => @platform, :id => @mass_build
it "should not be able to get failed builds list" do
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
response.should redirect_to(new_user_session_path)
end
@ -161,4 +164,3 @@ describe Platforms::MassBuildsController do
it_should_behave_like 'mass_build platform reader'
end
end

View File

@ -4,7 +4,7 @@ FactoryGirl.define do
association :platform
#name FactoryGirl.generate(:name)
association :user
repositories { |mb| [ mb.platform.repositories.first.id ] }
projects_list "first"
arches { [ Arch.first.id ] }
auto_publish true
stop_build false

View File

@ -176,14 +176,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
return "string";
}
CodeMirror.defineMIME("text/x-csrc", {
CodeMirror.defineMIME("application/x-csrc", {
name: "clike",
keywords: words(cKeywords),
blockKeywords: words("case do else for if switch while struct"),
atoms: words("null"),
hooks: {"#": cppHook}
});
CodeMirror.defineMIME("text/x-c++src", {
CodeMirror.defineMIME("application/x-c++src", {
name: "clike",
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
"static_cast typeid catch operator template typename class friend private " +
@ -193,7 +193,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
atoms: words("true false null"),
hooks: {"#": cppHook}
});
CodeMirror.defineMIME("text/x-java", {
CodeMirror.defineMIME("application/x-java", {
name: "clike",
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
"do double else enum extends final finally float for goto if implements import " +
@ -209,7 +209,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
}
}
});
CodeMirror.defineMIME("text/x-csharp", {
CodeMirror.defineMIME("application/x-csharp", {
name: "clike",
keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
" default delegate do double else enum event explicit extern finally fixed float for" +

View File

@ -205,3 +205,4 @@ CodeMirror.defineMode("clojure", function (config, mode) {
});
CodeMirror.defineMIME("text/x-clojure", "clojure");
CodeMirror.defineMIME("application/x-clojure", "clojure");

View File

@ -339,3 +339,4 @@ CodeMirror.defineMode('coffeescript', function(conf) {
});
CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript');
CodeMirror.defineMIME('application/x-coffeescript', 'coffeescript');

View File

@ -122,3 +122,4 @@ CodeMirror.defineMode("css", function(config) {
});
CodeMirror.defineMIME("text/css", "css");
CodeMirror.defineMIME('application/x-coffeescript', 'css');

View File

@ -11,3 +11,4 @@ CodeMirror.defineMode("diff", function() {
});
CodeMirror.defineMIME("text/x-diff", "diff");
CodeMirror.defineMIME("application/x-diff", "diff");

View File

@ -170,3 +170,4 @@ CodeMirror.defineMode("go", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-go", "go");
CodeMirror.defineMIME("application/x-go", "go");

View File

@ -208,3 +208,4 @@ CodeMirror.defineMode("groovy", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-groovy", "groovy");
CodeMirror.defineMIME("application/x-groovy", "groovy");

View File

@ -4,7 +4,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
setState(f);
return f(source, setState);
}
// These should all be Unicode extended, as per the Haskell 2010 report
var smallRE = /[a-z_]/;
var largeRE = /[A-Z]/;
@ -15,12 +15,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
var specialRE = /[(),;[\]`{}]/;
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
function normal(source, setState) {
if (source.eatWhile(whiteCharRE)) {
return null;
}
var ch = source.next();
if (specialRE.test(ch)) {
if (ch == '{' && source.eat('-')) {
@ -32,7 +32,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
}
return null;
}
if (ch == '\'') {
if (source.eat('\\')) {
source.next(); // should handle other escapes here
@ -45,11 +45,11 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
}
return "error";
}
if (ch == '"') {
return switchState(source, setState, stringLiteral);
}
if (largeRE.test(ch)) {
source.eatWhile(idRE);
if (source.eat('.')) {
@ -57,12 +57,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
}
return "variable-2";
}
if (smallRE.test(ch)) {
source.eatWhile(idRE);
return "variable";
}
if (digitRE.test(ch)) {
if (ch == '0') {
if (source.eat(/[xX]/)) {
@ -87,7 +87,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
}
return t;
}
if (symbolRE.test(ch)) {
if (ch == '-' && source.eat(/-/)) {
source.eatWhile(/-/);
@ -101,12 +101,12 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
t = "variable-2";
}
source.eatWhile(symbolRE);
return t;
return t;
}
return "error";
}
function ncomment(type, nest) {
if (nest == 0) {
return normal;
@ -130,7 +130,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
return type;
}
}
function stringLiteral(source, setState) {
while (!source.eol()) {
var ch = source.next();
@ -153,7 +153,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
setState(normal);
return "error";
}
function stringGap(source, setState) {
if (source.eat('\\')) {
return switchState(source, setState, stringLiteral);
@ -162,8 +162,8 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
setState(normal);
return "error";
}
var wellKnownWords = (function() {
var wkw = {};
function setType(t) {
@ -172,19 +172,19 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
wkw[arguments[i]] = t;
}
}
setType("keyword")(
"case", "class", "data", "default", "deriving", "do", "else", "foreign",
"if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
"module", "newtype", "of", "then", "type", "where", "_");
setType("keyword")(
"\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
setType("builtin")(
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
setType("builtin")(
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
@ -192,7 +192,7 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
"Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
"ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
"String", "True");
setType("builtin")(
"abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
"asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
@ -220,16 +220,16 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
"toRational", "truncate", "uncurry", "undefined", "unlines", "until",
"unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
"zip3", "zipWith", "zipWith3");
return wkw;
})();
return {
startState: function () { return { f: normal }; },
copyState: function (s) { return { f: s.f }; },
token: function(stream, state) {
var t = state.f(stream, function(s) { state.f = s; });
var w = stream.current();
@ -240,3 +240,4 @@ CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
});
CodeMirror.defineMIME("text/x-haskell", "haskell");
CodeMirror.defineMIME("application/x-haskell", "haskell");

View File

@ -81,3 +81,4 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/html", "htmlmixed");
CodeMirror.defineMIME("application/html", "htmlmixed");

View File

@ -53,7 +53,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
else if (ch == "0" && stream.eat(/x/i)) {
stream.eatWhile(/[\da-f]/i);
return ret("number", "number");
}
}
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
return ret("number", "number");
@ -135,7 +135,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
// Communicate our context to the combinators.
// (Less wasteful than consing up a hundred closures on every call.)
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
if (!state.lexical.hasOwnProperty("align"))
state.lexical.align = true;
@ -240,7 +240,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type.match(/[;\}\)\],]/)) return pass();
return pass(expression);
}
function maybeoperator(type, value) {
if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
if (type == "operator") return cont(expression);
@ -357,4 +357,5 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("application/javascript", "javascript");
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});

View File

@ -1,7 +1,7 @@
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
// CodeMirror 1 mode.
// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
CodeMirror.defineMode("lua", function(config, parserConfig) {
var indentUnit = config.indentUnit;
@ -12,7 +12,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
return new RegExp("^(?:" + words.join("|") + ")$", "i");
}
var specials = wordRE(parserConfig.specials || []);
// long list of standard functions from lua manual
var builtins = wordRE([
"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load",
@ -47,7 +47,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
"table.concat","table.insert","table.maxn","table.remove","table.sort"
]);
var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
"true","function", "end", "if", "then", "else", "do",
"true","function", "end", "if", "then", "else", "do",
"while", "repeat", "until", "for", "in", "local" ]);
var indentTokens = wordRE(["function", "if","repeat","do", "\\(", "{"]);
@ -68,7 +68,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state);
stream.skipToEnd();
return "comment";
}
}
if (ch == "\"" || ch == "'")
return (state.cur = string(ch))(stream, state);
if (ch == "[" && /[\[=]/.test(stream.peek()))
@ -108,7 +108,7 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
return "string";
};
}
return {
startState: function(basecol) {
return {basecol: basecol || 0, indentDepth: 0, cur: normal};
@ -138,3 +138,4 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-lua", "lua");
CodeMirror.defineMIME("application/x-lua", "lua");

View File

@ -38,11 +38,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
stream.skipToEnd();
return code;
}
if (stream.eatSpace()) {
return null;
}
if (stream.peek() === '#' || stream.match(headerRE)) {
stream.skipToEnd();
return header;
@ -60,13 +60,13 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return hr;
}
}
var match;
if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
state.indentation += match[0].length;
return list;
}
return switchInline(stream, state, state.inline);
}
@ -90,16 +90,16 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (stream.match(textRE, true)) {
return getType(state);
}
return undefined;
return undefined;
}
function inlineNormal(stream, state) {
var style = state.text(stream, state)
if (typeof style !== 'undefined')
return style;
var ch = stream.next();
if (ch === '\\') {
stream.next();
return getType(state);
@ -122,7 +122,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
return (state.em = !state.em) ? getType(state) : t;
}
return getType(state);
}
@ -184,11 +184,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
startState: function() {
return {
f: blockNormal,
block: blockNormal,
htmlState: htmlMode.startState(),
indentation: 0,
inline: inlineNormal,
text: handleText,
em: false,
@ -199,11 +199,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
copyState: function(s) {
return {
f: s.f,
block: s.block,
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
indentation: s.indentation,
inline: s.inline,
text: s.text,
em: s.em,
@ -228,7 +228,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
}
state.indentation = currentIndentation;
if (currentIndentation > 0) return null;
}
return state.f(stream, state);
@ -240,3 +240,4 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
});
CodeMirror.defineMIME("text/x-markdown", "markdown");
CodeMirror.defineMIME("application/x-markdown", "markdown");

View File

@ -186,3 +186,4 @@ CodeMirror.defineMode("mysql", function(config) {
});
CodeMirror.defineMIME("text/x-mysql", "mysql");
CodeMirror.defineMIME("application/x-mysql", "mysql");

View File

@ -136,3 +136,4 @@ CodeMirror.defineMode("pascal", function(config) {
});
CodeMirror.defineMIME("text/x-pascal", "pascal");
CodeMirror.defineMIME("application/x-pascal", "pascal");

View File

@ -778,6 +778,7 @@ CodeMirror.defineMode("perl",function(config,parserConfig){
electricChars:"{}"}});
CodeMirror.defineMIME("text/x-perl", "perl");
CodeMirror.defineMIME("application/x-perl", "perl");
// it's like "peek", but need for look-ahead or look-behind if index < 0
CodeMirror.StringStream.prototype.look=function(c){

View File

@ -118,4 +118,5 @@
CodeMirror.defineMIME("application/x-httpd-php", "php");
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
CodeMirror.defineMIME("text/x-php", phpConfig);
CodeMirror.defineMIME("application/x-php", phpConfig);
})();

View File

@ -207,7 +207,7 @@ CodeMirror.defineMode("plsql", function(config, parserConfig) {
"verify version " +
"wrap";
CodeMirror.defineMIME("text/x-plsql", {
CodeMirror.defineMIME("application/x-plsql", {
name: "plsql",
keywords: keywords(cKeywords),
functions: keywords(cFunctions),

View File

@ -1,10 +1,10 @@
CodeMirror.defineMode("python", function(conf, parserConf) {
var ERRORCLASS = 'error';
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
}
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
@ -72,15 +72,15 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
if (stream.eatSpace()) {
return null;
}
var ch = stream.peek();
// Handle Comments
if (ch === '#') {
stream.skipToEnd();
return 'comment';
}
// Handle Number Literals
if (stream.match(/^[0-9\.]/, false)) {
var floatLiteral = false;
@ -116,13 +116,13 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return 'number';
}
}
// Handle Strings
if (stream.match(stringPrefixes)) {
state.tokenize = tokenStringFactory(stream.current());
return state.tokenize(stream, state);
}
// Handle operators and Delimiters
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
return null;
@ -135,31 +135,31 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
if (stream.match(singleDelimiters)) {
return null;
}
if (stream.match(keywords)) {
return 'keyword';
}
if (stream.match(builtins)) {
return 'builtin';
}
if (stream.match(identifiers)) {
return 'variable';
}
// Handle non-detected items
stream.next();
return ERRORCLASS;
}
function tokenStringFactory(delimiter) {
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
delimiter = delimiter.substr(1);
}
var singleline = delimiter.length == 1;
var OUTCLASS = 'string';
return function tokenString(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^'"\\]/);
@ -185,7 +185,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return OUTCLASS;
};
}
function indent(stream, state, type) {
type = type || 'py';
var indentUnit = 0;
@ -208,7 +208,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
type: type
});
}
function dedent(stream, state, type) {
type = type || 'py';
if (state.scopes.length == 1) return;
@ -257,7 +257,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return ERRORCLASS;
}
}
// Handle decorators
if (current === '@') {
style = state.tokenize(stream, state);
@ -270,7 +270,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return ERRORCLASS;
}
}
// Handle scope changes.
if (current === 'pass' || current === 'return') {
state.dedent += 1;
@ -298,7 +298,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
if (state.scopes.length > 1) state.scopes.shift();
state.dedent -= 1;
}
return style;
}
@ -312,29 +312,30 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
dedent: 0
};
},
token: function(stream, state) {
var style = tokenLexer(stream, state);
state.lastToken = {style:style, content: stream.current()};
if (stream.eol() && stream.lambda) {
state.lambda = false;
}
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase) {
return 0;
}
return state.scopes[0].offset;
}
};
return external;
});
CodeMirror.defineMIME("text/x-python", "python");
CodeMirror.defineMIME("application/x-python", "python");

View File

@ -139,3 +139,4 @@ CodeMirror.defineMode("r", function(config) {
});
CodeMirror.defineMIME("text/x-rsrc", "r");
CodeMirror.defineMIME("application/x-rsrc", "r");

View File

@ -17,3 +17,4 @@ CodeMirror.defineMode("changes", function(config, modeConfig) {
});
CodeMirror.defineMIME("text/x-rpm-changes", "changes");
CodeMirror.defineMIME("application/x-rpm-changes", "changes");

View File

@ -64,3 +64,4 @@ CodeMirror.defineMode("spec", function(config, modeConfig) {
});
CodeMirror.defineMIME("text/x-rpm-spec", "spec");
CodeMirror.defineMIME("application/x-rpm-spec", "spec");

View File

@ -324,3 +324,4 @@ CodeMirror.defineMode('rst', function(config, options) {
});
CodeMirror.defineMIME("text/x-rst", "rst");
CodeMirror.defineMIME("application/x-rst", "rst");

View File

@ -197,4 +197,5 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-ruby", "ruby");
CodeMirror.defineMIME("application/x-ruby", "ruby");

View File

@ -430,3 +430,4 @@ CodeMirror.defineMode("rust", function() {
});
CodeMirror.defineMIME("text/x-rustsrc", "rust");
CodeMirror.defineMIME("application/x-rustsrc", "rust");

View File

@ -5,7 +5,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD="keyword";
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
function makeKeywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
@ -14,7 +14,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
var keywords = makeKeywords("λ case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
var indentKeys = makeKeywords("define let letrec let* lambda");
function stateStack(indent, type, prev) { // represents a state stack object
this.indent = indent;
@ -29,14 +29,14 @@ CodeMirror.defineMode("scheme", function (config, mode) {
function popStack(state) {
state.indentStack = state.indentStack.prev;
}
/**
* Scheme numbers are complicated unfortunately.
* Checks if we're looking at a number, which might be possibly a fraction.
* Also checks that it is not part of a longer identifier. Returns true/false accordingly.
*/
function isNumber(ch, stream){
if(/[0-9]/.exec(ch) != null){
function isNumber(ch, stream){
if(/[0-9]/.exec(ch) != null){
stream.eatWhile(/[0-9]/);
stream.eat(/\//);
stream.eatWhile(/[0-9]/);
@ -67,13 +67,13 @@ CodeMirror.defineMode("scheme", function (config, mode) {
return null;
}
var returnType = null;
switch(state.mode){
case "string": // multi-line string parsing mode
var next, escaped = false;
while ((next = stream.next()) != null) {
if (next == "\"" && !escaped) {
state.mode = false;
break;
}
@ -85,7 +85,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
var next, maybeEnd = false;
while ((next = stream.next()) != null) {
if (next == "#" && maybeEnd) {
state.mode = false;
break;
}
@ -106,11 +106,11 @@ CodeMirror.defineMode("scheme", function (config, mode) {
}
default: // default parsing mode
var ch = stream.next();
if (ch == "\"") {
state.mode = "string";
returnType = STRING;
} else if (ch == "'") {
returnType = ATOM;
} else if (ch == '#') {
@ -123,16 +123,16 @@ CodeMirror.defineMode("scheme", function (config, mode) {
state.mode = "s-expr-comment";
returnType = COMMENT;
}
} else if (ch == ";") { // comment
stream.skipToEnd(); // rest of the line is a comment
returnType = COMMENT;
} else if (ch == "-"){
if(!isNaN(parseInt(stream.peek()))){
stream.eatWhile(/[\/0-9]/);
returnType = NUMBER;
}else{
}else{
returnType = null;
}
} else if (isNumber(ch,stream)){
@ -140,18 +140,18 @@ CodeMirror.defineMode("scheme", function (config, mode) {
} else if (ch == "(" || ch == "[") {
var keyWord = ''; var indentTemp = stream.column();
/**
Either
Either
(indent-word ..
(non-indent-word ..
(;something else, bracket, etc.
*/
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
keyWord += letter;
}
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
} else { // non-indent word
// we continue eating the spaces
@ -165,15 +165,15 @@ CodeMirror.defineMode("scheme", function (config, mode) {
}
}
stream.backUp(stream.current().length - 1); // undo all the eating
if(typeof state.sExprComment == "number") state.sExprComment++;
returnType = BRACKET;
} else if (ch == ")" || ch == "]") {
returnType = BRACKET;
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
popStack(state);
if(typeof state.sExprComment == "number"){
if(--state.sExprComment == 0){
returnType = COMMENT; // final closing bracket
@ -183,7 +183,7 @@ CodeMirror.defineMode("scheme", function (config, mode) {
}
} else {
stream.eatWhile(/[\w\$_\-]/);
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
returnType = BUILTIN;
}else returnType = null;
@ -199,4 +199,5 @@ CodeMirror.defineMode("scheme", function (config, mode) {
};
});
CodeMirror.defineMIME("text/x-scheme", "scheme");
CodeMirror.defineMIME("text/x-scheme", "scheme");
CodeMirror.defineMIME("application/x-scheme", "scheme");

View File

@ -0,0 +1,119 @@
CodeMirror.defineMode('shell', function(config) {
var words = {};
function define(style, string) {
var split = string.split(' ');
for(var i = 0; i < split.length; i++) {
words[split[i]] = style;
}
};
// Atoms
define('atom', 'true false');
// Keywords
define('keyword', 'if then do else elif while until for in esac fi fin ' +
'fil done exit set unset export function');
// Commands
define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' +
'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' +
'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' +
'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' +
'touch vi vim wall wc wget who write yes zsh');
function tokenBase(stream, state) {
var sol = stream.sol();
var ch = stream.next();
if (ch === '\'' || ch === '"' || ch === '`') {
state.tokens.unshift(tokenString(ch));
return tokenize(stream, state);
}
if (ch === '#') {
if (sol && stream.eat('!')) {
stream.skipToEnd();
return 'meta'; // 'comment'?
}
stream.skipToEnd();
return 'comment';
}
if (ch === '$') {
state.tokens.unshift(tokenDollar);
return tokenize(stream, state);
}
if (ch === '+' || ch === '=') {
return 'operator';
}
if (ch === '-') {
stream.eat('-');
stream.eatWhile(/\w/);
return 'attribute';
}
if (/\d/.test(ch)) {
stream.eatWhile(/\d/);
if(!/\w/.test(stream.peek())) {
return 'number';
}
}
stream.eatWhile(/\w/);
var cur = stream.current();
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
return words.hasOwnProperty(cur) ? words[cur] : null;
}
function tokenString(quote) {
return function(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
if (next === quote && !escaped) {
end = true;
break;
}
if (next === '$' && !escaped && quote !== '\'') {
escaped = true;
stream.backUp(1);
state.tokens.unshift(tokenDollar);
break;
}
escaped = !escaped && next === '\\';
}
if (end || !escaped) {
state.tokens.shift();
}
return (quote === '`' || quote === ')' ? 'quote' : 'string');
};
};
var tokenDollar = function(stream, state) {
if (state.tokens.length > 1) stream.eat('$');
var ch = stream.next(), hungry = /\w/;
if (ch === '{') hungry = /[^}]/;
if (ch === '(') {
state.tokens[0] = tokenString(')');
return tokenize(stream, state);
}
if (!/\d/.test(ch)) {
stream.eatWhile(hungry);
stream.eat('}');
}
state.tokens.shift();
return 'def';
};
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase) (stream, state);
};
return {
startState: function() {return {tokens:[]};},
token: function(stream, state) {
if (stream.eatSpace()) return null;
return tokenize(stream, state);
}
};
});
CodeMirror.defineMIME('text/x-sh', 'shell');
CodeMirror.defineMIME('application/x-sh', 'shell');

View File

@ -136,4 +136,5 @@ CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
});
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});
CodeMirror.defineMIME('application/x-stsrc', {name: 'smalltalk'});

View File

@ -3,13 +3,13 @@
* Licence: MIT
*/
CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
{
CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
{
function pushCommand(state, command) {
state.cmdState.push(command);
}
function peekCommand(state) {
function peekCommand(state) {
if (state.cmdState.length>0)
return state.cmdState[state.cmdState.length-1];
else
@ -20,7 +20,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
if (state.cmdState.length>0) {
var plug = state.cmdState.pop();
plug.closeBracket();
}
}
}
function applyMostPowerful(state) {
@ -58,7 +58,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
}
var plugins = new Array();
plugins["importmodule"] = addPluginPattern("importmodule", "tag", "{[", ["string", "builtin"]);
plugins["documentclass"] = addPluginPattern("documentclass", "tag", "{[", ["", "atom"]);
plugins["usepackage"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
@ -99,7 +99,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
if (ch == "%") {
setState(state, inCComment);
return "comment";
}
}
else if (ch=='}' || ch==']') {
plug = peekCommand(state);
if (plug) {
@ -109,10 +109,10 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
return "error";
return "bracket";
} else if (ch=='{' || ch=='[') {
plug = plugins["DEFAULT"];
plug = plugins["DEFAULT"];
plug = new plug();
pushCommand(state, plug);
return "bracket";
return "bracket";
}
else if (/\d/.test(ch)) {
source.eatWhile(/[\w.%]/);
@ -154,7 +154,7 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
return {
startState: function() { return { f:normal, cmdState:[] }; },
copyState: function(s) { return { f: s.f, cmdState: s.cmdState.slice(0, s.cmdState.length) }; },
token: function(stream, state) {
var t = state.f(stream, state);
var w = stream.current();
@ -165,3 +165,4 @@ CodeMirror.defineMode("stex", function(cmCfg, modeCfg)
CodeMirror.defineMIME("text/x-stex", "stex");
CodeMirror.defineMIME("application/x-stex", "stex");

View File

@ -90,14 +90,14 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
}
function jsTokenBase(stream, state) {
var sol = stream.sol(),
var sol = stream.sol(),
ch, tch;
state.block = false; // indicates the start of a code block.
ch = stream.peek(); // don't eat, to make match simpler
// check start of blocks
// check start of blocks
if (sol && /[<\/\*{}\-]/.test(ch)) {
if (stream.match(reCodeBlockStart)) {
state.block = true;
@ -180,7 +180,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
if (stream.eat("%")) {
return chain(stream, state, twTokenComment);
}
else if (stream.eat("/")) { //
else if (stream.eat("/")) { //
return chain(stream, state, twTokenEm);
}
}
@ -254,7 +254,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
// tw code
function twTokenCode(stream, state) {
var ch, sb = state.block;
if (sb && stream.current()) {
return ret("code", "code");
}
@ -301,12 +301,12 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
return ret("text", "underlined");
}
// tw strike through text looks ugly
// tw strike through text looks ugly
// TODO just strike through the first and last 2 chars if possible.
function twTokenStrike(stream, state) {
var maybeEnd = false,
ch, nr;
while (ch = stream.next()) {
if (ch == "-" && maybeEnd) {
state.tokenize = jsTokenBase;
@ -371,4 +371,5 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
});
CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
CodeMirror.defineMIME("application/x-tiddlywiki", "tiddlywiki");
//}}}

View File

@ -144,3 +144,4 @@ CodeMirror.defineMode("velocity", function(config) {
});
CodeMirror.defineMIME("text/velocity", "velocity");
CodeMirror.defineMIME("application/velocity", "velocity");

View File

@ -184,7 +184,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
return "string";
}
CodeMirror.defineMIME("text/x-verilog", {
CodeMirror.defineMIME("application/x-verilog", {
name: "verilog",
keywords: words(verilogKeywords),
blockKeywords: words(verilogBlockKeywords),

View File

@ -50,7 +50,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
var ok;
if (stream.eat("#")) {
if (stream.eat("x")) {
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
} else {
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
}
@ -256,5 +256,6 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
};
});
CodeMirror.defineMIME("application/xml", "xml");
//CodeMirror.defineMIME("application/xml", "xml");
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
CodeMirror.defineMIME("application/html", {name: "xml", htmlMode: true});

View File

@ -1,8 +1,8 @@
CodeMirror.defineMode("yaml", function() {
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
return {
token: function(stream, state) {
var ch = stream.peek();
@ -31,7 +31,7 @@ CodeMirror.defineMode("yaml", function() {
return "atom";
}
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
/* inline pairs/lists */
if (stream.match(/^(\{|\}|\[|\])/)) {
if (ch == '{')
@ -44,7 +44,7 @@ CodeMirror.defineMode("yaml", function() {
state.inlineList--;
return 'meta';
}
/* list seperator */
if (state.inlineList > 0 && !esc && ch == ',') {
stream.next();
@ -58,7 +58,7 @@ CodeMirror.defineMode("yaml", function() {
stream.next();
return 'meta';
}
/* start of value of a pair */
if (state.pairStart) {
/* block literals */
@ -93,3 +93,4 @@ CodeMirror.defineMode("yaml", function() {
});
CodeMirror.defineMIME("text/x-yaml", "yaml");
CodeMirror.defineMIME("application/x-yaml", "yaml");

View File

@ -815,4 +815,3 @@ a.badge:hover {
.badge-inverse[href] {
background-color: #1a1a1a;
}