mirror of https://github.com/CesiumGS/cesium.git
Update Codemirror + JSHint to support ES6+ syntax
This commit is contained in:
parent
47b0fb9f1f
commit
bcafd892fc
|
|
@ -21,7 +21,6 @@
|
|||
"boss": false,
|
||||
"debug": false,
|
||||
"eqnull": false,
|
||||
"esnext": false,
|
||||
"moz": false,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"extends": "../.jshintrc",
|
||||
"unused": false,
|
||||
"esversion": 10,
|
||||
"predef": [
|
||||
"JSON",
|
||||
"require",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ require({
|
|||
location: '../Apps/Sandcastle'
|
||||
}, {
|
||||
name: 'CodeMirror',
|
||||
location: '../ThirdParty/codemirror-4.6'
|
||||
location: '../ThirdParty/codemirror-5.52.0'
|
||||
}, {
|
||||
name: 'ThirdParty',
|
||||
location: '../Apps/Sandcastle/ThirdParty'
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||||
<title>Cesium Sandcastle</title>
|
||||
<link rel="stylesheet" href="../../ThirdParty/codemirror-4.6/lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../ThirdParty/codemirror-5.52.0/lib/codemirror.css">
|
||||
<link rel="stylesheet" href="CesiumSandcastle.css">
|
||||
<script>
|
||||
if (window.location.protocol === 'file:') {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
}
|
||||
</script>
|
||||
<script src="../../ThirdParty/jshint-2.1.10/jshint.js"></script>
|
||||
<script src="../../ThirdParty/jshint-2.11.0/jshint.js"></script>
|
||||
|
||||
<script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../ThirdParty/dojo-release-1.10.4/dojo/dojo.js"></script>
|
||||
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
<script type="text/javascript" src="Sandcastle-helpers.js"></script>
|
||||
<script src="CesiumSandcastle.js"></script>
|
||||
<!-- Needed for autocomplete -->
|
||||
<link rel="stylesheet" href="../../ThirdParty/codemirror-4.6/addon/hint/show-hint.css">
|
||||
<link rel="stylesheet" href="../../ThirdParty/codemirror-5.52.0/addon/hint/show-hint.css">
|
||||
<!-- End of autocomplete -->
|
||||
<meta property="og:title" content="Cesium Sandcastle" />
|
||||
<meta property="og:description" content="The Cesium Sandcastle provides an interactive environment for testing Cesium code." />
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ http://dojotoolkit.org/
|
|||
|
||||
http://codemirror.net/
|
||||
|
||||
> Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
> Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
>
|
||||
> 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:
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
*.txt text
|
||||
*.js text
|
||||
*.html text
|
||||
*.md text
|
||||
*.json text
|
||||
*.yml text
|
||||
*.css text
|
||||
*.svg text
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
/node_modules
|
||||
/npm-debug.log
|
||||
test.html
|
||||
.tern-*
|
||||
*~
|
||||
*.swp
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
|
|
@ -1,381 +0,0 @@
|
|||
List of CodeMirror contributors. Updated before every release.
|
||||
|
||||
4r2r
|
||||
Aaron Brooks
|
||||
Abe Fettig
|
||||
Adam Ahmed
|
||||
Adam King
|
||||
adanlobato
|
||||
Adán Lobato
|
||||
Adrian Aichner
|
||||
aeroson
|
||||
Ahmad Amireh
|
||||
Ahmad M. Zawawi
|
||||
ahoward
|
||||
Akeksandr Motsjonov
|
||||
Alberto González Palomo
|
||||
Alberto Pose
|
||||
Albert Xing
|
||||
Alexander Pavlov
|
||||
Alexander Schepanovski
|
||||
Alexander Shvets
|
||||
Alexander Solovyov
|
||||
Alexandre Bique
|
||||
alexey-k
|
||||
Alex Piggott
|
||||
Amsul
|
||||
amuntean
|
||||
Amy
|
||||
Ananya Sen
|
||||
anaran
|
||||
AndersMad
|
||||
Anders Nawroth
|
||||
Anderson Mesquita
|
||||
Andreas Reischuck
|
||||
Andre von Houck
|
||||
Andrey Fedorov
|
||||
Andrey Lushnikov
|
||||
Andy Joslin
|
||||
Andy Kimball
|
||||
Andy Li
|
||||
angelozerr
|
||||
angelo.zerr@gmail.com
|
||||
Ankit Ahuja
|
||||
Ansel Santosa
|
||||
Anthony Grimes
|
||||
Anton Kovalyov
|
||||
areos
|
||||
as3boyan
|
||||
AtomicPages LLC
|
||||
Atul Bhouraskar
|
||||
Aurelian Oancea
|
||||
Bastian Müller
|
||||
Bem Jones-Bey
|
||||
benbro
|
||||
Beni Cherniavsky-Paskin
|
||||
Benjamin DeCoste
|
||||
Ben Keen
|
||||
Bernhard Sirlinger
|
||||
Bert Chang
|
||||
Billy Moon
|
||||
binny
|
||||
B Krishna Chaitanya
|
||||
Blaine G
|
||||
boomyjee
|
||||
borawjm
|
||||
Brandon Frohs
|
||||
Brandon Wamboldt
|
||||
Brett Zamir
|
||||
Brian Grinstead
|
||||
Brian Sletten
|
||||
Bruce Mitchener
|
||||
Chandra Sekhar Pydi
|
||||
Charles Skelton
|
||||
Cheah Chu Yeow
|
||||
Chris Coyier
|
||||
Chris Granger
|
||||
Chris Houseknecht
|
||||
Chris Morgan
|
||||
Christopher Brown
|
||||
ciaranj
|
||||
CodeAnimal
|
||||
ComFreek
|
||||
Curtis Gagliardi
|
||||
dagsta
|
||||
daines
|
||||
Dan Heberden
|
||||
Daniel, Dao Quang Minh
|
||||
Daniele Di Sarli
|
||||
Daniel Faust
|
||||
Daniel Huigens
|
||||
Daniel KJ
|
||||
Daniel Neel
|
||||
Daniel Parnell
|
||||
Danny Yoo
|
||||
Darius Roberts
|
||||
Dave Myers
|
||||
David Mignot
|
||||
David Pathakjee
|
||||
deebugger
|
||||
Deep Thought
|
||||
dignifiedquire
|
||||
domagoj412
|
||||
Dominator008
|
||||
Domizio Demichelis
|
||||
Doug Wikle
|
||||
Drew Bratcher
|
||||
Drew Hintz
|
||||
Drew Khoury
|
||||
Dror BG
|
||||
duralog
|
||||
eborden
|
||||
edsharp
|
||||
ekhaled
|
||||
Enam Mijbah Noor
|
||||
Eric Allam
|
||||
eustas
|
||||
Fabien O'Carroll
|
||||
Fabio Zendhi Nagao
|
||||
Faiza Alsaied
|
||||
Fauntleroy
|
||||
fbuchinger
|
||||
feizhang365
|
||||
Felipe Lalanne
|
||||
Felix Raab
|
||||
Filip Noetzel
|
||||
flack
|
||||
ForbesLindesay
|
||||
Forbes Lindesay
|
||||
Ford_Lawnmower
|
||||
Frank Wiegand
|
||||
Gabriel Horner
|
||||
Gabriel Nahmias
|
||||
galambalazs
|
||||
Gautam Mehta
|
||||
gekkoe
|
||||
Gergely Hegykozi
|
||||
Glenn Jorde
|
||||
Glenn Ruehle
|
||||
Golevka
|
||||
Gordon Smith
|
||||
Grant Skinner
|
||||
greengiant
|
||||
Guillaume Massé
|
||||
Guillaume Massé
|
||||
Gustavo Rodrigues
|
||||
Hakan Tunc
|
||||
Hans Engel
|
||||
Hardest
|
||||
Hasan Karahan
|
||||
Hiroyuki Makino
|
||||
hitsthings
|
||||
Hocdoc
|
||||
Ian Beck
|
||||
Ian Dickinson
|
||||
Ian Wehrman
|
||||
Ian Wetherbee
|
||||
Ice White
|
||||
ICHIKAWA, Yuji
|
||||
ilvalle
|
||||
Ingo Richter
|
||||
Irakli Gozalishvili
|
||||
Ivan Kurnosov
|
||||
Jacob Lee
|
||||
Jakob Miland
|
||||
Jakub Vrana
|
||||
James Campos
|
||||
James Thorne
|
||||
Jamie Hill
|
||||
Jan Jongboom
|
||||
jankeromnes
|
||||
Jan Keromnes
|
||||
Jan Odvarko
|
||||
Jan T. Sott
|
||||
Jason
|
||||
Jason Grout
|
||||
Jason Johnston
|
||||
Jason San Jose
|
||||
Jason Siefken
|
||||
Jaydeep Solanki
|
||||
Jean Boussier
|
||||
jeffkenton
|
||||
Jeff Pickhardt
|
||||
jem (graphite)
|
||||
Jochen Berger
|
||||
Johan Ask
|
||||
John Connor
|
||||
John Lees-Miller
|
||||
John Snelson
|
||||
John Van Der Loo
|
||||
Jonathan Malmaud
|
||||
jongalloway
|
||||
Jon Malmaud
|
||||
Joost-Wim Boekesteijn
|
||||
Joseph Pecoraro
|
||||
Joshua Newman
|
||||
Josh Watzman
|
||||
jots
|
||||
jsoojeon
|
||||
Juan Benavides Romero
|
||||
Jucovschi Constantin
|
||||
Juho Vuori
|
||||
jwallers@gmail.com
|
||||
kaniga
|
||||
Ken Newman
|
||||
Ken Rockot
|
||||
Kevin Sawicki
|
||||
Klaus Silveira
|
||||
Koh Zi Han, Cliff
|
||||
komakino
|
||||
Konstantin Lopuhin
|
||||
koops
|
||||
ks-ifware
|
||||
kubelsmieci
|
||||
Lanny
|
||||
Laszlo Vidacs
|
||||
leaf corcoran
|
||||
Leonid Khachaturov
|
||||
Leonya Khachaturov
|
||||
Liam Newman
|
||||
LM
|
||||
lochel
|
||||
Lorenzo Stoakes
|
||||
Luciano Longo
|
||||
lynschinzer
|
||||
Maksim Lin
|
||||
Maksym Taran
|
||||
Malay Majithia
|
||||
Manuel Rego Casasnovas
|
||||
Marat Dreizin
|
||||
Marcel Gerber
|
||||
Marco Aurélio
|
||||
Marco Munizaga
|
||||
Marcus Bointon
|
||||
Marijn Haverbeke
|
||||
Mario Pietsch
|
||||
Mark Lentczner
|
||||
Marko Bonaci
|
||||
Martin Balek
|
||||
Martín Gaitán
|
||||
Martin Hasoň
|
||||
Mason Malone
|
||||
Mateusz Paprocki
|
||||
Mathias Bynens
|
||||
mats cronqvist
|
||||
Matthew Beale
|
||||
Matthias BUSSONNIER
|
||||
Matt McDonald
|
||||
Matt Pass
|
||||
Matt Sacks
|
||||
mauricio
|
||||
Maximilian Hils
|
||||
Maxim Kraev
|
||||
Max Kirsch
|
||||
mbarkhau
|
||||
Metatheos
|
||||
Micah Dubinko
|
||||
Michael Lehenbauer
|
||||
Michael Zhou
|
||||
Mighty Guava
|
||||
Miguel Castillo
|
||||
Mike
|
||||
Mike Brevoort
|
||||
Mike Diaz
|
||||
Mike Ivanov
|
||||
Mike Kadin
|
||||
MinRK
|
||||
Miraculix87
|
||||
misfo
|
||||
mloginov
|
||||
mps
|
||||
mtaran-google
|
||||
Narciso Jaramillo
|
||||
Nathan Williams
|
||||
ndr
|
||||
nerbert
|
||||
nextrevision
|
||||
nguillaumin
|
||||
Ng Zhi An
|
||||
Nicholas Bollweg
|
||||
Nick Small
|
||||
Niels van Groningen
|
||||
Nikita Beloglazov
|
||||
Nikita Vasilyev
|
||||
Nikolay Kostov
|
||||
nilp0inter
|
||||
nlwillia
|
||||
pablo
|
||||
Page
|
||||
Panupong Pasupat
|
||||
paris
|
||||
Patil Arpith
|
||||
Patrick Strawderman
|
||||
Paul Garvin
|
||||
Paul Ivanov
|
||||
Pavel Feldman
|
||||
Pavel Strashkin
|
||||
Paweł Bartkiewicz
|
||||
peteguhl
|
||||
Peter Flynn
|
||||
peterkroon
|
||||
Peter Kroon
|
||||
prasanthj
|
||||
Prasanth J
|
||||
Radek Piórkowski
|
||||
Rahul
|
||||
Randy Edmunds
|
||||
Rasmus Erik Voel Jensen
|
||||
Richard van der Meer
|
||||
Richard Z.H. Wang
|
||||
Roberto Abdelkader Martínez Pérez
|
||||
robertop23
|
||||
Robert Plummer
|
||||
Ruslan Osmanov
|
||||
Ryan Prior
|
||||
sabaca
|
||||
Samuel Ainsworth
|
||||
sandeepshetty
|
||||
Sander AKA Redsandro
|
||||
santec
|
||||
Sascha Peilicke
|
||||
satchmorun
|
||||
sathyamoorthi
|
||||
SCLINIC\jdecker
|
||||
Scott Aikin
|
||||
Sebastian Zaha
|
||||
shaund
|
||||
shaun gilchrist
|
||||
Shawn A
|
||||
sheopory
|
||||
Shiv Deepak
|
||||
Shmuel Englard
|
||||
Shubham Jain
|
||||
snasa
|
||||
soliton4
|
||||
sonson
|
||||
spastorelli
|
||||
srajanpaliwal
|
||||
Stanislav Oaserele
|
||||
Stas Kobzar
|
||||
Stefan Borsje
|
||||
Steffen Beyer
|
||||
Steve O'Hara
|
||||
stoskov
|
||||
Taha Jahangir
|
||||
Takuji Shimokawa
|
||||
Tarmil
|
||||
tfjgeorge
|
||||
Thaddee Tyl
|
||||
TheHowl
|
||||
think
|
||||
Thomas Dvornik
|
||||
Thomas Schmid
|
||||
Tim Alby
|
||||
Tim Baumann
|
||||
Timothy Farrell
|
||||
Timothy Hatcher
|
||||
TobiasBg
|
||||
Tomas-A
|
||||
Tomas Varaneckas
|
||||
Tom Erik Støwer
|
||||
Tom MacWright
|
||||
Tony Jian
|
||||
Travis Heppe
|
||||
Triangle717
|
||||
twifkak
|
||||
Vestimir Markov
|
||||
vf
|
||||
Vincent Woo
|
||||
Volker Mische
|
||||
wenli
|
||||
Wesley Wiser
|
||||
William Jamieson
|
||||
William Stein
|
||||
Wojtek Ptak
|
||||
Xavier Mendez
|
||||
YNH Webdev
|
||||
Yunchi Luo
|
||||
Yuvi Panda
|
||||
Zachary Dremann
|
||||
zziuni
|
||||
魏鹏刚
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# CodeMirror
|
||||
[](https://travis-ci.org/marijnh/CodeMirror)
|
||||
[](https://www.npmjs.org/package/codemirror)
|
||||
|
||||
CodeMirror is a JavaScript component that provides a code editor in
|
||||
the browser. When a mode is available for the language you are coding
|
||||
in, it will color your code, and optionally help with indentation.
|
||||
|
||||
The project page is http://codemirror.net
|
||||
The manual is at http://codemirror.net/doc/manual.html
|
||||
The contributing guidelines are in [CONTRIBUTING.md](https://github.com/marijnh/CodeMirror/blob/master/CONTRIBUTING.md)
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var modes = ["clike", "css", "javascript"];
|
||||
|
||||
for (var i = 0; i < modes.length; ++i)
|
||||
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
|
||||
|
||||
function continueComment(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), mode, inserts = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head, token = cm.getTokenAt(pos);
|
||||
if (token.type != "comment") return CodeMirror.Pass;
|
||||
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
||||
if (!mode) mode = modeHere;
|
||||
else if (mode != modeHere) return CodeMirror.Pass;
|
||||
|
||||
var insert = null;
|
||||
if (mode.blockCommentStart && mode.blockCommentContinue) {
|
||||
var end = token.string.indexOf(mode.blockCommentEnd);
|
||||
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
|
||||
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
|
||||
// Comment ended, don't continue it
|
||||
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
||||
insert = full.slice(0, token.start);
|
||||
if (!/^\s*$/.test(insert)) {
|
||||
insert = "";
|
||||
for (var j = 0; j < token.start; ++j) insert += " ";
|
||||
}
|
||||
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
||||
found + mode.blockCommentContinue.length > token.start &&
|
||||
/^\s*$/.test(full.slice(0, found))) {
|
||||
insert = full.slice(0, found);
|
||||
}
|
||||
if (insert != null) insert += mode.blockCommentContinue;
|
||||
}
|
||||
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
|
||||
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
|
||||
if (found > -1) {
|
||||
insert = line.slice(0, found);
|
||||
if (/\S/.test(insert)) insert = null;
|
||||
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
|
||||
}
|
||||
}
|
||||
if (insert == null) return CodeMirror.Pass;
|
||||
inserts[i] = "\n" + insert;
|
||||
}
|
||||
|
||||
cm.operation(function() {
|
||||
for (var i = ranges.length - 1; i >= 0; i--)
|
||||
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
|
||||
});
|
||||
}
|
||||
|
||||
function continueLineCommentEnabled(cm) {
|
||||
var opt = cm.getOption("continueComments");
|
||||
if (opt && typeof opt == "object")
|
||||
return opt.continueLineComment !== false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
|
||||
if (prev && prev != CodeMirror.Init)
|
||||
cm.removeKeyMap("continueComment");
|
||||
if (val) {
|
||||
var key = "Enter";
|
||||
if (typeof val == "string")
|
||||
key = val;
|
||||
else if (typeof val == "object" && val.key)
|
||||
key = val.key;
|
||||
var map = {name: "continueComment"};
|
||||
map[key] = continueComment;
|
||||
cm.addKeyMap(map);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var DEFAULT_BRACKETS = "()[]{}''\"\"";
|
||||
var DEFAULT_EXPLODE_ON_ENTER = "[]{}";
|
||||
var SPACE_CHAR_REGEX = /\s/;
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
|
||||
if (old != CodeMirror.Init && old)
|
||||
cm.removeKeyMap("autoCloseBrackets");
|
||||
if (!val) return;
|
||||
var pairs = DEFAULT_BRACKETS, explode = DEFAULT_EXPLODE_ON_ENTER;
|
||||
if (typeof val == "string") pairs = val;
|
||||
else if (typeof val == "object") {
|
||||
if (val.pairs != null) pairs = val.pairs;
|
||||
if (val.explode != null) explode = val.explode;
|
||||
}
|
||||
var map = buildKeymap(pairs);
|
||||
if (explode) map.Enter = buildExplodeHandler(explode);
|
||||
cm.addKeyMap(map);
|
||||
});
|
||||
|
||||
function charsAround(cm, pos) {
|
||||
var str = cm.getRange(Pos(pos.line, pos.ch - 1),
|
||||
Pos(pos.line, pos.ch + 1));
|
||||
return str.length == 2 ? str : null;
|
||||
}
|
||||
|
||||
// Project the token type that will exists after the given char is
|
||||
// typed, and use it to determine whether it would cause the start
|
||||
// of a string token.
|
||||
function enteringString(cm, pos, ch) {
|
||||
var line = cm.getLine(pos.line);
|
||||
var token = cm.getTokenAt(pos);
|
||||
if (/\bstring2?\b/.test(token.type)) return false;
|
||||
var stream = new CodeMirror.StringStream(line.slice(0, pos.ch) + ch + line.slice(pos.ch), 4);
|
||||
stream.pos = stream.start = token.start;
|
||||
for (;;) {
|
||||
var type1 = cm.getMode().token(stream, token.state);
|
||||
if (stream.pos >= pos.ch + 1) return /\bstring2?\b/.test(type1);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
|
||||
function buildKeymap(pairs) {
|
||||
var map = {
|
||||
name : "autoCloseBrackets",
|
||||
Backspace: function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var cur = ranges[i].head;
|
||||
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
var closingBrackets = "";
|
||||
for (var i = 0; i < pairs.length; i += 2) (function(left, right) {
|
||||
if (left != right) closingBrackets += right;
|
||||
map["'" + left + "'"] = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), type, next;
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i], cur = range.head, curType;
|
||||
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
|
||||
if (!range.empty())
|
||||
curType = "surround";
|
||||
else if (left == right && next == right) {
|
||||
if (cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == left + left + left)
|
||||
curType = "skipThree";
|
||||
else
|
||||
curType = "skip";
|
||||
} else if (left == right && cur.ch > 1 &&
|
||||
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left &&
|
||||
(cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left))
|
||||
curType = "addFour";
|
||||
else if (left == '"' || left == "'") {
|
||||
if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, left)) curType = "both";
|
||||
else return CodeMirror.Pass;
|
||||
} else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next))
|
||||
curType = "both";
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
if (!type) type = curType;
|
||||
else if (type != curType) return CodeMirror.Pass;
|
||||
}
|
||||
|
||||
cm.operation(function() {
|
||||
if (type == "skip") {
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "skipThree") {
|
||||
for (var i = 0; i < 3; i++)
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "surround") {
|
||||
var sels = cm.getSelections();
|
||||
for (var i = 0; i < sels.length; i++)
|
||||
sels[i] = left + sels[i] + right;
|
||||
cm.replaceSelections(sels, "around");
|
||||
} else if (type == "both") {
|
||||
cm.replaceSelection(left + right, null);
|
||||
cm.execCommand("goCharLeft");
|
||||
} else if (type == "addFour") {
|
||||
cm.replaceSelection(left + left + left + left, "before");
|
||||
cm.execCommand("goCharRight");
|
||||
}
|
||||
});
|
||||
};
|
||||
if (left != right) map["'" + right + "'"] = function(cm) {
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i];
|
||||
if (!range.empty() ||
|
||||
cm.getRange(range.head, Pos(range.head.line, range.head.ch + 1)) != right)
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
cm.execCommand("goCharRight");
|
||||
};
|
||||
})(pairs.charAt(i), pairs.charAt(i + 1));
|
||||
return map;
|
||||
}
|
||||
|
||||
function buildExplodeHandler(pairs) {
|
||||
return function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
cm.operation(function() {
|
||||
cm.replaceSelection("\n\n", null);
|
||||
cm.execCommand("goCharLeft");
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var line = ranges[i].head.line;
|
||||
cm.indentLine(line, null, true);
|
||||
cm.indentLine(line + 1, null, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)([*+-]|(\d+)\.)(\s+)/,
|
||||
unorderedBullets = "*+-";
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head, match;
|
||||
var inList = cm.getStateAfter(pos.line).list !== false;
|
||||
|
||||
if (!ranges[i].empty() || !inList || !(match = cm.getLine(pos.line).match(listRE))) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
var indent = match[1], after = match[4];
|
||||
var bullet = unorderedBullets.indexOf(match[2]) >= 0
|
||||
? match[2]
|
||||
: (parseInt(match[3], 10) + 1) + ".";
|
||||
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
});
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, _keywords, getToken) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
className: token.string == ":" ? "python-type" : null};
|
||||
}
|
||||
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
|
||||
var completionList = getCompletions(token, context);
|
||||
completionList = completionList.sort();
|
||||
|
||||
return {list: completionList,
|
||||
from: CodeMirror.Pos(cur.line, token.start),
|
||||
to: CodeMirror.Pos(cur.line, token.end)};
|
||||
}
|
||||
|
||||
function pythonHint(editor) {
|
||||
return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "python", pythonHint);
|
||||
|
||||
var pythonKeywords = "and del from not while as elif global or with assert else if pass yield"
|
||||
+ "break except import print class exec in raise continue finally is return def for lambda try";
|
||||
var pythonKeywordsL = pythonKeywords.split(" ");
|
||||
var pythonKeywordsU = pythonKeywords.toUpperCase().split(" ");
|
||||
|
||||
var pythonBuiltins = "abs divmod input open staticmethod all enumerate int ord str "
|
||||
+ "any eval isinstance pow sum basestring execfile issubclass print super"
|
||||
+ "bin file iter property tuple bool filter len range type"
|
||||
+ "bytearray float list raw_input unichr callable format locals reduce unicode"
|
||||
+ "chr frozenset long reload vars classmethod getattr map repr xrange"
|
||||
+ "cmp globals max reversed zip compile hasattr memoryview round __import__"
|
||||
+ "complex hash min set apply delattr help next setattr buffer"
|
||||
+ "dict hex object slice coerce dir id oct sorted intern ";
|
||||
var pythonBuiltinsL = pythonBuiltins.split(" ").join("() ").split(" ");
|
||||
var pythonBuiltinsU = pythonBuiltins.toUpperCase().split(" ").join("() ").split(" ");
|
||||
|
||||
function getCompletions(token, context) {
|
||||
var found = [], start = token.string;
|
||||
function maybeAdd(str) {
|
||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
|
||||
function gatherCompletions(_obj) {
|
||||
forEach(pythonBuiltinsL, maybeAdd);
|
||||
forEach(pythonBuiltinsU, maybeAdd);
|
||||
forEach(pythonKeywordsL, maybeAdd);
|
||||
forEach(pythonKeywordsU, maybeAdd);
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
|
||||
if (obj.type == "variable")
|
||||
base = obj.string;
|
||||
else if(obj.type == "variable-3")
|
||||
base = ":" + obj.string;
|
||||
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var tables;
|
||||
var keywords;
|
||||
var CONS = {
|
||||
QUERY_DIV: ";",
|
||||
ALIAS_KEYWORD: "AS"
|
||||
};
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function getKeywords(editor) {
|
||||
var mode = editor.doc.modeOption;
|
||||
if (mode === "sql") mode = "text/x-sql";
|
||||
return CodeMirror.resolveMode(mode).keywords;
|
||||
}
|
||||
|
||||
function match(string, word) {
|
||||
var len = string.length;
|
||||
var sub = word.substr(0, len);
|
||||
return string.toUpperCase() === sub.toUpperCase();
|
||||
}
|
||||
|
||||
function addMatches(result, search, wordlist, formatter) {
|
||||
for (var word in wordlist) {
|
||||
if (!wordlist.hasOwnProperty(word)) continue;
|
||||
if (Array.isArray(wordlist)) {
|
||||
word = wordlist[word];
|
||||
}
|
||||
if (match(search, word)) {
|
||||
result.push(formatter(word));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function columnCompletion(result, editor) {
|
||||
var cur = editor.getCursor();
|
||||
var token = editor.getTokenAt(cur);
|
||||
var string = token.string.substr(1);
|
||||
var prevCur = Pos(cur.line, token.start);
|
||||
var table = editor.getTokenAt(prevCur).string;
|
||||
if (!tables.hasOwnProperty(table))
|
||||
table = findTableByAlias(table, editor);
|
||||
var columns = tables[table];
|
||||
if (!columns) return;
|
||||
|
||||
addMatches(result, string, columns, function(w) {return "." + w;});
|
||||
}
|
||||
|
||||
function eachWord(lineText, f) {
|
||||
if (!lineText) return;
|
||||
var excepted = /[,;]/g;
|
||||
var words = lineText.split(" ");
|
||||
for (var i = 0; i < words.length; i++) {
|
||||
f(words[i]?words[i].replace(excepted, '') : '');
|
||||
}
|
||||
}
|
||||
|
||||
function convertCurToNumber(cur) {
|
||||
// max characters of a line is 999,999.
|
||||
return cur.line + cur.ch / Math.pow(10, 6);
|
||||
}
|
||||
|
||||
function convertNumberToCur(num) {
|
||||
return Pos(Math.floor(num), +num.toString().split('.').pop());
|
||||
}
|
||||
|
||||
function findTableByAlias(alias, editor) {
|
||||
var doc = editor.doc;
|
||||
var fullQuery = doc.getValue();
|
||||
var aliasUpperCase = alias.toUpperCase();
|
||||
var previousWord = "";
|
||||
var table = "";
|
||||
var separator = [];
|
||||
var validRange = {
|
||||
start: Pos(0, 0),
|
||||
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
||||
};
|
||||
|
||||
//add separator
|
||||
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
||||
while(indexOfSeparator != -1) {
|
||||
separator.push(doc.posFromIndex(indexOfSeparator));
|
||||
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
||||
}
|
||||
separator.unshift(Pos(0, 0));
|
||||
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
||||
|
||||
//find valid range
|
||||
var prevItem = 0;
|
||||
var current = convertCurToNumber(editor.getCursor());
|
||||
for (var i=0; i< separator.length; i++) {
|
||||
var _v = convertCurToNumber(separator[i]);
|
||||
if (current > prevItem && current <= _v) {
|
||||
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
|
||||
break;
|
||||
}
|
||||
prevItem = _v;
|
||||
}
|
||||
|
||||
var query = doc.getRange(validRange.start, validRange.end, false);
|
||||
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
var lineText = query[i];
|
||||
eachWord(lineText, function(word) {
|
||||
var wordUpperCase = word.toUpperCase();
|
||||
if (wordUpperCase === aliasUpperCase && tables.hasOwnProperty(previousWord)) {
|
||||
table = previousWord;
|
||||
}
|
||||
if (wordUpperCase !== CONS.ALIAS_KEYWORD) {
|
||||
previousWord = word;
|
||||
}
|
||||
});
|
||||
if (table) break;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
||||
tables = (options && options.tables) || {};
|
||||
keywords = keywords || getKeywords(editor);
|
||||
var cur = editor.getCursor();
|
||||
var result = [];
|
||||
var token = editor.getTokenAt(cur), start, end, search;
|
||||
if (token.string.match(/^[.\w@]\w*$/)) {
|
||||
search = token.string;
|
||||
start = token.start;
|
||||
end = token.end;
|
||||
} else {
|
||||
start = end = cur.ch;
|
||||
search = "";
|
||||
}
|
||||
if (search.charAt(0) == ".") {
|
||||
columnCompletion(result, editor);
|
||||
if (!result.length) {
|
||||
while (start && search.charAt(0) == ".") {
|
||||
token = editor.getTokenAt(Pos(cur.line, token.start - 1));
|
||||
start = token.start;
|
||||
search = token.string + search;
|
||||
}
|
||||
addMatches(result, search, tables, function(w) {return w;});
|
||||
}
|
||||
} else {
|
||||
addMatches(result, search, tables, function(w) {return w;});
|
||||
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
||||
}
|
||||
|
||||
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
||||
});
|
||||
});
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
// declare global: JSHINT
|
||||
|
||||
var bogus = [ "Dangerous comment" ];
|
||||
|
||||
var warnings = [ [ "Expected '{'",
|
||||
"Statement body should be inside '{ }' braces." ] ];
|
||||
|
||||
var errors = [ "Missing semicolon", "Extra comma", "Missing property name",
|
||||
"Unmatched ", " and instead saw", " is not defined",
|
||||
"Unclosed string", "Stopping, unable to continue" ];
|
||||
|
||||
function validator(text, options) {
|
||||
if (!window.JSHINT) return [];
|
||||
JSHINT(text, options);
|
||||
var errors = JSHINT.data().errors, result = [];
|
||||
if (errors) parseErrors(errors, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||
|
||||
function cleanup(error) {
|
||||
// All problems are warnings by default
|
||||
fixWith(error, warnings, "warning", true);
|
||||
fixWith(error, errors, "error");
|
||||
|
||||
return isBogus(error) ? null : error;
|
||||
}
|
||||
|
||||
function fixWith(error, fixes, severity, force) {
|
||||
var description, fix, find, replace, found;
|
||||
|
||||
description = error.description;
|
||||
|
||||
for ( var i = 0; i < fixes.length; i++) {
|
||||
fix = fixes[i];
|
||||
find = (typeof fix === "string" ? fix : fix[0]);
|
||||
replace = (typeof fix === "string" ? null : fix[1]);
|
||||
found = description.indexOf(find) !== -1;
|
||||
|
||||
if (force || found) {
|
||||
error.severity = severity;
|
||||
}
|
||||
if (found && replace) {
|
||||
error.description = replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isBogus(error) {
|
||||
var description = error.description;
|
||||
for ( var i = 0; i < bogus.length; i++) {
|
||||
if (description.indexOf(bogus[i]) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseErrors(errors, output) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
if (error) {
|
||||
var linetabpositions, index;
|
||||
|
||||
linetabpositions = [];
|
||||
|
||||
// This next block is to fix a problem in jshint. Jshint
|
||||
// replaces
|
||||
// all tabs with spaces then performs some checks. The error
|
||||
// positions (character/space) are then reported incorrectly,
|
||||
// not taking the replacement step into account. Here we look
|
||||
// at the evidence line and try to adjust the character position
|
||||
// to the correct value.
|
||||
if (error.evidence) {
|
||||
// Tab positions are computed once per line and cached
|
||||
var tabpositions = linetabpositions[error.line];
|
||||
if (!tabpositions) {
|
||||
var evidence = error.evidence;
|
||||
tabpositions = [];
|
||||
// ugggh phantomjs does not like this
|
||||
// forEachChar(evidence, function(item, index) {
|
||||
Array.prototype.forEach.call(evidence, function(item,
|
||||
index) {
|
||||
if (item === '\t') {
|
||||
// First col is 1 (not 0) to match error
|
||||
// positions
|
||||
tabpositions.push(index + 1);
|
||||
}
|
||||
});
|
||||
linetabpositions[error.line] = tabpositions;
|
||||
}
|
||||
if (tabpositions.length > 0) {
|
||||
var pos = error.character;
|
||||
tabpositions.forEach(function(tabposition) {
|
||||
if (pos > tabposition) pos -= 1;
|
||||
});
|
||||
error.character = pos;
|
||||
}
|
||||
}
|
||||
|
||||
var start = error.character - 1, end = start + 1;
|
||||
if (error.evidence) {
|
||||
index = error.evidence.substring(start).search(/.\b/);
|
||||
if (index > -1) {
|
||||
end += index;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to format expected by validation service
|
||||
error.description = error.reason;// + "(jshint)";
|
||||
error.start = error.character;
|
||||
error.end = end;
|
||||
error = cleanup(error);
|
||||
|
||||
if (error)
|
||||
output.push({message: error.description,
|
||||
severity: error.severity,
|
||||
from: CodeMirror.Pos(error.line - 1, start),
|
||||
to: CodeMirror.Pos(error.line - 1, end)});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
|
||||
|
||||
// declare global: jsyaml
|
||||
|
||||
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
||||
var found = [];
|
||||
try { jsyaml.load(text); }
|
||||
catch(e) {
|
||||
var loc = e.mark;
|
||||
found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
|
||||
}
|
||||
return found;
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,536 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("diff_match_patch"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror, diff_match_patch);
|
||||
})(function(CodeMirror, diff_match_patch) {
|
||||
"use strict";
|
||||
var Pos = CodeMirror.Pos;
|
||||
var svgNS = "http://www.w3.org/2000/svg";
|
||||
|
||||
function DiffView(mv, type) {
|
||||
this.mv = mv;
|
||||
this.type = type;
|
||||
this.classes = type == "left"
|
||||
? {chunk: "CodeMirror-merge-l-chunk",
|
||||
start: "CodeMirror-merge-l-chunk-start",
|
||||
end: "CodeMirror-merge-l-chunk-end",
|
||||
insert: "CodeMirror-merge-l-inserted",
|
||||
del: "CodeMirror-merge-l-deleted",
|
||||
connect: "CodeMirror-merge-l-connect"}
|
||||
: {chunk: "CodeMirror-merge-r-chunk",
|
||||
start: "CodeMirror-merge-r-chunk-start",
|
||||
end: "CodeMirror-merge-r-chunk-end",
|
||||
insert: "CodeMirror-merge-r-inserted",
|
||||
del: "CodeMirror-merge-r-deleted",
|
||||
connect: "CodeMirror-merge-r-connect"};
|
||||
}
|
||||
|
||||
DiffView.prototype = {
|
||||
constructor: DiffView,
|
||||
init: function(pane, orig, options) {
|
||||
this.edit = this.mv.edit;
|
||||
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
||||
|
||||
this.diff = getDiff(asString(orig), asString(options.value));
|
||||
this.diffOutOfDate = false;
|
||||
|
||||
this.showDifferences = options.showDifferences !== false;
|
||||
this.forceUpdate = registerUpdate(this);
|
||||
setScrollLock(this, true, false);
|
||||
registerScroll(this);
|
||||
},
|
||||
setShowDifferences: function(val) {
|
||||
val = val !== false;
|
||||
if (val != this.showDifferences) {
|
||||
this.showDifferences = val;
|
||||
this.forceUpdate("full");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function ensureDiff(dv) {
|
||||
if (dv.diffOutOfDate) {
|
||||
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
||||
dv.diffOutOfDate = false;
|
||||
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
||||
}
|
||||
}
|
||||
|
||||
function registerUpdate(dv) {
|
||||
var edit = {from: 0, to: 0, marked: []};
|
||||
var orig = {from: 0, to: 0, marked: []};
|
||||
var debounceChange;
|
||||
function update(mode) {
|
||||
if (mode == "full") {
|
||||
if (dv.svg) clear(dv.svg);
|
||||
if (dv.copyButtons) clear(dv.copyButtons);
|
||||
clearMarks(dv.edit, edit.marked, dv.classes);
|
||||
clearMarks(dv.orig, orig.marked, dv.classes);
|
||||
edit.from = edit.to = orig.from = orig.to = 0;
|
||||
}
|
||||
ensureDiff(dv);
|
||||
if (dv.showDifferences) {
|
||||
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
|
||||
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
|
||||
}
|
||||
drawConnectors(dv);
|
||||
}
|
||||
function set(slow) {
|
||||
clearTimeout(debounceChange);
|
||||
debounceChange = setTimeout(update, slow == true ? 250 : 100);
|
||||
}
|
||||
function change() {
|
||||
if (!dv.diffOutOfDate) {
|
||||
dv.diffOutOfDate = true;
|
||||
edit.from = edit.to = orig.from = orig.to = 0;
|
||||
}
|
||||
set(true);
|
||||
}
|
||||
dv.edit.on("change", change);
|
||||
dv.orig.on("change", change);
|
||||
dv.edit.on("markerAdded", set);
|
||||
dv.edit.on("markerCleared", set);
|
||||
dv.orig.on("markerAdded", set);
|
||||
dv.orig.on("markerCleared", set);
|
||||
dv.edit.on("viewportChange", set);
|
||||
dv.orig.on("viewportChange", set);
|
||||
update();
|
||||
return update;
|
||||
}
|
||||
|
||||
function registerScroll(dv) {
|
||||
dv.edit.on("scroll", function() {
|
||||
syncScroll(dv, DIFF_INSERT) && drawConnectors(dv);
|
||||
});
|
||||
dv.orig.on("scroll", function() {
|
||||
syncScroll(dv, DIFF_DELETE) && drawConnectors(dv);
|
||||
});
|
||||
}
|
||||
|
||||
function syncScroll(dv, type) {
|
||||
// Change handler will do a refresh after a timeout when diff is out of date
|
||||
if (dv.diffOutOfDate) return false;
|
||||
if (!dv.lockScroll) return true;
|
||||
var editor, other, now = +new Date;
|
||||
if (type == DIFF_INSERT) { editor = dv.edit; other = dv.orig; }
|
||||
else { editor = dv.orig; other = dv.edit; }
|
||||
// Don't take action if the position of this editor was recently set
|
||||
// (to prevent feedback loops)
|
||||
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 50 > now) return false;
|
||||
|
||||
var sInfo = editor.getScrollInfo(), halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
||||
var mid = editor.lineAtHeight(midY, "local");
|
||||
var around = chunkBoundariesAround(dv.diff, mid, type == DIFF_INSERT);
|
||||
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
|
||||
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
|
||||
var ratio = (midY - off.top) / (off.bot - off.top);
|
||||
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
||||
|
||||
var botDist, mix;
|
||||
// Some careful tweaking to make sure no space is left out of view
|
||||
// when scrolling to top or bottom.
|
||||
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
|
||||
targetPos = targetPos * mix + sInfo.top * (1 - mix);
|
||||
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
|
||||
var otherInfo = other.getScrollInfo();
|
||||
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
|
||||
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
|
||||
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
|
||||
}
|
||||
|
||||
other.scrollTo(sInfo.left, targetPos);
|
||||
other.state.scrollSetAt = now;
|
||||
other.state.scrollSetBy = dv;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getOffsets(editor, around) {
|
||||
var bot = around.after;
|
||||
if (bot == null) bot = editor.lastLine() + 1;
|
||||
return {top: editor.heightAtLine(around.before || 0, "local"),
|
||||
bot: editor.heightAtLine(bot, "local")};
|
||||
}
|
||||
|
||||
function setScrollLock(dv, val, action) {
|
||||
dv.lockScroll = val;
|
||||
if (val && action != false) syncScroll(dv, DIFF_INSERT) && drawConnectors(dv);
|
||||
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da";
|
||||
}
|
||||
|
||||
// Updating the marks for editor content
|
||||
|
||||
function clearMarks(editor, arr, classes) {
|
||||
for (var i = 0; i < arr.length; ++i) {
|
||||
var mark = arr[i];
|
||||
if (mark instanceof CodeMirror.TextMarker) {
|
||||
mark.clear();
|
||||
} else if (mark.parent) {
|
||||
editor.removeLineClass(mark, "background", classes.chunk);
|
||||
editor.removeLineClass(mark, "background", classes.start);
|
||||
editor.removeLineClass(mark, "background", classes.end);
|
||||
}
|
||||
}
|
||||
arr.length = 0;
|
||||
}
|
||||
|
||||
// FIXME maybe add a margin around viewport to prevent too many updates
|
||||
function updateMarks(editor, diff, state, type, classes) {
|
||||
var vp = editor.getViewport();
|
||||
editor.operation(function() {
|
||||
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
||||
clearMarks(editor, state.marked, classes);
|
||||
markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
|
||||
state.from = vp.from; state.to = vp.to;
|
||||
} else {
|
||||
if (vp.from < state.from) {
|
||||
markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
|
||||
state.from = vp.from;
|
||||
}
|
||||
if (vp.to > state.to) {
|
||||
markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
|
||||
state.to = vp.to;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function markChanges(editor, diff, type, marks, from, to, classes) {
|
||||
var pos = Pos(0, 0);
|
||||
var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
|
||||
var cls = type == DIFF_DELETE ? classes.del : classes.insert;
|
||||
function markChunk(start, end) {
|
||||
var bfrom = Math.max(from, start), bto = Math.min(to, end);
|
||||
for (var i = bfrom; i < bto; ++i) {
|
||||
var line = editor.addLineClass(i, "background", classes.chunk);
|
||||
if (i == start) editor.addLineClass(line, "background", classes.start);
|
||||
if (i == end - 1) editor.addLineClass(line, "background", classes.end);
|
||||
marks.push(line);
|
||||
}
|
||||
// When the chunk is empty, make sure a horizontal line shows up
|
||||
if (start == end && bfrom == end && bto == end) {
|
||||
if (bfrom)
|
||||
marks.push(editor.addLineClass(bfrom - 1, "background", classes.end));
|
||||
else
|
||||
marks.push(editor.addLineClass(bfrom, "background", classes.start));
|
||||
}
|
||||
}
|
||||
|
||||
var chunkStart = 0;
|
||||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i], tp = part[0], str = part[1];
|
||||
if (tp == DIFF_EQUAL) {
|
||||
var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1);
|
||||
moveOver(pos, str);
|
||||
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
||||
if (cleanTo > cleanFrom) {
|
||||
if (i) markChunk(chunkStart, cleanFrom);
|
||||
chunkStart = cleanTo;
|
||||
}
|
||||
} else {
|
||||
if (tp == type) {
|
||||
var end = moveOver(pos, str, true);
|
||||
var a = posMax(top, pos), b = posMin(bot, end);
|
||||
if (!posEq(a, b))
|
||||
marks.push(editor.markText(a, b, {className: cls}));
|
||||
pos = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chunkStart <= pos.line) markChunk(chunkStart, pos.line + 1);
|
||||
}
|
||||
|
||||
// Updating the gap between editor and original
|
||||
|
||||
function drawConnectors(dv) {
|
||||
if (!dv.showDifferences) return;
|
||||
|
||||
if (dv.svg) {
|
||||
clear(dv.svg);
|
||||
var w = dv.gap.offsetWidth;
|
||||
attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight);
|
||||
}
|
||||
if (dv.copyButtons) clear(dv.copyButtons);
|
||||
|
||||
var flip = dv.type == "left";
|
||||
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
|
||||
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
|
||||
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
|
||||
if (topEdit > vpEdit.to || botEdit < vpEdit.from ||
|
||||
topOrig > vpOrig.to || botOrig < vpOrig.from)
|
||||
return;
|
||||
var topLpx = dv.orig.heightAtLine(topOrig, "local") - sTopOrig, top = topLpx;
|
||||
if (dv.svg) {
|
||||
var topRpx = dv.edit.heightAtLine(topEdit, "local") - sTopEdit;
|
||||
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
|
||||
var botLpx = dv.orig.heightAtLine(botOrig, "local") - sTopOrig;
|
||||
var botRpx = dv.edit.heightAtLine(botEdit, "local") - sTopEdit;
|
||||
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
|
||||
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
|
||||
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
|
||||
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")),
|
||||
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z",
|
||||
"class", dv.classes.connect);
|
||||
}
|
||||
if (dv.copyButtons) {
|
||||
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
|
||||
"CodeMirror-merge-copy"));
|
||||
var editOriginals = dv.mv.options.allowEditingOriginals;
|
||||
copy.title = editOriginals ? "Push to left" : "Revert chunk";
|
||||
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig};
|
||||
copy.style.top = top + "px";
|
||||
|
||||
if (editOriginals) {
|
||||
var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit;
|
||||
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
|
||||
"CodeMirror-merge-copy-reverse"));
|
||||
copyReverse.title = "Push to right";
|
||||
copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit};
|
||||
copyReverse.style.top = topReverse + "px";
|
||||
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyChunk(dv, to, from, chunk) {
|
||||
if (dv.diffOutOfDate) return;
|
||||
to.replaceRange(from.getRange(Pos(chunk.topOrig, 0), Pos(chunk.botOrig, 0)),
|
||||
Pos(chunk.topEdit, 0), Pos(chunk.botEdit, 0));
|
||||
}
|
||||
|
||||
// Merge view, containing 0, 1, or 2 diff views.
|
||||
|
||||
var MergeView = CodeMirror.MergeView = function(node, options) {
|
||||
if (!(this instanceof MergeView)) return new MergeView(node, options);
|
||||
|
||||
this.options = options;
|
||||
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
|
||||
var hasLeft = origLeft != null, hasRight = origRight != null;
|
||||
var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0);
|
||||
var wrap = [], left = this.left = null, right = this.right = null;
|
||||
|
||||
if (hasLeft) {
|
||||
left = this.left = new DiffView(this, "left");
|
||||
var leftPane = elt("div", null, "CodeMirror-merge-pane");
|
||||
wrap.push(leftPane);
|
||||
wrap.push(buildGap(left));
|
||||
}
|
||||
|
||||
var editPane = elt("div", null, "CodeMirror-merge-pane");
|
||||
wrap.push(editPane);
|
||||
|
||||
if (hasRight) {
|
||||
right = this.right = new DiffView(this, "right");
|
||||
wrap.push(buildGap(right));
|
||||
var rightPane = elt("div", null, "CodeMirror-merge-pane");
|
||||
wrap.push(rightPane);
|
||||
}
|
||||
|
||||
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
|
||||
|
||||
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
|
||||
|
||||
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
|
||||
this.edit = CodeMirror(editPane, copyObj(options));
|
||||
|
||||
if (left) left.init(leftPane, origLeft, options);
|
||||
if (right) right.init(rightPane, origRight, options);
|
||||
|
||||
var onResize = function() {
|
||||
if (left) drawConnectors(left);
|
||||
if (right) drawConnectors(right);
|
||||
};
|
||||
CodeMirror.on(window, "resize", onResize);
|
||||
var resizeInterval = setInterval(function() {
|
||||
for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {}
|
||||
if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); }
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
function buildGap(dv) {
|
||||
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
|
||||
lock.title = "Toggle locked scrolling";
|
||||
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
|
||||
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
|
||||
var gapElts = [lockWrap];
|
||||
if (dv.mv.options.revertButtons !== false) {
|
||||
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
|
||||
CodeMirror.on(dv.copyButtons, "click", function(e) {
|
||||
var node = e.target || e.srcElement;
|
||||
if (!node.chunk) return;
|
||||
if (node.className == "CodeMirror-merge-copy-reverse") {
|
||||
copyChunk(dv, dv.orig, dv.edit, node.chunk);
|
||||
return;
|
||||
}
|
||||
copyChunk(dv, dv.edit, dv.orig, node.chunk);
|
||||
});
|
||||
gapElts.unshift(dv.copyButtons);
|
||||
}
|
||||
var svg = document.createElementNS && document.createElementNS(svgNS, "svg");
|
||||
if (svg && !svg.createSVGRect) svg = null;
|
||||
dv.svg = svg;
|
||||
if (svg) gapElts.push(svg);
|
||||
|
||||
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
|
||||
}
|
||||
|
||||
MergeView.prototype = {
|
||||
constuctor: MergeView,
|
||||
editor: function() { return this.edit; },
|
||||
rightOriginal: function() { return this.right && this.right.orig; },
|
||||
leftOriginal: function() { return this.left && this.left.orig; },
|
||||
setShowDifferences: function(val) {
|
||||
if (this.right) this.right.setShowDifferences(val);
|
||||
if (this.left) this.left.setShowDifferences(val);
|
||||
},
|
||||
rightChunks: function() {
|
||||
return this.right && getChunks(this.right);
|
||||
},
|
||||
leftChunks: function() {
|
||||
return this.left && getChunks(this.left);
|
||||
}
|
||||
};
|
||||
|
||||
function asString(obj) {
|
||||
if (typeof obj == "string") return obj;
|
||||
else return obj.getValue();
|
||||
}
|
||||
|
||||
// Operations on diffs
|
||||
|
||||
var dmp = new diff_match_patch();
|
||||
function getDiff(a, b) {
|
||||
var diff = dmp.diff_main(a, b);
|
||||
dmp.diff_cleanupSemantic(diff);
|
||||
// The library sometimes leaves in empty parts, which confuse the algorithm
|
||||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i];
|
||||
if (!part[1]) {
|
||||
diff.splice(i--, 1);
|
||||
} else if (i && diff[i - 1][0] == part[0]) {
|
||||
diff.splice(i--, 1);
|
||||
diff[i][1] += part[1];
|
||||
}
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
function iterateChunks(diff, f) {
|
||||
var startEdit = 0, startOrig = 0;
|
||||
var edit = Pos(0, 0), orig = Pos(0, 0);
|
||||
for (var i = 0; i < diff.length; ++i) {
|
||||
var part = diff[i], tp = part[0];
|
||||
if (tp == DIFF_EQUAL) {
|
||||
var startOff = startOfLineClean(diff, i) ? 0 : 1;
|
||||
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
||||
moveOver(edit, part[1], null, orig);
|
||||
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
||||
var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff;
|
||||
if (cleanToEdit > cleanFromEdit) {
|
||||
if (i) f(startOrig, cleanFromOrig, startEdit, cleanFromEdit);
|
||||
startEdit = cleanToEdit; startOrig = cleanToOrig;
|
||||
}
|
||||
} else {
|
||||
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
|
||||
}
|
||||
}
|
||||
if (startEdit <= edit.line || startOrig <= orig.line)
|
||||
f(startOrig, orig.line + 1, startEdit, edit.line + 1);
|
||||
}
|
||||
|
||||
function getChunks(dv) {
|
||||
ensureDiff(dv);
|
||||
var collect = [];
|
||||
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
|
||||
collect.push({origFrom: topOrig, origTo: botOrig,
|
||||
editFrom: topEdit, editTo: botEdit});
|
||||
});
|
||||
return collect;
|
||||
}
|
||||
|
||||
function endOfLineClean(diff, i) {
|
||||
if (i == diff.length - 1) return true;
|
||||
var next = diff[i + 1][1];
|
||||
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
||||
if (i == diff.length - 2) return true;
|
||||
next = diff[i + 2][1];
|
||||
return next.length > 1 && next.charCodeAt(0) == 10;
|
||||
}
|
||||
|
||||
function startOfLineClean(diff, i) {
|
||||
if (i == 0) return true;
|
||||
var last = diff[i - 1][1];
|
||||
if (last.charCodeAt(last.length - 1) != 10) return false;
|
||||
if (i == 1) return true;
|
||||
last = diff[i - 2][1];
|
||||
return last.charCodeAt(last.length - 1) == 10;
|
||||
}
|
||||
|
||||
function chunkBoundariesAround(diff, n, nInEdit) {
|
||||
var beforeE, afterE, beforeO, afterO;
|
||||
iterateChunks(diff, function(fromOrig, toOrig, fromEdit, toEdit) {
|
||||
var fromLocal = nInEdit ? fromEdit : fromOrig;
|
||||
var toLocal = nInEdit ? toEdit : toOrig;
|
||||
if (afterE == null) {
|
||||
if (fromLocal > n) { afterE = fromEdit; afterO = fromOrig; }
|
||||
else if (toLocal > n) { afterE = toEdit; afterO = toOrig; }
|
||||
}
|
||||
if (toLocal <= n) { beforeE = toEdit; beforeO = toOrig; }
|
||||
else if (fromLocal <= n) { beforeE = fromEdit; beforeO = fromOrig; }
|
||||
});
|
||||
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};
|
||||
}
|
||||
|
||||
// General utilities
|
||||
|
||||
function elt(tag, content, className, style) {
|
||||
var e = document.createElement(tag);
|
||||
if (className) e.className = className;
|
||||
if (style) e.style.cssText = style;
|
||||
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
||||
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
||||
return e;
|
||||
}
|
||||
|
||||
function clear(node) {
|
||||
for (var count = node.childNodes.length; count > 0; --count)
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
|
||||
function attrs(elt) {
|
||||
for (var i = 1; i < arguments.length; i += 2)
|
||||
elt.setAttribute(arguments[i], arguments[i+1]);
|
||||
}
|
||||
|
||||
function copyObj(obj, target) {
|
||||
if (!target) target = {};
|
||||
for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
|
||||
return target;
|
||||
}
|
||||
|
||||
function moveOver(pos, str, copy, other) {
|
||||
var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0;
|
||||
for (;;) {
|
||||
var nl = str.indexOf("\n", at);
|
||||
if (nl == -1) break;
|
||||
++out.line;
|
||||
if (other) ++other.line;
|
||||
at = nl + 1;
|
||||
}
|
||||
out.ch = (at ? 0 : out.ch) + (str.length - at);
|
||||
if (other) other.ch = (at ? 0 : other.ch) + (str.length - at);
|
||||
return out;
|
||||
}
|
||||
|
||||
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
||||
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
||||
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
||||
});
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// Define search commands. Depends on dialog.js or another
|
||||
// implementation of the openDialog method.
|
||||
|
||||
// Replace works a little oddly -- it will do the replace on the next
|
||||
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
||||
// replace by making sure the match is no longer selected when hitting
|
||||
// Ctrl-G.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
function searchOverlay(query, caseInsensitive) {
|
||||
if (typeof query == "string")
|
||||
query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
|
||||
else if (!query.global)
|
||||
query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
|
||||
|
||||
return {token: function(stream) {
|
||||
query.lastIndex = stream.pos;
|
||||
var match = query.exec(stream.string);
|
||||
if (match && match.index == stream.pos) {
|
||||
stream.pos += match[0].length;
|
||||
return "searching";
|
||||
} else if (match) {
|
||||
stream.pos = match.index;
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
function SearchState() {
|
||||
this.posFrom = this.posTo = this.query = null;
|
||||
this.overlay = null;
|
||||
}
|
||||
function getSearchState(cm) {
|
||||
return cm.state.search || (cm.state.search = new SearchState());
|
||||
}
|
||||
function queryCaseInsensitive(query) {
|
||||
return typeof query == "string" && query == query.toLowerCase();
|
||||
}
|
||||
function getSearchCursor(cm, query, pos) {
|
||||
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
||||
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
|
||||
}
|
||||
function dialog(cm, text, shortText, deflt, f) {
|
||||
if (cm.openDialog) cm.openDialog(text, f, {value: deflt});
|
||||
else f(prompt(shortText, deflt));
|
||||
}
|
||||
function confirmDialog(cm, text, shortText, fs) {
|
||||
if (cm.openConfirm) cm.openConfirm(text, fs);
|
||||
else if (confirm(shortText)) fs[0]();
|
||||
}
|
||||
function parseQuery(query) {
|
||||
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
||||
if (isRE) {
|
||||
query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i");
|
||||
if (query.test("")) query = /x^/;
|
||||
} else if (query == "") {
|
||||
query = /x^/;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
var queryDialog =
|
||||
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
||||
function doSearch(cm, rev) {
|
||||
var state = getSearchState(cm);
|
||||
if (state.query) return findNext(cm, rev);
|
||||
dialog(cm, queryDialog, "Search for:", cm.getSelection(), function(query) {
|
||||
cm.operation(function() {
|
||||
if (!query || state.query) return;
|
||||
state.query = parseQuery(query);
|
||||
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
|
||||
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
|
||||
cm.addOverlay(state.overlay);
|
||||
state.posFrom = state.posTo = cm.getCursor();
|
||||
findNext(cm, rev);
|
||||
});
|
||||
});
|
||||
}
|
||||
function findNext(cm, rev) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
||||
if (!cursor.find(rev)) {
|
||||
cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
|
||||
if (!cursor.find(rev)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
||||
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
||||
});}
|
||||
function clearSearch(cm) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
if (!state.query) return;
|
||||
state.query = null;
|
||||
cm.removeOverlay(state.overlay);
|
||||
});}
|
||||
|
||||
var replaceQueryDialog =
|
||||
'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>';
|
||||
var replacementQueryDialog = 'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
|
||||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
|
||||
function replace(cm, all) {
|
||||
if (cm.getOption("readOnly")) return;
|
||||
dialog(cm, replaceQueryDialog, "Replace:", cm.getSelection(), function(query) {
|
||||
if (!query) return;
|
||||
query = parseQuery(query);
|
||||
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
|
||||
if (all) {
|
||||
cm.operation(function() {
|
||||
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
||||
if (typeof query != "string") {
|
||||
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
||||
cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
||||
} else cursor.replace(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
clearSearch(cm);
|
||||
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
||||
var advance = function() {
|
||||
var start = cursor.from(), match;
|
||||
if (!(match = cursor.findNext())) {
|
||||
cursor = getSearchCursor(cm, query);
|
||||
if (!(match = cursor.findNext()) ||
|
||||
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
|
||||
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
||||
[function() {doReplace(match);}, advance]);
|
||||
};
|
||||
var doReplace = function(match) {
|
||||
cursor.replace(typeof query == "string" ? text :
|
||||
text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
|
||||
advance();
|
||||
};
|
||||
advance();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
||||
CodeMirror.commands.findNext = doSearch;
|
||||
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
||||
CodeMirror.commands.clearSearch = clearSearch;
|
||||
CodeMirror.commands.replace = replace;
|
||||
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
||||
});
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
function SearchCursor(doc, query, pos, caseFold) {
|
||||
this.atOccurrence = false; this.doc = doc;
|
||||
if (caseFold == null && typeof query == "string") caseFold = false;
|
||||
|
||||
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
|
||||
this.pos = {from: pos, to: pos};
|
||||
|
||||
// The matches method is filled in based on the type of query.
|
||||
// It takes a position and a direction, and returns an object
|
||||
// describing the next occurrence of the query, or null if no
|
||||
// more matches were found.
|
||||
if (typeof query != "string") { // Regexp match
|
||||
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
||||
this.matches = function(reverse, pos) {
|
||||
if (reverse) {
|
||||
query.lastIndex = 0;
|
||||
var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
|
||||
for (;;) {
|
||||
query.lastIndex = cutOff;
|
||||
var newMatch = query.exec(line);
|
||||
if (!newMatch) break;
|
||||
match = newMatch;
|
||||
start = match.index;
|
||||
cutOff = match.index + (match[0].length || 1);
|
||||
if (cutOff == line.length) break;
|
||||
}
|
||||
var matchLen = (match && match[0].length) || 0;
|
||||
if (!matchLen) {
|
||||
if (start == 0 && line.length == 0) {match = undefined;}
|
||||
else if (start != doc.getLine(pos.line).length) {
|
||||
matchLen++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
query.lastIndex = pos.ch;
|
||||
var line = doc.getLine(pos.line), match = query.exec(line);
|
||||
var matchLen = (match && match[0].length) || 0;
|
||||
var start = match && match.index;
|
||||
if (start + matchLen != line.length && !matchLen) matchLen = 1;
|
||||
}
|
||||
if (match && matchLen)
|
||||
return {from: Pos(pos.line, start),
|
||||
to: Pos(pos.line, start + matchLen),
|
||||
match: match};
|
||||
};
|
||||
} else { // String query
|
||||
var origQuery = query;
|
||||
if (caseFold) query = query.toLowerCase();
|
||||
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
||||
var target = query.split("\n");
|
||||
// Different methods for single-line and multi-line queries
|
||||
if (target.length == 1) {
|
||||
if (!query.length) {
|
||||
// Empty string would match anything and never progress, so
|
||||
// we define it to match nothing instead.
|
||||
this.matches = function() {};
|
||||
} else {
|
||||
this.matches = function(reverse, pos) {
|
||||
if (reverse) {
|
||||
var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
|
||||
var match = line.lastIndexOf(query);
|
||||
if (match > -1) {
|
||||
match = adjustPos(orig, line, match);
|
||||
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
||||
}
|
||||
} else {
|
||||
var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
|
||||
var match = line.indexOf(query);
|
||||
if (match > -1) {
|
||||
match = adjustPos(orig, line, match) + pos.ch;
|
||||
return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
var origTarget = origQuery.split("\n");
|
||||
this.matches = function(reverse, pos) {
|
||||
var last = target.length - 1;
|
||||
if (reverse) {
|
||||
if (pos.line - (target.length - 1) < doc.firstLine()) return;
|
||||
if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
|
||||
var to = Pos(pos.line, origTarget[last].length);
|
||||
for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
|
||||
if (target[i] != fold(doc.getLine(ln))) return;
|
||||
var line = doc.getLine(ln), cut = line.length - origTarget[0].length;
|
||||
if (fold(line.slice(cut)) != target[0]) return;
|
||||
return {from: Pos(ln, cut), to: to};
|
||||
} else {
|
||||
if (pos.line + (target.length - 1) > doc.lastLine()) return;
|
||||
var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
|
||||
if (fold(line.slice(cut)) != target[0]) return;
|
||||
var from = Pos(pos.line, cut);
|
||||
for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
|
||||
if (target[i] != fold(doc.getLine(ln))) return;
|
||||
if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return;
|
||||
return {from: from, to: Pos(ln, origTarget[last].length)};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SearchCursor.prototype = {
|
||||
findNext: function() {return this.find(false);},
|
||||
findPrevious: function() {return this.find(true);},
|
||||
|
||||
find: function(reverse) {
|
||||
var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
|
||||
function savePosAndFail(line) {
|
||||
var pos = Pos(line, 0);
|
||||
self.pos = {from: pos, to: pos};
|
||||
self.atOccurrence = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (this.pos = this.matches(reverse, pos)) {
|
||||
this.atOccurrence = true;
|
||||
return this.pos.match || true;
|
||||
}
|
||||
if (reverse) {
|
||||
if (!pos.line) return savePosAndFail(0);
|
||||
pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
|
||||
}
|
||||
else {
|
||||
var maxLine = this.doc.lineCount();
|
||||
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
||||
pos = Pos(pos.line + 1, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
from: function() {if (this.atOccurrence) return this.pos.from;},
|
||||
to: function() {if (this.atOccurrence) return this.pos.to;},
|
||||
|
||||
replace: function(newText) {
|
||||
if (!this.atOccurrence) return;
|
||||
var lines = CodeMirror.splitLines(newText);
|
||||
this.doc.replaceRange(lines, this.pos.from, this.pos.to);
|
||||
this.pos.to = Pos(this.pos.from.line + lines.length - 1,
|
||||
lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
|
||||
}
|
||||
};
|
||||
|
||||
// Maps a position in a case-folded line back to a position in the original line
|
||||
// (compensating for codepoints increasing in number during folding)
|
||||
function adjustPos(orig, folded, pos) {
|
||||
if (orig.length == folded.length) return pos;
|
||||
for (var pos1 = Math.min(pos, orig.length);;) {
|
||||
var len1 = orig.slice(0, pos1).toLowerCase().length;
|
||||
if (len1 < pos) ++pos1;
|
||||
else if (len1 > pos) --pos1;
|
||||
else return pos1;
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
||||
return new SearchCursor(this.doc, query, pos, caseFold);
|
||||
});
|
||||
CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
|
||||
return new SearchCursor(this, query, pos, caseFold);
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
|
||||
var ranges = [], next;
|
||||
var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
|
||||
while (next = cur.findNext()) {
|
||||
if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
|
||||
ranges.push({anchor: cur.from(), head: cur.to()});
|
||||
}
|
||||
if (ranges.length)
|
||||
this.setSelections(ranges, 0);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Compression helper for CodeMirror
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// bin/compress codemirror runmode javascript xml
|
||||
//
|
||||
// Will take lib/codemirror.js, addon/runmode/runmode.js,
|
||||
// mode/javascript/javascript.js, and mode/xml/xml.js, run them though
|
||||
// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit
|
||||
// out the result.
|
||||
//
|
||||
// bin/compress codemirror --local /path/to/bin/UglifyJS
|
||||
//
|
||||
// Will use a local minifier instead of the online default one.
|
||||
//
|
||||
// Script files are specified without .js ending. Prefixing them with
|
||||
// their full (local) path is optional. So you may say lib/codemirror
|
||||
// or mode/xml/xml to be more precise. In fact, even the .js suffix
|
||||
// may be speficied, if wanted.
|
||||
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
|
||||
function help(ok) {
|
||||
console.log("usage: " + process.argv[1] + " [--local /path/to/uglifyjs] files...");
|
||||
process.exit(ok ? 0 : 1);
|
||||
}
|
||||
|
||||
var local = null, args = [], extraArgs = null, files = [], blob = "";
|
||||
|
||||
for (var i = 2; i < process.argv.length; ++i) {
|
||||
var arg = process.argv[i];
|
||||
if (arg == "--local" && i + 1 < process.argv.length) {
|
||||
var parts = process.argv[++i].split(/\s+/);
|
||||
local = parts[0];
|
||||
extraArgs = parts.slice(1);
|
||||
if (!extraArgs.length) extraArgs = ["-c", "-m"];
|
||||
} else if (arg == "--help") {
|
||||
help(true);
|
||||
} else if (arg[0] != "-") {
|
||||
files.push({name: arg, re: new RegExp("(?:\\/|^)" + arg + (/\.js$/.test(arg) ? "$" : "\\.js$"))});
|
||||
} else help(false);
|
||||
}
|
||||
|
||||
function walk(dir) {
|
||||
fs.readdirSync(dir).forEach(function(fname) {
|
||||
if (/^[_\.]/.test(fname)) return;
|
||||
var file = dir + fname;
|
||||
if (fs.statSync(file).isDirectory()) return walk(file + "/");
|
||||
if (files.some(function(spec, i) {
|
||||
var match = spec.re.test(file);
|
||||
if (match) files.splice(i, 1);
|
||||
return match;
|
||||
})) {
|
||||
if (local) args.push(file);
|
||||
else blob += fs.readFileSync(file, "utf8");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walk("lib/");
|
||||
walk("addon/");
|
||||
walk("mode/");
|
||||
|
||||
if (!local && !blob) help(false);
|
||||
|
||||
if (files.length) {
|
||||
console.log("Some speficied files were not found: " +
|
||||
files.map(function(a){return a.name;}).join(", "));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (local) {
|
||||
require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]});
|
||||
} else {
|
||||
var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8");
|
||||
var req = require("http").request({
|
||||
host: "marijnhaverbeke.nl",
|
||||
port: 80,
|
||||
method: "POST",
|
||||
path: "/uglifyjs",
|
||||
headers: {"content-type": "application/x-www-form-urlencoded",
|
||||
"content-length": data.length}
|
||||
});
|
||||
req.on("response", function(resp) {
|
||||
resp.on("data", function (chunk) { process.stdout.write(chunk); });
|
||||
});
|
||||
req.end(data);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var lint = require("../test/lint/lint"),
|
||||
path = require("path");
|
||||
|
||||
if (process.argv.length > 2) {
|
||||
lint.checkDir(process.argv[2]);
|
||||
} else {
|
||||
process.chdir(path.resolve(__dirname, ".."));
|
||||
lint.checkDir("lib");
|
||||
lint.checkDir("mode");
|
||||
lint.checkDir("addon");
|
||||
lint.checkDir("keymap");
|
||||
}
|
||||
|
||||
process.exit(lint.success() ? 0 : 1);
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"name": "codemirror",
|
||||
"version":"4.6.0",
|
||||
"main": ["lib/codemirror.js", "lib/codemirror.css"],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components",
|
||||
"bin",
|
||||
"demo",
|
||||
"doc",
|
||||
"test",
|
||||
"index.html",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Match Highlighter Demo</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../lib/codemirror.css">
|
||||
<script src="../lib/codemirror.js"></script>
|
||||
<script src="../addon/search/searchcursor.js"></script>
|
||||
<script src="../addon/search/match-highlighter.js"></script>
|
||||
<style type="text/css">
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.CodeMirror-focused .cm-matchhighlight {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
|
||||
background-position: bottom;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Home</a>
|
||||
<li><a href="../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a class=active href="#">Match Highlighter</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Match Highlighter Demo</h2>
|
||||
<form><textarea id="code" name="code">Select this text: hardToSpotVar
|
||||
And everywhere else in your code where hardToSpotVar appears will automatically illuminate.
|
||||
Give it a try! No more hardToSpotVars.</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
highlightSelectionMatches: {showToken: /\w/}
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Search and highlight occurences of the selected text.</p>
|
||||
|
||||
</article>
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Compression Helper</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="docs.css">
|
||||
<script src="../lib/codemirror.js"></script>
|
||||
<script src="../mode/javascript/javascript.js"></script>
|
||||
<link rel=stylesheet href="../lib/codemirror.css">
|
||||
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Home</a>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a class=active href="#">Compression helper</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
|
||||
<h2>Script compression helper</h2>
|
||||
|
||||
<p>To optimize loading CodeMirror, especially when including a
|
||||
bunch of different modes, it is recommended that you combine and
|
||||
minify (and preferably also gzip) the scripts. This page makes
|
||||
those first two steps very easy. Simply select the version and
|
||||
scripts you need in the form below, and
|
||||
click <strong>Compress</strong> to download the minified script
|
||||
file.</p>
|
||||
|
||||
<form id="form" action="http://marijnhaverbeke.nl/uglifyjs" method="post" onsubmit="generateHeader();">
|
||||
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
|
||||
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
|
||||
<option value="http://codemirror.net/">HEAD</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.6.0;f=">4.6</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.5.0;f=">4.5</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.4.0;f=">4.4</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.3.0;f=">4.3</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.2.1;f=">4.2</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.2.0;f=">4.2</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.1.0;f=">4.1</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.0.3;f=">4.0</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.23.0;f=">3.23</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.22.0;f=">3.22</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.21.0;f=">3.21</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.20.0;f=">3.20</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.19.0;f=">3.19</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.18.0;f=">3.18</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.16.0;f=">3.16</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.15.0;f=">3.15</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.14.0;f=">3.14</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=3.13.0;f=">3.13</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.12;f=">3.12</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.11;f=">3.11</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.1;f=">3.1</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.02;f=">3.02</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.01;f=">3.01</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0;f=">3.0</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.38;f=">2.38</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.37;f=">2.37</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.36;f=">2.36</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.35;f=">2.35</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.34;f=">2.34</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.33;f=">2.33</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.32;f=">2.32</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.31;f=">2.31</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.3;f=">2.3</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.25;f=">2.25</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.24;f=">2.24</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.23;f=">2.23</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.22;f=">2.22</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.21;f=">2.21</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.2;f=">2.2</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.18;f=">2.18</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.16;f=">2.16</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.15;f=">2.15</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.13;f=">2.13</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.12;f=">2.12</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.11;f=">2.11</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.1;f=">2.1</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.02;f=">2.02</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.01;f=">2.01</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v2.0;f=">2.0</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=beta2;f=">beta2</option>
|
||||
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=beta1;f=">beta1</option>
|
||||
</select></p>
|
||||
|
||||
<select multiple="multiple" size="20" name="code_url" style="width: 40em;" class="field" id="files">
|
||||
<optgroup label="CodeMirror Library">
|
||||
<option value="http://codemirror.net/lib/codemirror.js" selected>codemirror.js</option>
|
||||
</optgroup>
|
||||
<optgroup label="Modes">
|
||||
<option value="http://codemirror.net/mode/apl/apl.js">apl.js</option>
|
||||
<option value="http://codemirror.net/mode/clike/clike.js">clike.js</option>
|
||||
<option value="http://codemirror.net/mode/clojure/clojure.js">clojure.js</option>
|
||||
<option value="http://codemirror.net/mode/cobol/cobol.js">cobol.js</option>
|
||||
<option value="http://codemirror.net/mode/coffeescript/coffeescript.js">coffeescript.js</option>
|
||||
<option value="http://codemirror.net/mode/commonlisp/commonlisp.js">commonlisp.js</option>
|
||||
<option value="http://codemirror.net/mode/css/css.js">css.js</option>
|
||||
<option value="http://codemirror.net/mode/cypher/cypher.js">cypher.js</option>
|
||||
<option value="http://codemirror.net/mode/d/d.js">d.js</option>
|
||||
<option value="http://codemirror.net/mode/diff/diff.js">diff.js</option>
|
||||
<option value="http://codemirror.net/mode/django/django.js">django.js</option>
|
||||
<option value="http://codemirror.net/mode/dtd/dtd.js">dtd.js</option>
|
||||
<option value="http://codemirror.net/mode/dylan/dylan.js">dylan.js</option>
|
||||
<option value="http://codemirror.net/mode/ecl/ecl.js">ecl.js</option>
|
||||
<option value="http://codemirror.net/mode/eiffel/eiffel.js">eiffel.js</option>
|
||||
<option value="http://codemirror.net/mode/erlang/erlang.js">erlang.js</option>
|
||||
<option value="http://codemirror.net/mode/fortran/fortran.js">fortran.js</option>
|
||||
<option value="http://codemirror.net/mode/gfm/gfm.js">gfm.js</option>
|
||||
<option value="http://codemirror.net/mode/gas/gas.js">gas.js</option>
|
||||
<option value="http://codemirror.net/mode/gherkin/gherkin.js">gherkin.js</option>
|
||||
<option value="http://codemirror.net/mode/go/go.js">go.js</option>
|
||||
<option value="http://codemirror.net/mode/groovy/groovy.js">groovy.js</option>
|
||||
<option value="http://codemirror.net/mode/haml/haml.js">haml.js</option>
|
||||
<option value="http://codemirror.net/mode/haskell/haskell.js">haskell.js</option>
|
||||
<option value="http://codemirror.net/mode/haxe/haxe.js">haxe.js</option>
|
||||
<option value="http://codemirror.net/mode/htmlembedded/htmlembedded.js">htmlembedded.js</option>
|
||||
<option value="http://codemirror.net/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
|
||||
<option value="http://codemirror.net/mode/http/http.js">http.js</option>
|
||||
<option value="http://codemirror.net/mode/jade/jade.js">jade.js</option>
|
||||
<option value="http://codemirror.net/mode/javascript/javascript.js">javascript.js</option>
|
||||
<option value="http://codemirror.net/mode/jinja2/jinja2.js">jinja2.js</option>
|
||||
<option value="http://codemirror.net/mode/julia/julia.js">julia.js</option>
|
||||
<option value="http://codemirror.net/mode/kotlin/kotlin.js">kotlin.js</option>
|
||||
<option value="http://codemirror.net/mode/livescript/livescript.js">livescript.js</option>
|
||||
<option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
|
||||
<option value="http://codemirror.net/mode/markdown/markdown.js">markdown.js</option>
|
||||
<option value="http://codemirror.net/mode/mirc/mirc.js">mirc.js</option>
|
||||
<option value="http://codemirror.net/mode/mllike/mllike.js">mllike.js</option>
|
||||
<option value="http://codemirror.net/mode/modelica/modelica.js">modelica.js</option>
|
||||
<option value="http://codemirror.net/mode/nginx/nginx.js">nginx.js</option>
|
||||
<option value="http://codemirror.net/mode/ntriples/ntriples.js">ntriples.js</option>
|
||||
<option value="http://codemirror.net/mode/octave/octave.js">octave.js</option>
|
||||
<option value="http://codemirror.net/mode/pascal/pascal.js">pascal.js</option>
|
||||
<option value="http://codemirror.net/mode/pegjs/pegjs.js">pegjs.js</option>
|
||||
<option value="http://codemirror.net/mode/perl/perl.js">perl.js</option>
|
||||
<option value="http://codemirror.net/mode/php/php.js">php.js</option>
|
||||
<option value="http://codemirror.net/mode/pig/pig.js">pig.js</option>
|
||||
<option value="http://codemirror.net/mode/properties/properties.js">properties.js</option>
|
||||
<option value="http://codemirror.net/mode/python/python.js">python.js</option>
|
||||
<option value="http://codemirror.net/mode/puppet/puppet.js">puppet.js</option>
|
||||
<option value="http://codemirror.net/mode/q/q.js">q.js</option>
|
||||
<option value="http://codemirror.net/mode/r/r.js">r.js</option>
|
||||
<option value="http://codemirror.net/mode/rpm/rpm.js">rpm.js</option>
|
||||
<option value="http://codemirror.net/mode/rst/rst.js">rst.js</option>
|
||||
<option value="http://codemirror.net/mode/ruby/ruby.js">ruby.js</option>
|
||||
<option value="http://codemirror.net/mode/rust/rust.js">rust.js</option>
|
||||
<option value="http://codemirror.net/mode/sass/sass.js">sass.js</option>
|
||||
<option value="http://codemirror.net/mode/scala/scala.js">scala.js</option>
|
||||
<option value="http://codemirror.net/mode/scheme/scheme.js">scheme.js</option>
|
||||
<option value="http://codemirror.net/mode/shell/shell.js">shell.js</option>
|
||||
<option value="http://codemirror.net/mode/sieve/sieve.js">sieve.js</option>
|
||||
<option value="http://codemirror.net/mode/slim/slim.js">slim.js</option>
|
||||
<option value="http://codemirror.net/mode/smalltalk/smalltalk.js">smalltalk.js</option>
|
||||
<option value="http://codemirror.net/mode/smarty/smarty.js">smarty.js</option>
|
||||
<option value="http://codemirror.net/mode/smartymixed/smartymixed.js">smartymixed.js</option>
|
||||
<option value="http://codemirror.net/mode/sql/sql.js">sql.js</option>
|
||||
<option value="http://codemirror.net/mode/sparql/sparql.js">sparql.js</option>
|
||||
<option value="http://codemirror.net/mode/stex/stex.js">stex.js</option>
|
||||
<option value="http://codemirror.net/mode/tcl/tcl.js">tcl.js</option>
|
||||
<option value="http://codemirror.net/mode/tiddlywiki/tiddlywiki.js">tiddlywiki.js</option>
|
||||
<option value="http://codemirror.net/mode/tiki/tiki.js">tiki.js</option>
|
||||
<option value="http://codemirror.net/mode/toml/toml.js">toml.js</option>
|
||||
<option value="http://codemirror.net/mode/turtle/turtle.js">turtle.js</option>
|
||||
<option value="http://codemirror.net/mode/vb/vb.js">vb.js</option>
|
||||
<option value="http://codemirror.net/mode/vbscript/vbscript.js">vbscript.js</option>
|
||||
<option value="http://codemirror.net/mode/velocity/velocity.js">velocity.js</option>
|
||||
<option value="http://codemirror.net/mode/verilog/verilog.js">verilog.js</option>
|
||||
<option value="http://codemirror.net/mode/xml/xml.js">xml.js</option>
|
||||
<option value="http://codemirror.net/mode/xquery/xquery.js">xquery.js</option>
|
||||
<option value="http://codemirror.net/mode/yaml/yaml.js">yaml.js</option>
|
||||
<option value="http://codemirror.net/mode/z80/z80.js">z80.js</option>
|
||||
</optgroup>
|
||||
<optgroup label="Add-ons">
|
||||
<option value="http://codemirror.net/addon/selection/active-line.js">active-line.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/anyword-hint.js">anyword-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/brace-fold.js">brace-fold.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/closebrackets.js">closebrackets.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/closetag.js">closetag.js</option>
|
||||
<option value="http://codemirror.net/addon/runmode/colorize.js">colorize.js</option>
|
||||
<option value="http://codemirror.net/addon/comment/comment.js">comment.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/comment-fold.js">comment-fold.js</option>
|
||||
<option value="http://codemirror.net/addon/comment/continuecomment.js">continuecomment.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/continuelist.js">continuelist.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/css-hint.js">css-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/dialog/dialog.js">dialog.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/foldcode.js">foldcode.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/foldgutter.js">foldgutter.js</option>
|
||||
<option value="http://codemirror.net/addon/display/fullscreen.js">fullscreen.js</option>
|
||||
<option value="http://codemirror.net/addon/wrap/hardwrap.js">hardwrap.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/html-hint.js">html-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/indent-fold.js">indent-fold.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/javascript-hint.js">javascript-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/lint/javascript-lint.js">javascript-lint.js</option>
|
||||
<option value="http://codemirror.net/addon/lint/json-lint.js">json-lint.js</option>
|
||||
<option value="http://codemirror.net/addon/lint/lint.js">lint.js</option>
|
||||
<option value="http://codemirror.net/addon/mode/loadmode.js">loadmode.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/markdown-fold.js">markdown-fold.js</option>
|
||||
<option value="http://codemirror.net/addon/selection/mark-selection.js">mark-selection.js</option>
|
||||
<option value="http://codemirror.net/addon/search/match-highlighter.js">match-highlighter.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/matchbrackets.js">matchbrackets.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/matchtags.js">matchtags.js</option>
|
||||
<option value="http://codemirror.net/addon/merge/merge.js">merge.js</option>
|
||||
<option value="http://codemirror.net/addon/mode/multiplex.js">multiplex.js</option>
|
||||
<option value="http://codemirror.net/addon/mode/overlay.js">overlay.js</option>
|
||||
<option value="http://codemirror.net/addon/display/placeholder.js">placeholder.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/python-hint.js">python-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/display/rulers.js">rulers.js</option>
|
||||
<option value="http://codemirror.net/addon/runmode/runmode.js">runmode.js</option>
|
||||
<option value="http://codemirror.net/addon/runmode/runmode.node.js">runmode.node.js</option>
|
||||
<option value="http://codemirror.net/addon/runmode/runmode-standalone.js">runmode-standalone.js</option>
|
||||
<option value="http://codemirror.net/addon/search/search.js">search.js</option>
|
||||
<option value="http://codemirror.net/addon/search/searchcursor.js">searchcursor.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/show-hint.js">show-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/sql-hint.js">sql-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/edit/trailingspace.js">trailingspace.js</option>
|
||||
<option value="http://codemirror.net/addon/tern/tern.js">tern.js</option>
|
||||
<option value="http://codemirror.net/addon/fold/xml-fold.js">xml-fold.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/xml-hint.js">xml-hint.js</option>
|
||||
<option value="http://codemirror.net/addon/hint/yaml-lint.js">yaml-lint.js</option>
|
||||
</optgroup>
|
||||
<optgroup label="Keymaps">
|
||||
<option value="http://codemirror.net/keymap/emacs.js">emacs.js</option>
|
||||
<option value="http://codemirror.net/keymap/sublime.js">sublime.js</option>
|
||||
<option value="http://codemirror.net/keymap/vim.js">vim.js</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
<p>
|
||||
<button type="submit">Compress</button> with <a href="http://github.com/mishoo/UglifyJS/">UglifyJS</a>
|
||||
</p>
|
||||
<input type="hidden" id="header" name="header">
|
||||
<p>Custom code to add to the compressed file:<textarea name="js_code" style="width: 100%; height: 15em;" class="field" id="js_code"></textarea></p>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
CodeMirror.fromTextArea(document.getElementById("js_code")).getWrapperElement().className += " field";
|
||||
|
||||
function setVersion(ver) {
|
||||
var urlprefix = ver.options[ver.selectedIndex].value;
|
||||
var select = document.getElementById("files"), m;
|
||||
for (var optgr = select.firstChild; optgr; optgr = optgr.nextSibling)
|
||||
for (var opt = optgr.firstChild; opt; opt = opt.nextSibling) {
|
||||
if (opt.nodeName != "OPTION")
|
||||
continue;
|
||||
else if (m = opt.value.match(/^http:\/\/codemirror.net\/(.*)$/))
|
||||
opt.value = urlprefix + m[1];
|
||||
else if (m = opt.value.match(/http:\/\/marijnhaverbeke.nl\/git\/codemirror\?a=blob_plain;hb=[^;]+;f=(.*)$/))
|
||||
opt.value = urlprefix + m[1];
|
||||
}
|
||||
}
|
||||
|
||||
function generateHeader() {
|
||||
var versionNode = document.getElementById("version");
|
||||
var version = versionNode.options[versionNode.selectedIndex].label
|
||||
var filesNode = document.getElementById("files");
|
||||
var optGroupHeaderIncluded;
|
||||
|
||||
// Generate the comment
|
||||
var str = "/* CodeMirror - Minified & Bundled\n";
|
||||
str += " Generated on " + new Date().toLocaleDateString() + " with http://codemirror.net/doc/compress.html\n";
|
||||
str += " Version: " + version + "\n\n";
|
||||
|
||||
for (var group = filesNode.firstChild; group; group = group.nextSibling) {
|
||||
optGroupHeaderIncluded = false;
|
||||
for (var option = group.firstChild; option; option = option.nextSibling) {
|
||||
if (option.nodeName !== "OPTION") {
|
||||
continue;
|
||||
} else if (option.selected) {
|
||||
if (!optGroupHeaderIncluded) {
|
||||
str += " " + group.label + ":\n";
|
||||
optGroupHeaderIncluded = true;
|
||||
}
|
||||
str += " - " + option.label + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
str += " */\n\n";
|
||||
|
||||
document.getElementById("header").value = str;
|
||||
}
|
||||
</script>
|
||||
|
||||
</article>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
|
|
@ -1,147 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
inkscape:export-filename="/home/marijn/src/js/codemirror/doc/logo.png"
|
||||
inkscape:export-xdpi="27.450405"
|
||||
inkscape:export-ydpi="27.450405"
|
||||
sodipodi:docname="logo.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath4138">
|
||||
<path
|
||||
transform="matrix(1.05,0,0,1,-290.76164,27.927128)"
|
||||
d="m 705.08647,231.61324 a 70.710678,104.55079 0 1 1 -141.42135,0 70.710678,104.55079 0 1 1 141.42135,0 z"
|
||||
sodipodi:ry="104.55079"
|
||||
sodipodi:rx="70.710678"
|
||||
sodipodi:cy="231.61324"
|
||||
sodipodi:cx="634.37579"
|
||||
id="path4140"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
sodipodi:type="arc" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="291.72812"
|
||||
inkscape:cy="789.2497"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="875"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#a21313;fill-opacity:1;stroke:none;font-family:Ubuntu Mono;-inkscape-font-specification:Ubuntu Mono"
|
||||
x="247.48738"
|
||||
y="163.42795"
|
||||
id="text4006"
|
||||
sodipodi:linespacing="125%"
|
||||
clip-path="url(#clipPath4138)"
|
||||
transform="translate(0.50507287,0.50507595)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4008"
|
||||
x="247.48738"
|
||||
y="163.42795"> if (unit == "char") moveOnce();</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="182.17795"
|
||||
id="tspan4010"> else if (unit == "column") moveOnce(true);</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="200.92795"
|
||||
id="tspan4012"> else if (unit == "word" || unit == "group") {</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="219.67795"
|
||||
id="tspan4014"> var sawType = null, group = unit == "group";</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="238.42795"
|
||||
id="tspan4016"> for (var first = true;; first = false) {</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="257.17795"
|
||||
id="tspan4018"> if (dir < 0 && !moveOnce(!first)) break;</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="275.92795"
|
||||
id="tspan4020"> var cur = lineObj.text.charAt(ch) || "\n";</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="294.67795"
|
||||
id="tspan4022"> var type = isWordChar(cur) ? "w"</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="313.42795"
|
||||
id="tspan4024"> : !group ? null</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="332.17795"
|
||||
id="tspan4026"> : /\s/.test(cur) ? null</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="350.92795"
|
||||
id="tspan4028"> : "p"; // punctuation</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="247.48738"
|
||||
y="369.67795"
|
||||
id="tspan4046"> if (sawType && sawType</tspan></text>
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 374.84375 136.8125 C 371.96854 136.71001 368.64305 137.97919 365.15625 142.03125 C 361.97051 140.84608 359.22347 140.35622 356.84375 140.375 C 346.53162 140.4564 343.3125 149.71875 343.3125 149.71875 C 326.2234 146.67934 325.625 162.59375 325.625 162.59375 C 309.43195 163.37101 312.4375 177.375 312.4375 177.375 C 295.67899 180.15651 301.1875 194 301.1875 194 C 284.10838 199.04575 293.4375 212.46875 293.4375 212.46875 C 293.4375 212.46875 277.68174 220.31271 288.1875 232.25 C 288.1875 232.25 273.81776 243.63282 285.90625 253.34375 C 285.90625 253.34375 271.57897 263.97487 286.40625 275.03125 C 286.40625 275.03125 273.84147 285.48036 289.96875 295.3125 C 289.96875 295.3125 278.92374 306.07108 295.59375 314.65625 C 295.59375 314.65625 287.70844 329.01862 305.96875 335.125 C 305.96875 335.125 300.47495 348.88874 319.09375 351.46875 C 319.09375 351.46875 315.90162 357.19564 321.59375 361.15625 C 321.59375 361.15625 310.04416 364.78661 312.5625 374.40625 C 313.83361 379.26171 316.82684 380.49158 323.53125 380.1875 C 323.53125 380.1875 329.096 395.54812 350.46875 398.96875 L 353.125 402.59375 C 353.125 402.59375 342.80592 409.64088 359.125 421.5 C 359.125 421.5 354.16126 425.74314 363.28125 433.34375 C 363.28125 433.34375 357.54117 438.3362 365.75 442.625 C 365.75 442.625 361.35822 445.96166 366.09375 448.125 C 366.09375 448.125 370.88293 490.18262 355.40625 534.4375 C 355.40625 534.4375 341.28721 542.04782 350.1875 556.96875 C 350.1875 556.96875 331.59675 562.24093 345.09375 575.53125 C 345.09375 575.53125 342.0547 585.56155 349.375 585.78125 C 349.375 585.78125 346.16048 592.54552 354.4375 594.5625 C 354.4375 594.5625 353.17883 603.88113 364.09375 602.1875 C 369.44813 608.40994 378.92733 608.70518 385.21875 602.34375 C 396.13361 604.03738 394.875 594.71875 394.875 594.71875 C 403.15197 592.70177 399.9375 585.9375 399.9375 585.9375 C 407.25781 585.7178 404.21875 575.6875 404.21875 575.6875 C 417.71573 562.39718 399.125 557.09375 399.125 557.09375 C 408.0253 542.17282 393.90625 534.5625 393.90625 534.5625 C 378.42953 490.30762 383.21875 448.28125 383.21875 448.28125 C 387.95421 446.11791 383.5625 442.78125 383.5625 442.78125 C 391.77129 438.49245 386.03125 433.5 386.03125 433.5 C 395.15125 425.89939 390.1875 421.65625 390.1875 421.65625 C 406.5066 409.79713 396.1875 402.75 396.1875 402.75 L 398.84375 399.125 C 420.21649 395.70437 425.78125 380.34375 425.78125 380.34375 C 432.48566 380.64783 435.47889 379.41796 436.75 374.5625 C 439.26834 364.94286 427.75 361.3125 427.75 361.3125 C 433.44213 357.35188 430.21875 351.59375 430.21875 351.59375 C 448.83755 349.01373 443.34375 335.28125 443.34375 335.28125 C 461.60406 329.17487 453.71875 314.78125 453.71875 314.78125 C 470.38876 306.19608 459.34375 295.46875 459.34375 295.46875 C 475.47103 285.63661 462.90625 275.1875 462.90625 275.1875 C 477.73353 264.13112 463.40625 253.5 463.40625 253.5 C 475.49474 243.78907 461.15625 232.375 461.15625 232.375 C 471.66201 220.43771 455.875 212.625 455.875 212.625 C 455.875 212.625 465.20411 199.202 448.125 194.15625 C 448.125 194.15625 453.66476 180.31276 436.90625 177.53125 C 436.90625 177.53125 439.88054 163.52726 423.6875 162.75 C 423.6875 162.75 423.0891 146.8356 406 149.875 C 406 149.875 401.14687 135.83532 384.15625 142.15625 C 384.15625 142.15625 380.33279 137.00815 374.84375 136.8125 z M 375.34375 155 C 416.3488 155 449.59375 201.78944 449.59375 259.53125 C 449.59375 317.27306 416.3488 364.09375 375.34375 364.09375 C 334.3387 364.09375 301.09375 317.27306 301.09375 259.53125 C 301.09375 201.78944 334.3387 155 375.34375 155 z "
|
||||
id="rect3058" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4207"
|
||||
y="491.91403"
|
||||
x="149.69542"
|
||||
style="font-size:95px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#a21313;fill-opacity:1;stroke:none;font-family:Source Sans;-inkscape-font-specification:Source Sans"
|
||||
xml:space="preserve"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90"><tspan
|
||||
y="491.91403"
|
||||
x="149.69542"
|
||||
id="tspan4209"
|
||||
sodipodi:role="line">Code Mirror</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 8.8 KiB |
|
|
@ -1,931 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Release History</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="docs.css">
|
||||
<script src="activebookmark.js"></script>
|
||||
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Home</a>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a class=active data-default="true" href="#v4">Version 4.x</a>
|
||||
<li><a href="#v3">Version 3.x</a>
|
||||
<li><a href="#v2">Version 2.x</a>
|
||||
<li><a href="#v1">Version 0.x</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
|
||||
<h2>Release notes and version history</h2>
|
||||
|
||||
<section id=v4 class=first>
|
||||
|
||||
<h2>Version 4.x</h2>
|
||||
|
||||
<p class="rel">19-09-2014: <a href="http://codemirror.net/codemirror-4.6.zip">Version 4.6</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/modelica/index.html">Modelica</a></li>
|
||||
<li>New method: <a href="manual.html#findWordAt"><code>findWordAt</code></a></li>
|
||||
<li>Make it easier to <a href="../demo/markselection.html">use text background styling</a></li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.5.0...4.6.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-08-2014: <a href="http://codemirror.net/codemirror-4.5.zip">Version 4.5</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Fix several serious bugs with horizontal scrolling</li>
|
||||
<li>New mode: <a href="../mode/slim/index.html">Slim</a></li>
|
||||
<li>New command: <a href="manual.html#command_goLineLeftSmart"><code>goLineLeftSmart</code></a></li>
|
||||
<li>More fixes and extensions for the <a href="../demo/vim.html">Vim</a> visual block mode</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.4.0...4.5.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-07-2014: <a href="http://codemirror.net/codemirror-4.4.zip">Version 4.4</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><strong>Note:</strong> Some events might now fire in slightly
|
||||
different order (<code>"change"</code> is still guaranteed to fire
|
||||
before <code>"cursorActivity"</code>)</li>
|
||||
<li>Nested operations in multiple editors are now synced (complete
|
||||
at same time, reducing DOM reflows)</li>
|
||||
<li>Visual block mode for <a href="../demo/vim.html">vim</a> (<C-v>) is nearly complete</li>
|
||||
<li>New mode: <a href="../mode/kotlin/index.html">Kotlin</a></li>
|
||||
<li>Better multi-selection paste for text copied from multiple CodeMirror selections</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.3.0...4.4.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-06-2014: <a href="http://codemirror.net/codemirror-4.3.zip">Version 4.3</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Several <a href="../demo/vim.html">vim bindings</a>
|
||||
improvements: search and exCommand history, global flag
|
||||
for <code>:substitute</code>, <code>:global</code> command.
|
||||
<li>Allow hiding the cursor by
|
||||
setting <a href="manual.html#option_cursorBlinkRate"><code>cursorBlinkRate</code></a>
|
||||
to a negative value.</li>
|
||||
<li>Make gutter markers themeable, use this in foldgutter.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.2.0...4.3.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">19-05-2014: <a href="http://codemirror.net/codemirror-4.2.zip">Version 4.2</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Fix problem where some modes were broken by the fact that empty tokens were forbidden.</li>
|
||||
<li>Several fixes to context menu handling.</li>
|
||||
<li>On undo, scroll <em>change</em>, not cursor, into view.</li>
|
||||
<li>Rewritten <a href="../mode/jade/index.html">Jade</a> mode.</li>
|
||||
<li>Various improvements to <a href="../mode/shell/index.html">Shell</a> (support for more syntax) and <a href="../mode/python/index.html">Python</a> (better indentation) modes.</li>
|
||||
<li>New mode: <a href="../mode/cypher/index.html">Cypher</a>.</li>
|
||||
<li>New theme: <a href="../demo/theme.html?neo">Neo</a>.</li>
|
||||
<li>Support direct styling options (color, line style, width) in the <a href="manual.html#addon_rulers">rulers</a> addon.</li>
|
||||
<li>Recognize per-editor configuration for the <a href="manual.html#addon_show-hint">show-hint</a> and <a href="manual.html#addon_foldcode">foldcode</a> addons.</li>
|
||||
<li>More intelligent scanning for existing close tags in <a href="manual.html#addon_closetag">closetag</a> addon.</li>
|
||||
<li>In the <a href="../demo/vim.html">Vim bindings</a>: Fix bracket matching, support case conversion in visual mode, visual paste, append action.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.1.0...4.2.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">22-04-2014: <a href="http://codemirror.net/codemirror-4.1.zip">Version 4.1</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><em>Slightly incompatible</em>:
|
||||
The <a href="manual.html#event_cursorActivity"><code>"cursorActivity"</code></a>
|
||||
event now fires after all other events for the operation (and only
|
||||
for handlers that were actually registered at the time the
|
||||
activity happened).</li>
|
||||
<li>New command: <a href="manual.html#command_insertSoftTab"><code>insertSoftTab</code></a>.</li>
|
||||
<li>New mode: <a href="../mode/django/index.html">Django</a>.</li>
|
||||
<li>Improved modes: <a href="../mode/verilog/index.html">Verilog</a> (rewritten), <a href="../mode/jinja2/index.html">Jinja2</a>, <a href="../mode/haxe/index.html">Haxe</a>, <a href="../mode/php/index.html">PHP</a> (string interpolation highlighted), <a href="../mode/javascript/index.html">JavaScript</a> (indentation of trailing else, template strings), <a href="../mode/livescript/index.html">LiveScript</a> (multi-line strings).</li>
|
||||
<li>Many small issues from the 3.x→4.x transition were found and fixed.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/4.0.3...4.1.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-03-2014: <a href="http://codemirror.net/codemirror-4.0.zip">Version 4.0</a>:</p>
|
||||
|
||||
<p class="rel-note">This is a new major version of CodeMirror. There
|
||||
are a few <strong>incompatible</strong> changes in the API. Upgrade
|
||||
with care, and read the <a href="upgrade_v4.html">upgrading
|
||||
guide</a>.</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Multiple selections (ctrl-click, alt-drag, <a href="manual.html#setSelections">API</a>).</li>
|
||||
<li>Sublime Text <a href="../demo/sublime.html">bindings</a>.</li>
|
||||
<li><a href="manual.html#modloader">Module loader shims</a> wrapped around all modules.</li>
|
||||
<li>Selection <a href="manual.html#command_undoSelection">undo</a>/<a href="manual.html#command_redoSelection">redo</a>.</li>
|
||||
<li>Improved character measuring (faster, handles wrapped lines more robustly).</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.23.0...4.0.3">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section id=v3>
|
||||
|
||||
<h2>Version 3.x</h2>
|
||||
|
||||
<p class="rel">22-04-2014: <a href="http://codemirror.net/codemirror-3.24.zip">Version 3.24</a>:</p>
|
||||
|
||||
<p class="rel-note">Merges the improvements from 4.1 that could
|
||||
easily be applied to the 3.x code. Also improves the way the editor
|
||||
size is updated when line widgets change.</p>
|
||||
|
||||
<p class="rel">20-03-2014: <a href="http://codemirror.net/codemirror-3.23.zip">Version 3.23</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>In the <a href="../mode/xml/index.html">XML mode</a>,
|
||||
add <code>brackets</code> style to angle brackets, fix
|
||||
case-sensitivity of tags for HTML.</li>
|
||||
<li>New mode: <a href="../mode/dylan/index.html">Dylan</a>.</li>
|
||||
<li>Many improvements to the <a href="../demo/vim.html">Vim bindings</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-02-2014: <a href="http://codemirror.net/codemirror-3.22.zip">Version 3.22</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Adds the <a href="manual.html#findMarks"><code>findMarks</code></a> method.</li>
|
||||
<li>New addons: <a href="manual.html#addon_rulers">rulers</a>, markdown-fold, yaml-lint.</li>
|
||||
<li>New theme: <a href="../demo/theme.html?mdn-like">mdn-like</a>.</li>
|
||||
<li>New mode: <a href="../mode/solr/index.html">Solr</a>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.21.0...3.22.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">16-01-2014: <a href="http://codemirror.net/codemirror-3.21.zip">Version 3.21</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Auto-indenting a block will no longer add trailing whitespace to blank lines.</a>
|
||||
<li>Marking text has a new option <a href="manual.html#markText"><code>clearWhenEmpty</code></a> to control auto-removal.</li>
|
||||
<li>Several bugfixes in the handling of bidirectional text.</li>
|
||||
<li>The <a href="../mode/xml/index.html">XML</a> and <a href="../mode/css/index.html">CSS</a> modes were largely rewritten. <a href="../mode/css/less.html">LESS</a> support was added to the CSS mode.</li>
|
||||
<li>The OCaml mode was moved to an <a href="../mode/mllike/index.html">mllike</a> mode, F# support added.</li>
|
||||
<li>Make it possible to fetch multiple applicable helper values with <a href="manual.html#getHelpers"><code>getHelpers</code></a>, and to register helpers matched on predicates with <a href="manual.html#registerGlobalHelper"><code>registerGlobalHelper</code></a>.</li>
|
||||
<li>New theme <a href="../demo/theme.html?pastel-on-dark">pastel-on-dark</a>.</li>
|
||||
<li>Better ECMAScript 6 support in <a href="../mode/javascript/index.html">JavaScript</a> mode.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.20.0...3.21.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-11-2013: <a href="http://codemirror.net/codemirror-3.20.zip">Version 3.20</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/julia/index.html">Julia</a> and <a href="../mode/pegjs/index.html">PEG.js</a>.</li>
|
||||
<li>Support ECMAScript 6 in the <a href="../mode/javascript/index.html">JavaScript mode</a>.</li>
|
||||
<li>Improved indentation for the <a href="../mode/coffeescript/index.html">CoffeeScript mode</a>.</li>
|
||||
<li>Make non-printable-character representation <a href="manual.html#option_specialChars">configurable</a>.</li>
|
||||
<li>Add ‘notification’ functionality to <a href="manual.html#addon_dialog">dialog</a> addon.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.19.0...3.20.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-10-2013: <a href="http://codemirror.net/codemirror-3.19.zip">Version 3.19</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/eiffel/index.html">Eiffel</a>, <a href="../mode/gherkin/index.html">Gherkin</a>, <a href="../mode/sql/?mime=text/x-mssql">MSSQL dialect</a>.</li>
|
||||
<li>New addons: <a href="manual.html#addon_hardwrap">hardwrap</a>, <a href="manual.html#addon_sql-hint">sql-hint</a>.</li>
|
||||
<li>New theme: <a href="../demo/theme.html?mbo">MBO</a>.</li>
|
||||
<li>Add <a href="manual.html#token_style_line">support</a> for line-level styling from mode tokenizers.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.18.0...3.19.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-09-2013: <a href="http://codemirror.net/codemirror-3.18.zip">Version 3.18</a>:</p>
|
||||
|
||||
<p class="rel-note">Emergency release to fix a problem in 3.17
|
||||
where <code>.setOption("lineNumbers", false)</code> would raise an
|
||||
error.</p>
|
||||
|
||||
<p class="rel">23-09-2013: <a href="http://codemirror.net/codemirror-3.17.zip">Version 3.17</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/fortran/index.html">Fortran</a>, <a href="../mode/octave/index.html">Octave</a> (Matlab), <a href="../mode/toml/index.html">TOML</a>, and <a href="../mode/dtd/index.html">DTD</a>.</li>
|
||||
<li>New addons: <a href="../addon/lint/css-lint.js"><code>css-lint</code></a>, <a href="manual.html#addon_css-hint"><code>css-hint</code></a>.</li>
|
||||
<li>Improve resilience to CSS 'frameworks' that globally mess up <code>box-sizing</code>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.16.0...3.17.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-08-2013: <a href="http://codemirror.net/codemirror-3.16.zip">Version 3.16</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>The whole codebase is now under a single <a href="../LICENSE">license</a> file.</li>
|
||||
<li>The project page was overhauled and redesigned.</li>
|
||||
<li>New themes: <a href="../demo/theme.html?paraiso-dark">Paraiso</a> (<a href="../demo/theme.html?paraiso-light">light</a>), <a href="../demo/theme.html?the-matrix">The Matrix</a>.</li>
|
||||
<li>Improved interaction between themes and <a href="manual.html#addon_active-line">active-line</a>/<a href="manual.html#addon_matchbrackets">matchbrackets</a> addons.</li>
|
||||
<li>New <a href="manual.html#addon_foldcode">folding</a> function <code>CodeMirror.fold.comment</code>.</li>
|
||||
<li>Added <a href="manual.html#addon_fullscreen">fullscreen</a> addon.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.15.0...3.16.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">29-07-2013: <a href="http://codemirror.net/codemirror-3.15.zip">Version 3.15</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/jade/index.html">Jade</a>, <a href="../mode/nginx/index.html">Nginx</a>.</li>
|
||||
<li>New addons: <a href="../demo/tern.html">Tern</a>, <a href="manual.html#addon_matchtags">matchtags</a>, and <a href="manual.html#addon_foldgutter">foldgutter</a>.</li>
|
||||
<li>Introduced <a href="manual.html#getHelper"><em>helper</em></a> concept (<a href="https://groups.google.com/forum/#!msg/codemirror/cOc0xvUUEUU/nLrX1-qnidgJ">context</a>).</li>
|
||||
<li>New method: <a href="manual.html#getModeAt"><code>getModeAt</code></a>.</li>
|
||||
<li>New themes: base16 <a href="../demo/theme.html?base16-dark">dark</a>/<a href="../demo/theme.html?base16-light">light</a>, 3024 <a href="../demo/theme.html?3024-night">dark</a>/<a href="../demo/theme.html?3024-day">light</a>, <a href="../demo/theme.html?tomorrow-night-eighties">tomorrow-night</a>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.14.0...3.15.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-06-2013: <a href="http://codemirror.net/codemirror-3.14.zip">Version 3.14</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New
|
||||
addons: <a href="manual.html#addon_trailingspace">trailing
|
||||
space highlight</a>, <a href="manual.html#addon_xml-hint">XML
|
||||
completion</a> (rewritten),
|
||||
and <a href="manual.html#addon_merge">diff merging</a>.</li>
|
||||
<li><a href="manual.html#markText"><code>markText</code></a>
|
||||
and <a href="manual.html#addLineWidget"><code>addLineWidget</code></a>
|
||||
now take a <code>handleMouseEvents</code> option.</li>
|
||||
<li>New methods: <a href="manual.html#lineAtHeight"><code>lineAtHeight</code></a>,
|
||||
<a href="manual.html#getTokenTypeAt"><code>getTokenTypeAt</code></a>.</li>
|
||||
<li>More precise cleanness-tracking
|
||||
using <a href="manual.html#changeGeneration"><code>changeGeneration</code></a>
|
||||
and <a href="manual.html#isClean"><code>isClean</code></a>.</li>
|
||||
<li>Many extensions to <a href="../demo/emacs.html">Emacs</a> mode
|
||||
(prefixes, more navigation units, and more).</li>
|
||||
<li>New
|
||||
events <a href="manual.html#event_keyHandled"><code>"keyHandled"</code></a>
|
||||
and <a href="manual.html#event_inputRead"><code>"inputRead"</code></a>.</li>
|
||||
<li>Various improvements to <a href="../mode/ruby/index.html">Ruby</a>,
|
||||
<a href="../mode/smarty/index.html">Smarty</a>, <a href="../mode/sql/index.html">SQL</a>,
|
||||
and <a href="../demo/vim.html">Vim</a> modes.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/3.13.0...3.14.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-05-2013: <a href="http://codemirror.net/codemirror-3.13.zip">Version 3.13</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/cobol/index.html">COBOL</a> and <a href="../mode/haml/index.html">HAML</a>.</li>
|
||||
<li>New options: <a href="manual.html#option_cursorScrollMargin"><code>cursorScrollMargin</code></a> and <a href="manual.html#option_coverGutterNextToScrollbar"><code>coverGutterNextToScrollbar</code></a>.</li>
|
||||
<li>New addon: <a href="manual.html#addon_comment">commenting</a>.</li>
|
||||
<li>More features added to the <a href="../demo/vim.html">Vim keymap</a>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.12...3.13.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">19-04-2013: <a href="http://codemirror.net/codemirror-3.12.zip">Version 3.12</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/gas/index.html">GNU assembler</a>.</li>
|
||||
<li>New
|
||||
options: <a href="manual.html#option_maxHighlightLength"><code>maxHighlightLength</code></a>
|
||||
and <a href="manual.html#option_historyEventDelay"><code>historyEventDelay</code></a>.</li>
|
||||
<li>Added <a href="manual.html#mark_addToHistory"><code>addToHistory</code></a>
|
||||
option for <code>markText</code>.</li>
|
||||
<li>Various fixes to JavaScript tokenization and indentation corner cases.</li>
|
||||
<li>Further improvements to the vim mode.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.11...v3.12">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-03-2013: <a href="http://codemirror.net/codemirror-3.11.zip">Version 3.11</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><strong>Removed code:</strong> <code>collapserange</code>,
|
||||
<code>formatting</code>, and <code>simple-hint</code>
|
||||
addons. <code>plsql</code> and <code>mysql</code> modes
|
||||
(use <a href="../mode/sql/index.html"><code>sql</code></a> mode).</li>
|
||||
<li><strong>Moved code:</strong> the range-finding functions for folding now have <a href="../addon/fold/">their own files</a>.</li>
|
||||
<li><strong>Changed interface:</strong>
|
||||
the <a href="manual.html#addon_continuecomment"><code>continuecomment</code></a>
|
||||
addon now exposes an option, rather than a command.</li>
|
||||
<li>New
|
||||
modes: <a href="../mode/css/scss.html">SCSS</a>, <a href="../mode/tcl/index.html">Tcl</a>, <a href="../mode/livescript/index.html">LiveScript</a>,
|
||||
and <a href="../mode/mirc/index.html">mIRC</a>.</li>
|
||||
<li>New addons: <a href="../demo/placeholder.html"><code>placeholder</code></a>, <a href="../demo/html5complete.html">HTML completion</a>.</li>
|
||||
<li>New
|
||||
methods: <a href="manual.html#hasFocus"><code>hasFocus</code></a>, <a href="manual.html#defaultCharWidth"><code>defaultCharWidth</code></a>.</li>
|
||||
<li>New events: <a href="manual.html#event_beforeCursorEnter"><code>beforeCursorEnter</code></a>, <a href="manual.html#event_renderLine"><code>renderLine</code></a>.</li>
|
||||
<li>Many improvements to the <a href="manual.html#addon_show-hint"><code>show-hint</code></a> completion
|
||||
dialog addon.</li>
|
||||
<li>Tweak behavior of by-word cursor motion.</li>
|
||||
<li>Further improvements to the <a href="../demo/vim.html">vim mode</a>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.1...v3.11">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-02-2013: <a href="http://codemirror.net/codemirror-3.1.zip">Version 3.1</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><strong>Incompatible:</strong> key handlers may
|
||||
now <em>return</em>, rather
|
||||
than <em>throw</em> <code>CodeMirror.Pass</code> to signal they
|
||||
didn't handle the key.</li>
|
||||
<li>Make documents a <a href="manual.html#api_doc">first-class
|
||||
construct</a>, support split views and subviews.</li>
|
||||
<li>Add a <a href="manual.html#addon_show-hint">new module</a>
|
||||
for showing completion hints.
|
||||
Deprecate <code>simple-hint.js</code>.</li>
|
||||
<li>Extend <a href="../mode/htmlmixed/index.html">htmlmixed mode</a>
|
||||
to allow custom handling of script types.</li>
|
||||
<li>Support an <code>insertLeft</code> option
|
||||
to <a href="manual.html#setBookmark"><code>setBookmark</code></a>.</li>
|
||||
<li>Add an <a href="manual.html#eachLine"><code>eachLine</code></a>
|
||||
method to iterate over a document.</li>
|
||||
<li>New addon modules: <a href="../demo/markselection.html">selection
|
||||
marking</a>, <a href="../demo/lint.html">linting</a>,
|
||||
and <a href="../demo/closebrackets.html">automatic bracket
|
||||
closing</a>.</li>
|
||||
<li>Add <a href="manual.html#event_beforeChange"><code>"beforeChange"</code></a>
|
||||
and <a href="manual.html#event_beforeSelectionChange"><code>"beforeSelectionChange"</code></a>
|
||||
events.</li>
|
||||
<li>Add <a href="manual.html#event_hide"><code>"hide"</code></a>
|
||||
and <a href="manual.html#event_unhide"><code>"unhide"</code></a>
|
||||
events to marked ranges.</li>
|
||||
<li>Fix <a href="manual.html#coordsChar"><code>coordsChar</code></a>'s
|
||||
interpretation of its argument to match the documentation.</li>
|
||||
<li>New modes: <a href="../mode/turtle/index.html">Turtle</a>
|
||||
and <a href="../mode/q/index.html">Q</a>.</li>
|
||||
<li>Further improvements to the <a href="../demo/vim.html">vim mode</a>.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.01...v3.1">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p class="rel">25-01-2013: <a href="http://codemirror.net/codemirror-3.02.zip">Version 3.02</a>:</p>
|
||||
|
||||
<p class="rel-note">Single-bugfix release. Fixes a problem that
|
||||
prevents CodeMirror instances from being garbage-collected after
|
||||
they become unused.</p>
|
||||
|
||||
<p class="rel">21-01-2013: <a href="http://codemirror.net/codemirror-3.01.zip">Version 3.01</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Move all add-ons into an organized directory structure
|
||||
under <a href="../addon/"><code>/addon</code></a>. <strong>You might have to adjust your
|
||||
paths.</strong></li>
|
||||
<li>New
|
||||
modes: <a href="../mode/d/index.html">D</a>, <a href="../mode/sass/index.html">Sass</a>, <a href="../mode/apl/index.html">APL</a>, <a href="../mode/sql/index.html">SQL</a>
|
||||
(configurable), and <a href="../mode/asterisk/index.html">Asterisk</a>.</li>
|
||||
<li>Several bugfixes in right-to-left text support.</li>
|
||||
<li>Add <a href="manual.html#option_rtlMoveVisually"><code>rtlMoveVisually</code></a> option.</li>
|
||||
<li>Improvements to vim keymap.</li>
|
||||
<li>Add built-in (lightweight) <a href="manual.html#addOverlay">overlay mode</a> support.</li>
|
||||
<li>Support <code>showIfHidden</code> option for <a href="manual.html#addLineWidget">line widgets</a>.</li>
|
||||
<li>Add simple <a href="manual.html#addon_python-hint">Python hinter</a>.</li>
|
||||
<li>Bring back the <a href="manual.html#option_fixedGutter"><code>fixedGutter</code></a> option.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0...v3.01">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">10-12-2012: <a href="http://codemirror.net/codemirror-3.0.zip">Version 3.0</a>:</p>
|
||||
|
||||
<p class="rel-note"><strong>New major version</strong>. Only
|
||||
partially backwards-compatible. See
|
||||
the <a href="upgrade_v3.html">upgrading guide</a> for more
|
||||
information. Changes since release candidate 2:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Rewritten VIM mode.</li>
|
||||
<li>Fix a few minor scrolling and sizing issues.</li>
|
||||
<li>Work around Safari segfault when dragging.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0rc2...v3.0">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc2.zip">Version 3.0, release candidate 2</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/http/index.html">HTTP</a>.</li>
|
||||
<li>Improved handling of selection anchor position.</li>
|
||||
<li>Improve IE performance on longer lines.</li>
|
||||
<li>Reduce gutter glitches during horiz. scrolling.</li>
|
||||
<li>Add <a href="manual.html#addKeyMap"><code>addKeyMap</code></a> and <a href="manual.html#removeKeyMap"><code>removeKeyMap</code></a> methods.</li>
|
||||
<li>Rewrite <code>formatting</code> and <code>closetag</code> add-ons.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0rc1...v3.0rc2">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc1.zip">Version 3.0, release candidate 1</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New theme: <a href="../demo/theme.html?solarized%20light">Solarized</a>.</li>
|
||||
<li>Introduce <a href="manual.html#addLineClass"><code>addLineClass</code></a>
|
||||
and <a href="manual.html#removeLineClass"><code>removeLineClass</code></a>,
|
||||
drop <code>setLineClass</code>.</li>
|
||||
<li>Add a <em>lot</em> of
|
||||
new <a href="manual.html#markText">options for marked text</a>
|
||||
(read-only, atomic, collapsed, widget replacement).</li>
|
||||
<li>Remove the old code folding interface in favour of these new ranges.</li>
|
||||
<li>Add <a href="manual.html#isClean"><code>isClean</code></a>/<a href="manual.html#markClean"><code>markClean</code></a> methods.</li>
|
||||
<li>Remove <code>compoundChange</code> method, use better undo-event-combining heuristic.</li>
|
||||
<li>Improve scrolling performance smoothness.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta2...v3.0rc1">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-3.0beta2.zip">Version 3.0, beta 2</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Fix page-based coordinate computation.</li>
|
||||
<li>Fix firing of <a href="manual.html#event_gutterClick"><code>gutterClick</code></a> event.</li>
|
||||
<li>Add <a href="manual.html#option_cursorHeight"><code>cursorHeight</code></a> option.</li>
|
||||
<li>Fix bi-directional text regression.</li>
|
||||
<li>Add <a href="manual.html#option_viewportMargin"><code>viewportMargin</code></a> option.</li>
|
||||
<li>Directly handle mousewheel events (again, hopefully better).</li>
|
||||
<li>Make vertical cursor movement more robust (through widgets, big line gaps).</li>
|
||||
<li>Add <a href="manual.html#option_flattenSpans"><code>flattenSpans</code></a> option.</li>
|
||||
<li>Many optimizations. Poor responsiveness should be fixed.</li>
|
||||
<li>Initialization in hidden state works again.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta1...v3.0beta2">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-3.0beta1.zip">Version 3.0, beta 1</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Bi-directional text support.</li>
|
||||
<li>More powerful gutter model.</li>
|
||||
<li>Support for arbitrary text/widget height.</li>
|
||||
<li>In-line widgets.</li>
|
||||
<li>Generalized event handling.</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section id=v2>
|
||||
|
||||
<h2>Version 2.x</h2>
|
||||
|
||||
<p class="rel">21-01-2013: <a href="http://codemirror.net/codemirror-2.38.zip">Version 2.38</a>:</p>
|
||||
|
||||
<p class="rel-note">Integrate some bugfixes, enhancements to the vim keymap, and new
|
||||
modes
|
||||
(<a href="../mode/d/index.html">D</a>, <a href="../mode/sass/index.html">Sass</a>, <a href="../mode/apl/index.html">APL</a>)
|
||||
from the v3 branch.</p>
|
||||
|
||||
<p class="rel">20-12-2012: <a href="http://codemirror.net/codemirror-2.37.zip">Version 2.37</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/sql/index.html">SQL</a> (will replace <a href="../mode/plsql/index.html">plsql</a> and <a href="../mode/mysql/index.html">mysql</a> modes).</li>
|
||||
<li>Further work on the new VIM mode.</li>
|
||||
<li>Fix Cmd/Ctrl keys on recent Operas on OS X.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.36...v2.37">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-2.36.zip">Version 2.36</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/z80/index.html">Z80 assembly</a>.</li>
|
||||
<li>New theme: <a href="../demo/theme.html?twilight">Twilight</a>.</li>
|
||||
<li>Add command-line compression helper.</li>
|
||||
<li>Make <a href="manual.html#scrollIntoView"><code>scrollIntoView</code></a> public.</li>
|
||||
<li>Add <a href="manual.html#defaultTextHeight"><code>defaultTextHeight</code></a> method.</li>
|
||||
<li>Various extensions to the vim keymap.</li>
|
||||
<li>Make <a href="../mode/php/index.html">PHP mode</a> build on <a href="../mode/htmlmixed/index.html">mixed HTML mode</a>.</li>
|
||||
<li>Add <a href="manual.html#addon_continuecomment">comment-continuing</a> add-on.</li>
|
||||
<li>Full <a href="../https://github.com/marijnh/CodeMirror/compare/v2.35...v2.36">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-2.35.zip">Version 2.35</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New (sub) mode: <a href="../mode/javascript/typescript.html">TypeScript</a>.</li>
|
||||
<li>Don't overwrite (insert key) when pasting.</li>
|
||||
<li>Fix several bugs in <a href="manual.html#markText"><code>markText</code></a>/undo interaction.</li>
|
||||
<li>Better indentation of JavaScript code without semicolons.</li>
|
||||
<li>Add <a href="manual.html#defineInitHook"><code>defineInitHook</code></a> function.</li>
|
||||
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.34...v2.35">list of patches</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-2.34.zip">Version 2.34</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/commonlisp/index.html">Common Lisp</a>.</li>
|
||||
<li>Fix right-click select-all on most browsers.</li>
|
||||
<li>Change the way highlighting happens:<br> Saves memory and CPU cycles.<br> <code>compareStates</code> is no longer needed.<br> <code>onHighlightComplete</code> no longer works.</li>
|
||||
<li>Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.</li>
|
||||
<li>Add a <a href="manual.html#version"><code>CodeMirror.version</code></a> property.</li>
|
||||
<li>More robust handling of nested modes in <a href="../demo/formatting.html">formatting</a> and <a href="../demo/closetag.html">closetag</a> plug-ins.</li>
|
||||
<li>Un/redo now preserves <a href="manual.html#markText">marked text</a> and bookmarks.</li>
|
||||
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.33...v2.34">Full list</a> of patches.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-08-2012: <a href="http://codemirror.net/codemirror-2.33.zip">Version 2.33</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/sieve/index.html">Sieve</a>.</li>
|
||||
<li>New <a href="manual.html#getViewport"><code>getViewPort</code></a> and <a href="manual.html#option_onViewportChange"><code>onViewportChange</code></a> API.</li>
|
||||
<li><a href="manual.html#option_cursorBlinkRate">Configurable</a> cursor blink rate.</li>
|
||||
<li>Make binding a key to <code>false</code> disabling handling (again).</li>
|
||||
<li>Show non-printing characters as red dots.</li>
|
||||
<li>More tweaks to the scrolling model.</li>
|
||||
<li>Expanded testsuite. Basic linter added.</li>
|
||||
<li>Remove most uses of <code>innerHTML</code>. Remove <code>CodeMirror.htmlEscape</code>.</li>
|
||||
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.32...v2.33">Full list</a> of patches.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-07-2012: <a href="http://codemirror.net/codemirror-2.32.zip">Version 2.32</a>:</p>
|
||||
|
||||
<p class="rel-note">Emergency fix for a bug where an editor with
|
||||
line wrapping on IE will break when there is <em>no</em>
|
||||
scrollbar.</p>
|
||||
|
||||
<p class="rel">20-07-2012: <a href="http://codemirror.net/codemirror-2.31.zip">Version 2.31</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New modes: <a href="../mode/ocaml/index.html">OCaml</a>, <a href="../mode/haxe/index.html">Haxe</a>, and <a href="../mode/vb/index.html">VB.NET</a>.</li>
|
||||
<li>Several fixes to the new scrolling model.</li>
|
||||
<li>Add a <a href="manual.html#setSize"><code>setSize</code></a> method for programmatic resizing.</li>
|
||||
<li>Add <a href="manual.html#getHistory"><code>getHistory</code></a> and <a href="manual.html#setHistory"><code>setHistory</code></a> methods.</li>
|
||||
<li>Allow custom line separator string in <a href="manual.html#getValue"><code>getValue</code></a> and <a href="manual.html#getRange"><code>getRange</code></a>.</li>
|
||||
<li>Support double- and triple-click drag, double-clicking whitespace.</li>
|
||||
<li>And more... <a href="https://github.com/marijnh/CodeMirror/compare/v2.3...v2.31">(all patches)</a></li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">22-06-2012: <a href="http://codemirror.net/codemirror-2.3.zip">Version 2.3</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
|
||||
<li>New theme: <a href="../demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
|
||||
<li>Many extensions to the VIM keymap (including text objects).</li>
|
||||
<li>Add <a href="../demo/multiplex.html">mode-multiplexing</a> utility script.</li>
|
||||
<li>Fix bug where right-click paste works in read-only mode.</li>
|
||||
<li>Add a <a href="manual.html#getScrollInfo"><code>getScrollInfo</code></a> method.</li>
|
||||
<li>Lots of other <a href="https://github.com/marijnh/CodeMirror/compare/v2.25...v2.3">fixes</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-05-2012: <a href="http://codemirror.net/codemirror-2.25.zip">Version 2.25</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>New mode: <a href="../mode/erlang/index.html">Erlang</a>.</li>
|
||||
<li><strong>Remove xmlpure mode</strong> (use <a href="../mode/xml/index.html">xml.js</a>).</li>
|
||||
<li>Fix line-wrapping in Opera.</li>
|
||||
<li>Fix X Windows middle-click paste in Chrome.</li>
|
||||
<li>Fix bug that broke pasting of huge documents.</li>
|
||||
<li>Fix backspace and tab key repeat in Opera.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-04-2012: <a href="http://codemirror.net/codemirror-2.24.zip">Version 2.24</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li><strong>Drop support for Internet Explorer 6</strong>.</li>
|
||||
<li>New
|
||||
modes: <a href="../mode/shell/index.html">Shell</a>, <a href="../mode/tiki/index.html">Tiki
|
||||
wiki</a>, <a href="../mode/pig/index.html">Pig Latin</a>.</li>
|
||||
<li>New themes: <a href="../demo/theme.html?ambiance">Ambiance</a>, <a href="../demo/theme.html?blackboard">Blackboard</a>.</li>
|
||||
<li>More control over drag/drop
|
||||
with <a href="manual.html#option_dragDrop"><code>dragDrop</code></a>
|
||||
and <a href="manual.html#option_onDragEvent"><code>onDragEvent</code></a>
|
||||
options.</li>
|
||||
<li>Make HTML mode a bit less pedantic.</li>
|
||||
<li>Add <a href="manual.html#compoundChange"><code>compoundChange</code></a> API method.</li>
|
||||
<li>Several fixes in undo history and line hiding.</li>
|
||||
<li>Remove (broken) support for <code>catchall</code> in key maps,
|
||||
add <code>nofallthrough</code> boolean field instead.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">26-03-2012: <a href="http://codemirror.net/codemirror-2.23.zip">Version 2.23</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Change <strong>default binding for tab</strong> <a href="javascript:void(document.getElementById('tabbinding').style.display='')">[more]</a>
|
||||
<div style="display: none" id=tabbinding>
|
||||
Starting in 2.23, these bindings are default:
|
||||
<ul><li>Tab: Insert tab character</li>
|
||||
<li>Shift-tab: Reset line indentation to default</li>
|
||||
<li>Ctrl/Cmd-[: Reduce line indentation (old tab behaviour)</li>
|
||||
<li>Ctrl/Cmd-]: Increase line indentation (old shift-tab behaviour)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li>New modes: <a href="../mode/xquery/index.html">XQuery</a> and <a href="../mode/vbscript/index.html">VBScript</a>.</li>
|
||||
<li>Two new themes: <a href="../mode/less/index.html">lesser-dark</a> and <a href="../mode/xquery/index.html">xq-dark</a>.</li>
|
||||
<li>Differentiate between background and text styles in <a href="manual.html#setLineClass"><code>setLineClass</code></a>.</li>
|
||||
<li>Fix drag-and-drop in IE9+.</li>
|
||||
<li>Extend <a href="manual.html#charCoords"><code>charCoords</code></a>
|
||||
and <a href="manual.html#cursorCoords"><code>cursorCoords</code></a> with a <code>mode</code> argument.</li>
|
||||
<li>Add <a href="manual.html#option_autofocus"><code>autofocus</code></a> option.</li>
|
||||
<li>Add <a href="manual.html#findMarksAt"><code>findMarksAt</code></a> method.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-02-2012: <a href="http://codemirror.net/codemirror-2.22.zip">Version 2.22</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Allow <a href="manual.html#keymaps">key handlers</a> to pass up events, allow binding characters.</li>
|
||||
<li>Add <a href="manual.html#option_autoClearEmptyLines"><code>autoClearEmptyLines</code></a> option.</li>
|
||||
<li>Properly use tab stops when rendering tabs.</li>
|
||||
<li>Make PHP mode more robust.</li>
|
||||
<li>Support indentation blocks in <a href="manual.html#addon_foldcode">code folder</a>.</li>
|
||||
<li>Add a script for <a href="manual.html#addon_match-highlighter">highlighting instances of the selection</a>.</li>
|
||||
<li>New <a href="../mode/properties/index.html">.properties</a> mode.</li>
|
||||
<li>Fix many bugs.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-01-2012: <a href="http://codemirror.net/codemirror-2.21.zip">Version 2.21</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Added <a href="../mode/less/index.html">LESS</a>, <a href="../mode/mysql/index.html">MySQL</a>,
|
||||
<a href="../mode/go/index.html">Go</a>, and <a href="../mode/verilog/index.html">Verilog</a> modes.</li>
|
||||
<li>Add <a href="manual.html#option_smartIndent"><code>smartIndent</code></a>
|
||||
option.</li>
|
||||
<li>Support a cursor in <a href="manual.html#option_readOnly"><code>readOnly</code></a>-mode.</li>
|
||||
<li>Support assigning multiple styles to a token.</li>
|
||||
<li>Use a new approach to drawing the selection.</li>
|
||||
<li>Add <a href="manual.html#scrollTo"><code>scrollTo</code></a> method.</li>
|
||||
<li>Allow undo/redo events to span non-adjacent lines.</li>
|
||||
<li>Lots and lots of bugfixes.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-12-2011: <a href="http://codemirror.net/codemirror-2.2.zip">Version 2.2</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Slightly incompatible API changes. Read <a href="upgrade_v2.2.html">this</a>.</li>
|
||||
<li>New approach
|
||||
to <a href="manual.html#option_extraKeys">binding</a> keys,
|
||||
support for <a href="manual.html#option_keyMap">custom
|
||||
bindings</a>.</li>
|
||||
<li>Support for overwrite (insert).</li>
|
||||
<li><a href="manual.html#option_tabSize">Custom-width</a>
|
||||
and <a href="../demo/visibletabs.html">stylable</a> tabs.</li>
|
||||
<li>Moved more code into <a href="manual.html#addons">add-on scripts</a>.</li>
|
||||
<li>Support for sane vertical cursor movement in wrapped lines.</li>
|
||||
<li>More reliable handling of
|
||||
editing <a href="manual.html#markText">marked text</a>.</li>
|
||||
<li>Add minimal <a href="../demo/emacs.html">emacs</a>
|
||||
and <a href="../demo/vim.html">vim</a> bindings.</li>
|
||||
<li>Rename <code>coordsFromIndex</code>
|
||||
to <a href="manual.html#posFromIndex"><code>posFromIndex</code></a>,
|
||||
add <a href="manual.html#indexFromPos"><code>indexFromPos</code></a>
|
||||
method.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-11-2011: <a href="http://codemirror.net/codemirror-2.18.zip">Version 2.18</a>:</p>
|
||||
<p class="rel-note">Fixes <code>TextMarker.clear</code>, which is broken in 2.17.</p>
|
||||
|
||||
<p class="rel">21-11-2011: <a href="http://codemirror.net/codemirror-2.17.zip">Version 2.17</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add support for <a href="manual.html#option_lineWrapping">line
|
||||
wrapping</a> and <a href="manual.html#hideLine">code
|
||||
folding</a>.</li>
|
||||
<li>Add <a href="../mode/gfm/index.html">Github-style Markdown</a> mode.</li>
|
||||
<li>Add <a href="../theme/monokai.css">Monokai</a>
|
||||
and <a href="../theme/rubyblue.css">Rubyblue</a> themes.</li>
|
||||
<li>Add <a href="manual.html#setBookmark"><code>setBookmark</code></a> method.</li>
|
||||
<li>Move some of the demo code into reusable components
|
||||
under <a href="../addon/"><code>lib/util</code></a>.</li>
|
||||
<li>Make screen-coord-finding code faster and more reliable.</li>
|
||||
<li>Fix drag-and-drop in Firefox.</li>
|
||||
<li>Improve support for IME.</li>
|
||||
<li>Speed up content rendering.</li>
|
||||
<li>Fix browser's built-in search in Webkit.</li>
|
||||
<li>Make double- and triple-click work in IE.</li>
|
||||
<li>Various fixes to modes.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-10-2011: <a href="http://codemirror.net/codemirror-2.16.zip">Version 2.16</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="../mode/perl/index.html">Perl</a>, <a href="../mode/rust/index.html">Rust</a>, <a href="../mode/tiddlywiki/index.html">TiddlyWiki</a>, and <a href="../mode/groovy/index.html">Groovy</a> modes.</li>
|
||||
<li>Dragging text inside the editor now moves, rather than copies.</li>
|
||||
<li>Add a <a href="manual.html#coordsFromIndex"><code>coordsFromIndex</code></a> method.</li>
|
||||
<li><strong>API change</strong>: <code>setValue</code> now no longer clears history. Use <a href="manual.html#clearHistory"><code>clearHistory</code></a> for that.</li>
|
||||
<li><strong>API change</strong>: <a href="manual.html#markText"><code>markText</code></a> now
|
||||
returns an object with <code>clear</code> and <code>find</code>
|
||||
methods. Marked text is now more robust when edited.</li>
|
||||
<li>Fix editing code with tabs in Internet Explorer.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">26-09-2011: <a href="http://codemirror.net/codemirror-2.15.zip">Version 2.15</a>:</p>
|
||||
<p class="rel-note">Fix bug that snuck into 2.14: Clicking the
|
||||
character that currently has the cursor didn't re-focus the
|
||||
editor.</p>
|
||||
|
||||
<p class="rel">26-09-2011: <a href="http://codemirror.net/codemirror-2.14.zip">Version 2.14</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="../mode/clojure/index.html">Clojure</a>, <a href="../mode/pascal/index.html">Pascal</a>, <a href="../mode/ntriples/index.html">NTriples</a>, <a href="../mode/jinja2/index.html">Jinja2</a>, and <a href="../mode/markdown/index.html">Markdown</a> modes.</li>
|
||||
<li>Add <a href="../theme/cobalt.css">Cobalt</a> and <a href="../theme/eclipse.css">Eclipse</a> themes.</li>
|
||||
<li>Add a <a href="manual.html#option_fixedGutter"><code>fixedGutter</code></a> option.</li>
|
||||
<li>Fix bug with <code>setValue</code> breaking cursor movement.</li>
|
||||
<li>Make gutter updates much more efficient.</li>
|
||||
<li>Allow dragging of text out of the editor (on modern browsers).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p class="rel">23-08-2011: <a href="http://codemirror.net/codemirror-2.13.zip">Version 2.13</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="../mode/ruby/index.html">Ruby</a>, <a href="../mode/r/index.html">R</a>, <a href="../mode/coffeescript/index.html">CoffeeScript</a>, and <a href="../mode/velocity/index.html">Velocity</a> modes.</li>
|
||||
<li>Add <a href="manual.html#getGutterElement"><code>getGutterElement</code></a> to API.</li>
|
||||
<li>Several fixes to scrolling and positioning.</li>
|
||||
<li>Add <a href="manual.html#option_smartHome"><code>smartHome</code></a> option.</li>
|
||||
<li>Add an experimental <a href="../mode/xmlpure/index.html">pure XML</a> mode.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">25-07-2011: <a href="http://codemirror.net/codemirror-2.12.zip">Version 2.12</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <a href="../mode/sparql/index.html">SPARQL</a> mode.</li>
|
||||
<li>Fix bug with cursor jumping around in an unfocused editor in IE.</li>
|
||||
<li>Allow key and mouse events to bubble out of the editor. Ignore widget clicks.</li>
|
||||
<li>Solve cursor flakiness after undo/redo.</li>
|
||||
<li>Fix block-reindent ignoring the last few lines.</li>
|
||||
<li>Fix parsing of multi-line attrs in XML mode.</li>
|
||||
<li>Use <code>innerHTML</code> for HTML-escaping.</li>
|
||||
<li>Some fixes to indentation in C-like mode.</li>
|
||||
<li>Shrink horiz scrollbars when long lines removed.</li>
|
||||
<li>Fix width feedback loop bug that caused the width of an inner DIV to shrink.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">04-07-2011: <a href="http://codemirror.net/codemirror-2.11.zip">Version 2.11</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <a href="../mode/scheme/index.html">Scheme mode</a>.</li>
|
||||
<li>Add a <code>replace</code> method to search cursors, for cursor-preserving replacements.</li>
|
||||
<li>Make the <a href="../mode/clike/index.html">C-like mode</a> mode more customizable.</li>
|
||||
<li>Update XML mode to spot mismatched tags.</li>
|
||||
<li>Add <code>getStateAfter</code> API and <code>compareState</code> mode API methods for finer-grained mode magic.</li>
|
||||
<li>Add a <code>getScrollerElement</code> API method to manipulate the scrolling DIV.</li>
|
||||
<li>Fix drag-and-drop for Firefox.</li>
|
||||
<li>Add a C# configuration for the <a href="../mode/clike/index.html">C-like mode</a>.</li>
|
||||
<li>Add <a href="../demo/fullscreen.html">full-screen editing</a> and <a href="../demo/changemode.html">mode-changing</a> demos.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.1.zip">Version 2.1</a>:</p>
|
||||
<p class="rel-note">Add
|
||||
a <a href="manual.html#option_theme">theme</a> system
|
||||
(<a href="../demo/theme.html">demo</a>). Note that this is not
|
||||
backwards-compatible—you'll have to update your styles and
|
||||
modes!</p>
|
||||
|
||||
<p class="rel">07-06-2011: <a href="http://codemirror.net/codemirror-2.02.zip">Version 2.02</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <a href="../mode/lua/index.html">Lua mode</a>.</li>
|
||||
<li>Fix reverse-searching for a regexp.</li>
|
||||
<li>Empty lines can no longer break highlighting.</li>
|
||||
<li>Rework scrolling model (the outer wrapper no longer does the scrolling).</li>
|
||||
<li>Solve horizontal jittering on long lines.</li>
|
||||
<li>Add <a href="../demo/runmode.html">runmode.js</a>.</li>
|
||||
<li>Immediately re-highlight text when typing.</li>
|
||||
<li>Fix problem with 'sticking' horizontal scrollbar.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">26-05-2011: <a href="http://codemirror.net/codemirror-2.01.zip">Version 2.01</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <a href="../mode/smalltalk/index.html">Smalltalk mode</a>.</li>
|
||||
<li>Add a <a href="../mode/rst/index.html">reStructuredText mode</a>.</li>
|
||||
<li>Add a <a href="../mode/python/index.html">Python mode</a>.</li>
|
||||
<li>Add a <a href="../mode/plsql/index.html">PL/SQL mode</a>.</li>
|
||||
<li><code>coordsChar</code> now works</li>
|
||||
<li>Fix a problem where <code>onCursorActivity</code> interfered with <code>onChange</code>.</li>
|
||||
<li>Fix a number of scrolling and mouse-click-position glitches.</li>
|
||||
<li>Pass information about the changed lines to <code>onChange</code>.</li>
|
||||
<li>Support cmd-up/down on OS X.</li>
|
||||
<li>Add triple-click line selection.</li>
|
||||
<li>Don't handle shift when changing the selection through the API.</li>
|
||||
<li>Support <code>"nocursor"</code> mode for <code>readOnly</code> option.</li>
|
||||
<li>Add an <code>onHighlightComplete</code> option.</li>
|
||||
<li>Fix the context menu for Firefox.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-2.0.zip">Version 2.0</a>:</p>
|
||||
<p class="rel-note">CodeMirror 2 is a complete rewrite that's
|
||||
faster, smaller, simpler to use, and less dependent on browser
|
||||
quirks. See <a href="internals.html">this</a>
|
||||
and <a href="http://groups.google.com/group/codemirror/browse_thread/thread/5a8e894024a9f580">this</a>
|
||||
for more information.</p>
|
||||
|
||||
<p class="rel">22-02-2011: <a href="https://github.com/marijnh/codemirror/tree/beta2">Version 2.0 beta 2</a>:</p>
|
||||
<p class="rel-note">Somewhat more mature API, lots of bugs shaken out.</p>
|
||||
|
||||
<p class="rel">17-02-2011: <a href="http://codemirror.net/codemirror-0.94.zip">Version 0.94</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li><code>tabMode: "spaces"</code> was modified slightly (now indents when something is selected).</li>
|
||||
<li>Fixes a bug that would cause the selection code to break on some IE versions.</li>
|
||||
<li>Disabling spell-check on WebKit browsers now works.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">08-02-2011: <a href="http://codemirror.net/">Version 2.0 beta 1</a>:</p>
|
||||
<p class="rel-note">CodeMirror 2 is a complete rewrite of
|
||||
CodeMirror, no longer depending on an editable frame.</p>
|
||||
|
||||
<p class="rel">19-01-2011: <a href="http://codemirror.net/codemirror-0.93.zip">Version 0.93</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Added a <a href="contrib/regex/index.html">Regular Expression</a> parser.</li>
|
||||
<li>Fixes to the PHP parser.</li>
|
||||
<li>Support for regular expression in search/replace.</li>
|
||||
<li>Add <code>save</code> method to instances created with <code>fromTextArea</code>.</li>
|
||||
<li>Add support for MS T-SQL in the SQL parser.</li>
|
||||
<li>Support use of CSS classes for highlighting brackets.</li>
|
||||
<li>Fix yet another hang with line-numbering in hidden editors.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id=v1>
|
||||
|
||||
<h2>Version 0.x</h2>
|
||||
|
||||
<p class="rel">28-03-2011: <a href="http://codemirror.net/codemirror-1.0.zip">Version 1.0</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Fix error when debug history overflows.</li>
|
||||
<li>Refine handling of C# verbatim strings.</li>
|
||||
<li>Fix some issues with JavaScript indentation.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">17-12-2010: <a href="http://codemirror.net/codemirror-0.92.zip">Version 0.92</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Make CodeMirror work in XHTML documents.</li>
|
||||
<li>Fix bug in handling of backslashes in Python strings.</li>
|
||||
<li>The <code>styleNumbers</code> option is now officially
|
||||
supported and documented.</li>
|
||||
<li><code>onLineNumberClick</code> option added.</li>
|
||||
<li>More consistent names <code>onLoad</code> and
|
||||
<code>onCursorActivity</code> callbacks. Old names still work, but
|
||||
are deprecated.</li>
|
||||
<li>Add a <a href="contrib/freemarker/index.html">Freemarker</a> mode.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">11-11-2010: <a
|
||||
href="http://codemirror.net/codemirror-0.91.zip">Version 0.91</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Adds support for <a href="contrib/java">Java</a>.</li>
|
||||
<li>Small additions to the <a href="contrib/php">PHP</a> and <a href="contrib/sql">SQL</a> parsers.</li>
|
||||
<li>Work around various <a href="https://bugs.webkit.org/show_bug.cgi?id=47806">Webkit</a> <a href="https://bugs.webkit.org/show_bug.cgi?id=23474">issues</a>.</li>
|
||||
<li>Fix <code>toTextArea</code> to update the code in the textarea.</li>
|
||||
<li>Add a <code>noScriptCaching</code> option (hack to ease development).</li>
|
||||
<li>Make sub-modes of <a href="mixedtest.html">HTML mixed</a> mode configurable.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">02-10-2010: <a
|
||||
href="http://codemirror.net/codemirror-0.9.zip">Version 0.9</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add support for searching backwards.</li>
|
||||
<li>There are now parsers for <a href="contrib/scheme/index.html">Scheme</a>, <a href="contrib/xquery/index.html">XQuery</a>, and <a href="contrib/ometa/index.html">OmetaJS</a>.</li>
|
||||
<li>Makes <code>height: "dynamic"</code> more robust.</li>
|
||||
<li>Fixes bug where paste did not work on OS X.</li>
|
||||
<li>Add a <code>enterMode</code> and <code>electricChars</code> options to make indentation even more customizable.</li>
|
||||
<li>Add <code>firstLineNumber</code> option.</li>
|
||||
<li>Fix bad handling of <code>@media</code> rules by the CSS parser.</li>
|
||||
<li>Take a new, more robust approach to working around the invisible-last-line bug in WebKit.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">22-07-2010: <a
|
||||
href="http://codemirror.net/codemirror-0.8.zip">Version 0.8</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <code>cursorCoords</code> method to find the screen
|
||||
coordinates of the cursor.</li>
|
||||
<li>A number of fixes and support for more syntax in the PHP parser.</li>
|
||||
<li>Fix indentation problem with JSON-mode JS parser in Webkit.</li>
|
||||
<li>Add a <a href="compress.html">minification</a> UI.</li>
|
||||
<li>Support a <code>height: dynamic</code> mode, where the editor's
|
||||
height will adjust to the size of its content.</li>
|
||||
<li>Better support for IME input mode.</li>
|
||||
<li>Fix JavaScript parser getting confused when seeing a no-argument
|
||||
function call.</li>
|
||||
<li>Have CSS parser see the difference between selectors and other
|
||||
identifiers.</li>
|
||||
<li>Fix scrolling bug when pasting in a horizontally-scrolled
|
||||
editor.</li>
|
||||
<li>Support <code>toTextArea</code> method in instances created with
|
||||
<code>fromTextArea</code>.</li>
|
||||
<li>Work around new Opera cursor bug that causes the cursor to jump
|
||||
when pressing backspace at the end of a line.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-04-2010: <a
|
||||
href="http://codemirror.net/codemirror-0.67.zip">Version
|
||||
0.67</a>:</p>
|
||||
<p class="rel-note">More consistent page-up/page-down behaviour
|
||||
across browsers. Fix some issues with hidden editors looping forever
|
||||
when line-numbers were enabled. Make PHP parser parse
|
||||
<code>"\\"</code> correctly. Have <code>jumpToLine</code> work on
|
||||
line handles, and add <code>cursorLine</code> function to fetch the
|
||||
line handle where the cursor currently is. Add new
|
||||
<code>setStylesheet</code> function to switch style-sheets in a
|
||||
running editor.</p>
|
||||
|
||||
<p class="rel">01-03-2010: <a
|
||||
href="http://codemirror.net/codemirror-0.66.zip">Version
|
||||
0.66</a>:</p>
|
||||
<p class="rel-note">Adds <code>removeLine</code> method to API.
|
||||
Introduces the <a href="contrib/plsql/index.html">PLSQL parser</a>.
|
||||
Marks XML errors by adding (rather than replacing) a CSS class, so
|
||||
that they can be disabled by modifying their style. Fixes several
|
||||
selection bugs, and a number of small glitches.</p>
|
||||
|
||||
<p class="rel">12-11-2009: <a
|
||||
href="http://codemirror.net/codemirror-0.65.zip">Version
|
||||
0.65</a>:</p>
|
||||
<p class="rel-note">Add support for having both line-wrapping and
|
||||
line-numbers turned on, make paren-highlighting style customisable
|
||||
(<code>markParen</code> and <code>unmarkParen</code> config
|
||||
options), work around a selection bug that Opera
|
||||
<em>re</em>introduced in version 10.</p>
|
||||
|
||||
<p class="rel">23-10-2009: <a
|
||||
href="http://codemirror.net/codemirror-0.64.zip">Version
|
||||
0.64</a>:</p>
|
||||
<p class="rel-note">Solves some issues introduced by the
|
||||
paste-handling changes from the previous release. Adds
|
||||
<code>setSpellcheck</code>, <code>setTextWrapping</code>,
|
||||
<code>setIndentUnit</code>, <code>setUndoDepth</code>,
|
||||
<code>setTabMode</code>, and <code>setLineNumbers</code> to
|
||||
customise a running editor. Introduces an <a
|
||||
href="contrib/sql/index.html">SQL</a> parser. Fixes a few small
|
||||
problems in the <a href="contrib/python/index.html">Python</a>
|
||||
parser. And, as usual, add workarounds for various newly discovered
|
||||
browser incompatibilities.</p>
|
||||
|
||||
<p class="rel"><em>31-08-2009</em>: <a href="http://codemirror.net/codemirror-0.63.zip">Version 0.63</a>:</p>
|
||||
<p class="rel-note"> Overhaul of paste-handling (less fragile), fixes for several
|
||||
serious IE8 issues (cursor jumping, end-of-document bugs) and a number
|
||||
of small problems.</p>
|
||||
|
||||
<p class="rel"><em>30-05-2009</em>: <a href="http://codemirror.net/codemirror-0.62.zip">Version 0.62</a>:</p>
|
||||
<p class="rel-note">Introduces <a href="contrib/python/index.html">Python</a>
|
||||
and <a href="contrib/lua/index.html">Lua</a> parsers. Add
|
||||
<code>setParser</code> (on-the-fly mode changing) and
|
||||
<code>clearHistory</code> methods. Make parsing passes time-based
|
||||
instead of lines-based (see the <code>passTime</code> option).</p>
|
||||
|
||||
</section>
|
||||
</article>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,451 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
||||
dontAlignCalls = parserConfig.dontAlignCalls,
|
||||
keywords = parserConfig.keywords || {},
|
||||
builtin = parserConfig.builtin || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
var indent = state.indented;
|
||||
if (state.context && state.context.type == "statement")
|
||||
indent = state.context.indented;
|
||||
return state.context = new Context(indent, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
||||
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
|
||||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
||||
"double static else struct entry switch extern typedef float union for unsigned " +
|
||||
"goto while enum void const signed volatile";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
for (;;) {
|
||||
if (stream.skipTo("\\")) {
|
||||
stream.next();
|
||||
if (stream.eol()) {
|
||||
state.tokenize = cppHook;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
}
|
||||
|
||||
function cpp11StringHook(stream, state) {
|
||||
stream.backUp(1);
|
||||
// Raw strings.
|
||||
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
||||
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
state.cpp11RawStringDelim = match[1];
|
||||
state.tokenize = tokenRawString;
|
||||
return tokenRawString(stream, state);
|
||||
}
|
||||
// Unicode strings/chars.
|
||||
if (stream.match(/(u8|u|U|L)/)) {
|
||||
if (stream.match(/["']/, /* eat */ false)) {
|
||||
return "string";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Ignore this hook.
|
||||
stream.next();
|
||||
return false;
|
||||
}
|
||||
|
||||
// C#-style strings where "" escapes a quote.
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
||||
// <delim> can be a string up to 16 characters long.
|
||||
function tokenRawString(stream, state) {
|
||||
// Escape characters that have special regex meanings.
|
||||
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
||||
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
||||
if (match)
|
||||
state.tokenize = null;
|
||||
else
|
||||
stream.skipToEnd();
|
||||
return "string";
|
||||
}
|
||||
|
||||
function def(mimes, mode) {
|
||||
if (typeof mimes == "string") mimes = [mimes];
|
||||
var words = [];
|
||||
function add(obj) {
|
||||
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
||||
words.push(prop);
|
||||
}
|
||||
add(mode.keywords);
|
||||
add(mode.builtin);
|
||||
add(mode.atoms);
|
||||
if (words.length) {
|
||||
mode.helperType = mimes[0];
|
||||
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
||||
}
|
||||
|
||||
for (var i = 0; i < mimes.length; ++i)
|
||||
CodeMirror.defineMIME(mimes[i], mode);
|
||||
}
|
||||
|
||||
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
||||
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 " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
||||
"static_assert override"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"u": cpp11StringHook,
|
||||
"U": cpp11StringHook,
|
||||
"L": cpp11StringHook,
|
||||
"R": cpp11StringHook
|
||||
},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
def("text/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 " +
|
||||
"instanceof int interface long native new package private protected public " +
|
||||
"return short static strictfp super switch synchronized this throw throws transient " +
|
||||
"try void volatile while"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
},
|
||||
modeProps: {fold: ["brace", "import"]}
|
||||
});
|
||||
def("text/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base break case catch checked class const continue" +
|
||||
" default delegate do else enum event explicit extern finally fixed for" +
|
||||
" foreach goto if implicit in interface internal is lock namespace new" +
|
||||
" operator out override params private protected public readonly ref return sealed" +
|
||||
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
||||
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
||||
" global group into join let orderby partial remove select set value var yield"),
|
||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
||||
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
||||
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
||||
" UInt64 bool byte char decimal double short int long object" +
|
||||
" sbyte float string ushort uint ulong"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
if (stream.eat('"')) {
|
||||
state.tokenize = tokenAtString;
|
||||
return tokenAtString(stream, state);
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
def("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends false final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
||||
"<% >: # @ " +
|
||||
|
||||
/* package scala */
|
||||
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
||||
"readChar readInt readLong readFloat readDouble " +
|
||||
|
||||
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
||||
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
||||
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
||||
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
||||
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
||||
|
||||
/* package java.lang */
|
||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
||||
|
||||
|
||||
),
|
||||
multiLineStrings: true,
|
||||
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
||||
name: "clike",
|
||||
keywords: words("float int bool void " +
|
||||
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
||||
"mat2 mat3 mat4 " +
|
||||
"sampler1D sampler2D sampler3D samplerCube " +
|
||||
"sampler1DShadow sampler2DShadow" +
|
||||
"const attribute uniform varying " +
|
||||
"break continue discard return " +
|
||||
"for while do if else struct " +
|
||||
"in out inout"),
|
||||
blockKeywords: words("for while do if else struct"),
|
||||
builtin: words("radians degrees sin cos tan asin acos atan " +
|
||||
"pow exp log exp2 sqrt inversesqrt " +
|
||||
"abs sign floor ceil fract mod min max clamp mix step smootstep " +
|
||||
"length distance dot cross normalize ftransform faceforward " +
|
||||
"reflect refract matrixCompMult " +
|
||||
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
||||
"equal notEqual any all not " +
|
||||
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
||||
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
||||
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
||||
"textureCube textureCubeLod " +
|
||||
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
||||
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
||||
"dFdx dFdy fwidth " +
|
||||
"noise1 noise2 noise3 noise4"),
|
||||
atoms: words("true false " +
|
||||
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
||||
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
||||
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
||||
"gl_FogCoord " +
|
||||
"gl_Position gl_PointSize gl_ClipVertex " +
|
||||
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
||||
"gl_TexCoord gl_FogFragCoord " +
|
||||
"gl_FragCoord gl_FrontFacing " +
|
||||
"gl_FragColor gl_FragData gl_FragDepth " +
|
||||
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
||||
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
||||
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
||||
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
||||
"gl_ProjectionMatrixInverseTranspose " +
|
||||
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
||||
"gl_TextureMatrixInverseTranspose " +
|
||||
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
||||
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
||||
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
||||
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
||||
"gl_FogParameters " +
|
||||
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
||||
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
||||
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
||||
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
||||
"gl_MaxDrawBuffers"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-nesc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
||||
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
||||
"signal task uses abstract extends"),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: C-like mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
|
||||
<script src="../../addon/hint/show-hint.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">C-like</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>C-like mode</h2>
|
||||
|
||||
<div><textarea id="c-code">
|
||||
/* C demo code */
|
||||
|
||||
#include <zmq.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
typedef struct {
|
||||
void* arg_socket;
|
||||
zmq_msg_t* arg_msg;
|
||||
char* arg_string;
|
||||
unsigned long arg_len;
|
||||
int arg_int, arg_command;
|
||||
|
||||
int signal_fd;
|
||||
int pad;
|
||||
void* context;
|
||||
sem_t sem;
|
||||
} acl_zmq_context;
|
||||
|
||||
#define p(X) (context->arg_##X)
|
||||
|
||||
void* zmq_thread(void* context_pointer) {
|
||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
||||
char ok = 'K', err = 'X';
|
||||
int res;
|
||||
|
||||
while (1) {
|
||||
while ((res = sem_wait(&context->sem)) == EINTR);
|
||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
||||
switch(p(command)) {
|
||||
case 0: goto cleanup;
|
||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
||||
case 2: p(int) = zmq_close(p(socket)); break;
|
||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
||||
}
|
||||
p(command) = errno;
|
||||
write(context->signal_fd, &ok, 1);
|
||||
}
|
||||
cleanup:
|
||||
close(context->signal_fd);
|
||||
free(context_pointer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
||||
pthread_t thread;
|
||||
|
||||
context->context = zmq_context;
|
||||
context->signal_fd = signal_fd;
|
||||
sem_init(&context->sem, 1, 0);
|
||||
pthread_create(&thread, 0, &zmq_thread, context);
|
||||
pthread_detach(thread);
|
||||
return context;
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>C++ example</h2>
|
||||
|
||||
<div><textarea id="cpp-code">
|
||||
#include <iostream>
|
||||
#include "mystuff/util.h"
|
||||
|
||||
namespace {
|
||||
enum Enum {
|
||||
VAL1, VAL2, VAL3
|
||||
};
|
||||
|
||||
char32_t unicode_string = U"\U0010FFFF";
|
||||
string raw_string = R"delim(anything
|
||||
you
|
||||
want)delim";
|
||||
|
||||
int Helper(const MyType& param) {
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class ForwardDec;
|
||||
|
||||
template <class T, class V>
|
||||
class Class : public BaseClass {
|
||||
const MyType<T, V> member_;
|
||||
|
||||
public:
|
||||
const MyType<T, V>& Method() const {
|
||||
return member_;
|
||||
}
|
||||
|
||||
void Method2(MyType<T, V>* value);
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
void Class::Method2(MyType<T, V>* value) {
|
||||
std::out << 1 >> method();
|
||||
value->Method3(member_);
|
||||
member_ = value;
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<h2>Java example</h2>
|
||||
|
||||
<div><textarea id="java-code">
|
||||
import com.demo.util.MyType;
|
||||
import com.demo.util.MyInterface;
|
||||
|
||||
public enum Enum {
|
||||
VAL1, VAL2, VAL3
|
||||
}
|
||||
|
||||
public class Class<T, V> implements MyInterface {
|
||||
public static final MyType<T, V> member;
|
||||
|
||||
private class InnerClass {
|
||||
public int zero() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyType method() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void method2(MyType<T, V> value) {
|
||||
method();
|
||||
value.method3();
|
||||
member = value;
|
||||
}
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var cEditor = CodeMirror.fromTextArea(document.getElementById("c-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-csrc"
|
||||
});
|
||||
var cppEditor = CodeMirror.fromTextArea(document.getElementById("cpp-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-c++src"
|
||||
});
|
||||
var javaEditor = CodeMirror.fromTextArea(document.getElementById("java-code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-java"
|
||||
});
|
||||
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
||||
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle C-like languages as well as it
|
||||
can. Takes two configuration parameters: <code>keywords</code>, an
|
||||
object whose property names are the keywords in the language,
|
||||
and <code>useCPP</code>, which determines whether C preprocessor
|
||||
directives are recognized.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
||||
(C code), <code>text/x-c++src</code> (C++
|
||||
code), <code>text/x-java</code> (Java
|
||||
code), <code>text/x-csharp</code> (C#).</p>
|
||||
</article>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,88 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Clojure mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="clojure.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Clojure</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Clojure mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
; Conway's Game of Life, based on the work of:
|
||||
;; Laurent Petit https://gist.github.com/1200343
|
||||
;; Christophe Grand http://clj-me.cgrand.net/2011/08/19/conways-game-of-life
|
||||
|
||||
(ns ^{:doc "Conway's Game of Life."}
|
||||
game-of-life)
|
||||
|
||||
;; Core game of life's algorithm functions
|
||||
|
||||
(defn neighbours
|
||||
"Given a cell's coordinates, returns the coordinates of its neighbours."
|
||||
[[x y]]
|
||||
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
|
||||
[(+ dx x) (+ dy y)]))
|
||||
|
||||
(defn step
|
||||
"Given a set of living cells, computes the new set of living cells."
|
||||
[cells]
|
||||
(set (for [[cell n] (frequencies (mapcat neighbours cells))
|
||||
:when (or (= n 3) (and (= n 2) (cells cell)))]
|
||||
cell)))
|
||||
|
||||
;; Utility methods for displaying game on a text terminal
|
||||
|
||||
(defn print-board
|
||||
"Prints a board on *out*, representing a step in the game."
|
||||
[board w h]
|
||||
(doseq [x (range (inc w)) y (range (inc h))]
|
||||
(if (= y 0) (print "\n"))
|
||||
(print (if (board [x y]) "[X]" " . "))))
|
||||
|
||||
(defn display-grids
|
||||
"Prints a squence of boards on *out*, representing several steps."
|
||||
[grids w h]
|
||||
(doseq [board grids]
|
||||
(print-board board w h)
|
||||
(print "\n")))
|
||||
|
||||
;; Launches an example board
|
||||
|
||||
(def
|
||||
^{:doc "board represents the initial set of living cells"}
|
||||
board #{[2 1] [2 2] [2 3]})
|
||||
|
||||
(display-grids (take 3 (iterate step board)) 5 5)
|
||||
|
||||
;; Let's play with characters
|
||||
(println \1 \a \# \\
|
||||
\" \( \newline
|
||||
\} \" \space
|
||||
\tab \return \backspace
|
||||
\u1000 \uAaAa \u9F9F)
|
||||
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p>
|
||||
|
||||
</article>
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
// Error, because "foobarhello" is neither a known type or property, but
|
||||
// property was expected (after "and"), and it should be in parenthese.
|
||||
MT("atMediaUnknownType",
|
||||
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
||||
|
||||
// Soft error, because "foobarhello" is not a known property or type.
|
||||
MT("atMediaUnknownProperty",
|
||||
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
|
||||
|
||||
// Make sure nesting works with media queries
|
||||
MT("atMediaMaxWidthNested",
|
||||
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
||||
|
||||
MT("tagSelector",
|
||||
"[tag foo] { }");
|
||||
|
||||
MT("classSelector",
|
||||
"[qualifier .foo-bar_hello] { }");
|
||||
|
||||
MT("idSelector",
|
||||
"[builtin #foo] { [error #foo] }");
|
||||
|
||||
MT("tagSelectorUnclosed",
|
||||
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
|
||||
|
||||
MT("tagStringNoQuotes",
|
||||
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
|
||||
|
||||
MT("tagStringDouble",
|
||||
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
|
||||
|
||||
MT("tagStringSingle",
|
||||
"[tag foo] { [property font-family]: [string 'hello world']; }");
|
||||
|
||||
MT("tagColorKeyword",
|
||||
"[tag foo] {",
|
||||
" [property color]: [keyword black];",
|
||||
" [property color]: [keyword navy];",
|
||||
" [property color]: [keyword yellow];",
|
||||
"}");
|
||||
|
||||
MT("tagColorHex3",
|
||||
"[tag foo] { [property background]: [atom #fff]; }");
|
||||
|
||||
MT("tagColorHex6",
|
||||
"[tag foo] { [property background]: [atom #ffffff]; }");
|
||||
|
||||
MT("tagColorHex4",
|
||||
"[tag foo] { [property background]: [atom&error #ffff]; }");
|
||||
|
||||
MT("tagColorHexInvalid",
|
||||
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
||||
|
||||
MT("tagNegativeNumber",
|
||||
"[tag foo] { [property margin]: [number -5px]; }");
|
||||
|
||||
MT("tagPositiveNumber",
|
||||
"[tag foo] { [property padding]: [number 5px]; }");
|
||||
|
||||
MT("tagVendor",
|
||||
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
|
||||
|
||||
MT("tagBogusProperty",
|
||||
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
|
||||
|
||||
MT("tagTwoProperties",
|
||||
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
||||
|
||||
MT("tagTwoPropertiesURL",
|
||||
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
||||
|
||||
MT("commentSGML",
|
||||
"[comment <!--comment-->]");
|
||||
|
||||
MT("commentSGML2",
|
||||
"[comment <!--comment]",
|
||||
"[comment -->] [tag div] {}");
|
||||
|
||||
MT("indent_tagSelector",
|
||||
"[tag strong], [tag em] {",
|
||||
" [property background]: [atom rgba](",
|
||||
" [number 255], [number 255], [number 0], [number .2]",
|
||||
" );",
|
||||
"}");
|
||||
|
||||
MT("indent_atMedia",
|
||||
"[def @media] {",
|
||||
" [tag foo] {",
|
||||
" [property color]:",
|
||||
" [keyword yellow];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("indent_comma",
|
||||
"[tag foo] {",
|
||||
" [property font-family]: [variable verdana],",
|
||||
" [atom sans-serif];",
|
||||
"}");
|
||||
|
||||
MT("indent_parentheses",
|
||||
"[tag foo]:[variable-3 before] {",
|
||||
" [property background]: [atom url](",
|
||||
"[string blahblah]",
|
||||
"[string etc]",
|
||||
"[string ]) [keyword !important];",
|
||||
"}");
|
||||
|
||||
MT("font_face",
|
||||
"[def @font-face] {",
|
||||
" [property font-family]: [string 'myfont'];",
|
||||
" [error nonsense]: [string 'abc'];",
|
||||
" [property src]: [atom url]([string http://blah]),",
|
||||
" [atom url]([string http://foo]);",
|
||||
"}");
|
||||
|
||||
MT("empty_url",
|
||||
"[def @import] [tag url]() [tag screen];");
|
||||
|
||||
MT("parens",
|
||||
"[qualifier .foo] {",
|
||||
" [property background-image]: [variable fade]([atom #000], [number 20%]);",
|
||||
" [property border-image]: [variable linear-gradient](",
|
||||
" [atom to] [atom bottom],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 0%],",
|
||||
" [variable fade]([atom #000], [number 20%]) [number 100%]",
|
||||
" );",
|
||||
"}");
|
||||
})();
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "gfm", highlightFormatting: true});
|
||||
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
FT("codeBackticks",
|
||||
"[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
|
||||
|
||||
FT("doubleBackticks",
|
||||
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
|
||||
|
||||
FT("codeBlock",
|
||||
"[comment&formatting&formatting-code-block ```css]",
|
||||
"[tag foo]",
|
||||
"[comment&formatting&formatting-code-block ```]");
|
||||
|
||||
FT("taskList",
|
||||
"[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
|
||||
"[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
|
||||
|
||||
MT("emInWordAsterisk",
|
||||
"foo[em *bar*]hello");
|
||||
|
||||
MT("emInWordUnderscore",
|
||||
"foo_bar_hello");
|
||||
|
||||
MT("emStrongUnderscore",
|
||||
"[strong __][em&strong _foo__][em _] bar");
|
||||
|
||||
MT("fencedCodeBlocks",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"",
|
||||
"[comment ```]",
|
||||
"bar");
|
||||
|
||||
MT("fencedCodeBlockModeSwitching",
|
||||
"[comment ```javascript]",
|
||||
"[variable foo]",
|
||||
"",
|
||||
"[comment ```]",
|
||||
"bar");
|
||||
|
||||
MT("taskListAsterisk",
|
||||
"[variable-2 * []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListPlus",
|
||||
"[variable-2 + []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListDash",
|
||||
"[variable-2 - []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListNumber",
|
||||
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("SHA",
|
||||
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
|
||||
|
||||
MT("SHAEmphasis",
|
||||
"[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
|
||||
|
||||
MT("shortSHA",
|
||||
"foo [link be6a8cc] bar");
|
||||
|
||||
MT("tooShortSHA",
|
||||
"foo be6a8c bar");
|
||||
|
||||
MT("longSHA",
|
||||
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
|
||||
|
||||
MT("badSHA",
|
||||
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
|
||||
|
||||
MT("userSHA",
|
||||
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
|
||||
|
||||
MT("userSHAEmphasis",
|
||||
"[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
|
||||
|
||||
MT("userProjectSHA",
|
||||
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
|
||||
|
||||
MT("userProjectSHAEmphasis",
|
||||
"[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
|
||||
|
||||
MT("num",
|
||||
"foo [link #1] bar");
|
||||
|
||||
MT("numEmphasis",
|
||||
"[em *foo ][em&link #1][em *]");
|
||||
|
||||
MT("badNum",
|
||||
"foo #1bar hello");
|
||||
|
||||
MT("userNum",
|
||||
"foo [link bar#1] hello");
|
||||
|
||||
MT("userNumEmphasis",
|
||||
"[em *foo ][em&link bar#1][em *]");
|
||||
|
||||
MT("userProjectNum",
|
||||
"foo [link bar/hello#1] world");
|
||||
|
||||
MT("userProjectNumEmphasis",
|
||||
"[em *foo ][em&link bar/hello#1][em *]");
|
||||
|
||||
MT("vanillaLink",
|
||||
"foo [link http://www.example.com/] bar");
|
||||
|
||||
MT("vanillaLinkPunctuation",
|
||||
"foo [link http://www.example.com/]. bar");
|
||||
|
||||
MT("vanillaLinkExtension",
|
||||
"foo [link http://www.example.com/index.html] bar");
|
||||
|
||||
MT("vanillaLinkEmphasis",
|
||||
"foo [em *][em&link http://www.example.com/index.html][em *] bar");
|
||||
|
||||
MT("notALink",
|
||||
"[comment ```css]",
|
||||
"[tag foo] {[property color]:[keyword black];}",
|
||||
"[comment ```][link http://www.example.com/]");
|
||||
|
||||
MT("notALink",
|
||||
"[comment ``foo `bar` http://www.example.com/``] hello");
|
||||
|
||||
MT("notALink",
|
||||
"[comment `foo]",
|
||||
"[link http://www.example.com/]",
|
||||
"[comment `foo]",
|
||||
"",
|
||||
"[link http://www.example.com/]");
|
||||
})();
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
|
||||
|
||||
//config settings
|
||||
var scriptStartRegex = parserConfig.scriptStartRegex || /^<%/i,
|
||||
scriptEndRegex = parserConfig.scriptEndRegex || /^%>/i;
|
||||
|
||||
//inner modes
|
||||
var scriptingMode, htmlMixedMode;
|
||||
|
||||
//tokenizer when in html mode
|
||||
function htmlDispatch(stream, state) {
|
||||
if (stream.match(scriptStartRegex, false)) {
|
||||
state.token=scriptingDispatch;
|
||||
return scriptingMode.token(stream, state.scriptState);
|
||||
}
|
||||
else
|
||||
return htmlMixedMode.token(stream, state.htmlState);
|
||||
}
|
||||
|
||||
//tokenizer when in scripting mode
|
||||
function scriptingDispatch(stream, state) {
|
||||
if (stream.match(scriptEndRegex, false)) {
|
||||
state.token=htmlDispatch;
|
||||
return htmlMixedMode.token(stream, state.htmlState);
|
||||
}
|
||||
else
|
||||
return scriptingMode.token(stream, state.scriptState);
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
scriptingMode = scriptingMode || CodeMirror.getMode(config, parserConfig.scriptingModeSpec);
|
||||
htmlMixedMode = htmlMixedMode || CodeMirror.getMode(config, "htmlmixed");
|
||||
return {
|
||||
token : parserConfig.startOpen ? scriptingDispatch : htmlDispatch,
|
||||
htmlState : CodeMirror.startState(htmlMixedMode),
|
||||
scriptState : CodeMirror.startState(scriptingMode)
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
return state.token(stream, state);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.token == htmlDispatch)
|
||||
return htmlMixedMode.indent(state.htmlState, textAfter);
|
||||
else if (scriptingMode.indent)
|
||||
return scriptingMode.indent(state.scriptState, textAfter);
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
return {
|
||||
token : state.token,
|
||||
htmlState : CodeMirror.copyState(htmlMixedMode, state.htmlState),
|
||||
scriptState : CodeMirror.copyState(scriptingMode, state.scriptState)
|
||||
};
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
if (state.token == scriptingDispatch) return {state: state.scriptState, mode: scriptingMode};
|
||||
else return {state: state.htmlState, mode: htmlMixedMode};
|
||||
}
|
||||
};
|
||||
}, "htmlmixed");
|
||||
|
||||
CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingModeSpec:"javascript"});
|
||||
CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
|
||||
CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingModeSpec:"text/x-java"});
|
||||
CodeMirror.defineMIME("application/x-erb", { name: "htmlembedded", scriptingModeSpec:"ruby"});
|
||||
|
||||
});
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
|
||||
var htmlMode = CodeMirror.getMode(config, {name: "xml",
|
||||
htmlMode: true,
|
||||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
||||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag});
|
||||
var cssMode = CodeMirror.getMode(config, "css");
|
||||
|
||||
var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
|
||||
scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
|
||||
mode: CodeMirror.getMode(config, "javascript")});
|
||||
if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) {
|
||||
var conf = scriptTypesConf[i];
|
||||
scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)});
|
||||
}
|
||||
scriptTypes.push({matches: /./,
|
||||
mode: CodeMirror.getMode(config, "text/plain")});
|
||||
|
||||
function html(stream, state) {
|
||||
var tagName = state.htmlState.tagName;
|
||||
if (tagName) tagName = tagName.toLowerCase();
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") {
|
||||
// Script block: mode to change to depends on type attribute
|
||||
var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
|
||||
scriptType = scriptType ? scriptType[1] : "";
|
||||
if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1);
|
||||
for (var i = 0; i < scriptTypes.length; ++i) {
|
||||
var tp = scriptTypes[i];
|
||||
if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) {
|
||||
if (tp.mode) {
|
||||
state.token = script;
|
||||
state.localMode = tp.mode;
|
||||
state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") {
|
||||
state.token = css;
|
||||
state.localMode = cssMode;
|
||||
state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
|
||||
}
|
||||
return style;
|
||||
}
|
||||
function maybeBackup(stream, pat, style) {
|
||||
var cur = stream.current();
|
||||
var close = cur.search(pat), m;
|
||||
if (close > -1) stream.backUp(cur.length - close);
|
||||
else if (m = cur.match(/<\/?$/)) {
|
||||
stream.backUp(cur.length);
|
||||
if (!stream.match(pat, false)) stream.match(cur);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
function script(stream, state) {
|
||||
if (stream.match(/^<\/\s*script\s*>/i, false)) {
|
||||
state.token = html;
|
||||
state.localState = state.localMode = null;
|
||||
return html(stream, state);
|
||||
}
|
||||
return maybeBackup(stream, /<\/\s*script\s*>/,
|
||||
state.localMode.token(stream, state.localState));
|
||||
}
|
||||
function css(stream, state) {
|
||||
if (stream.match(/^<\/\s*style\s*>/i, false)) {
|
||||
state.token = html;
|
||||
state.localState = state.localMode = null;
|
||||
return html(stream, state);
|
||||
}
|
||||
return maybeBackup(stream, /<\/\s*style\s*>/,
|
||||
cssMode.token(stream, state.localState));
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var state = htmlMode.startState();
|
||||
return {token: html, localMode: null, localState: null, htmlState: state};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
if (state.localState)
|
||||
var local = CodeMirror.copyState(state.localMode, state.localState);
|
||||
return {token: state.token, localMode: state.localMode, localState: local,
|
||||
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
return state.token(stream, state);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (!state.localMode || /^\s*<\//.test(textAfter))
|
||||
return htmlMode.indent(state.htmlState, textAfter);
|
||||
else if (state.localMode.indent)
|
||||
return state.localMode.indent(state.localState, textAfter);
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
|
||||
}
|
||||
};
|
||||
}, "xml", "javascript", "css");
|
||||
|
||||
CodeMirror.defineMIME("text/html", "htmlmixed");
|
||||
|
||||
});
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "javascript");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("locals",
|
||||
"[keyword function] [variable foo]([def a], [def b]) { [keyword var] [def c] [operator =] [number 10]; [keyword return] [variable-2 a] [operator +] [variable-2 c] [operator +] [variable d]; }");
|
||||
|
||||
MT("comma-and-binop",
|
||||
"[keyword function](){ [keyword var] [def x] [operator =] [number 1] [operator +] [number 2], [def y]; }");
|
||||
|
||||
MT("destructuring",
|
||||
"([keyword function]([def a], [[[def b], [def c] ]]) {",
|
||||
" [keyword let] {[def d], [property foo]: [def c][operator =][number 10], [def x]} [operator =] [variable foo]([variable-2 a]);",
|
||||
" [[[variable-2 c], [variable y] ]] [operator =] [variable-2 c];",
|
||||
"})();");
|
||||
|
||||
MT("class_body",
|
||||
"[keyword class] [variable Foo] {",
|
||||
" [property constructor]() {}",
|
||||
" [property sayName]() {",
|
||||
" [keyword return] [string-2 `foo${][variable foo][string-2 }oo`];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("class",
|
||||
"[keyword class] [variable Point] [keyword extends] [variable SuperThing] {",
|
||||
" [property get] [property prop]() { [keyword return] [number 24]; }",
|
||||
" [property constructor]([def x], [def y]) {",
|
||||
" [keyword super]([string 'something']);",
|
||||
" [keyword this].[property x] [operator =] [variable-2 x];",
|
||||
" }",
|
||||
"}");
|
||||
|
||||
MT("module",
|
||||
"[keyword module] [string 'foo'] {",
|
||||
" [keyword export] [keyword let] [def x] [operator =] [number 42];",
|
||||
" [keyword export] [keyword *] [keyword from] [string 'somewhere'];",
|
||||
"}");
|
||||
|
||||
MT("import",
|
||||
"[keyword function] [variable foo]() {",
|
||||
" [keyword import] [def $] [keyword from] [string 'jquery'];",
|
||||
" [keyword module] [def crypto] [keyword from] [string 'crypto'];",
|
||||
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
|
||||
"}");
|
||||
|
||||
MT("const",
|
||||
"[keyword function] [variable f]() {",
|
||||
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
|
||||
"}");
|
||||
|
||||
MT("for/of",
|
||||
"[keyword for]([keyword let] [variable of] [keyword of] [variable something]) {}");
|
||||
|
||||
MT("generator",
|
||||
"[keyword function*] [variable repeat]([def n]) {",
|
||||
" [keyword for]([keyword var] [def i] [operator =] [number 0]; [variable-2 i] [operator <] [variable-2 n]; [operator ++][variable-2 i])",
|
||||
" [keyword yield] [variable-2 i];",
|
||||
"}");
|
||||
|
||||
MT("fatArrow",
|
||||
"[variable array].[property filter]([def a] [operator =>] [variable-2 a] [operator +] [number 1]);",
|
||||
"[variable a];", // No longer in scope
|
||||
"[keyword let] [variable f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
||||
"[variable c];");
|
||||
|
||||
MT("spread",
|
||||
"[keyword function] [variable f]([def a], [meta ...][def b]) {",
|
||||
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
||||
"}");
|
||||
|
||||
MT("comprehension",
|
||||
"[keyword function] [variable f]() {",
|
||||
" [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
|
||||
" ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",
|
||||
"}");
|
||||
|
||||
MT("quasi",
|
||||
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
||||
|
||||
MT("quasi_no_function",
|
||||
"[variable x] [operator =] [string-2 `fofdlakj${][variable x] [operator +] [string-2 `foo`] [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
|
||||
|
||||
MT("indent_statement",
|
||||
"[keyword var] [variable x] [operator =] [number 10]",
|
||||
"[variable x] [operator +=] [variable y] [operator +]",
|
||||
" [atom Infinity]",
|
||||
"[keyword debugger];");
|
||||
|
||||
MT("indent_if",
|
||||
"[keyword if] ([number 1])",
|
||||
" [keyword break];",
|
||||
"[keyword else] [keyword if] ([number 2])",
|
||||
" [keyword continue];",
|
||||
"[keyword else]",
|
||||
" [number 10];",
|
||||
"[keyword if] ([number 1]) {",
|
||||
" [keyword break];",
|
||||
"} [keyword else] [keyword if] ([number 2]) {",
|
||||
" [keyword continue];",
|
||||
"} [keyword else] {",
|
||||
" [number 10];",
|
||||
"}");
|
||||
|
||||
MT("indent_for",
|
||||
"[keyword for] ([keyword var] [variable i] [operator =] [number 0];",
|
||||
" [variable i] [operator <] [number 100];",
|
||||
" [variable i][operator ++])",
|
||||
" [variable doSomething]([variable i]);",
|
||||
"[keyword debugger];");
|
||||
|
||||
MT("indent_c_style",
|
||||
"[keyword function] [variable foo]()",
|
||||
"{",
|
||||
" [keyword debugger];",
|
||||
"}");
|
||||
|
||||
MT("indent_else",
|
||||
"[keyword for] (;;)",
|
||||
" [keyword if] ([variable foo])",
|
||||
" [keyword if] ([variable bar])",
|
||||
" [number 1];",
|
||||
" [keyword else]",
|
||||
" [number 2];",
|
||||
" [keyword else]",
|
||||
" [number 3];");
|
||||
|
||||
MT("indent_funarg",
|
||||
"[variable foo]([number 10000],",
|
||||
" [keyword function]([def a]) {",
|
||||
" [keyword debugger];",
|
||||
"};");
|
||||
|
||||
MT("indent_below_if",
|
||||
"[keyword for] (;;)",
|
||||
" [keyword if] ([variable foo])",
|
||||
" [number 1];",
|
||||
"[number 2];");
|
||||
|
||||
MT("multilinestring",
|
||||
"[keyword var] [variable x] [operator =] [string 'foo\\]",
|
||||
"[string bar'];");
|
||||
|
||||
MT("scary_regexp",
|
||||
"[string-2 /foo[[/]]bar/];");
|
||||
|
||||
var jsonld_mode = CodeMirror.getMode(
|
||||
{indentUnit: 2},
|
||||
{name: "javascript", jsonld: true}
|
||||
);
|
||||
function LD(name) {
|
||||
test.mode(name, jsonld_mode, Array.prototype.slice.call(arguments, 1));
|
||||
}
|
||||
|
||||
LD("json_ld_keywords",
|
||||
'{',
|
||||
' [meta "@context"]: {',
|
||||
' [meta "@base"]: [string "http://example.com"],',
|
||||
' [meta "@vocab"]: [string "http://xmlns.com/foaf/0.1/"],',
|
||||
' [property "likesFlavor"]: {',
|
||||
' [meta "@container"]: [meta "@list"]',
|
||||
' [meta "@reverse"]: [string "@beFavoriteOf"]',
|
||||
' },',
|
||||
' [property "nick"]: { [meta "@container"]: [meta "@set"] },',
|
||||
' [property "nick"]: { [meta "@container"]: [meta "@index"] }',
|
||||
' },',
|
||||
' [meta "@graph"]: [[ {',
|
||||
' [meta "@id"]: [string "http://dbpedia.org/resource/John_Lennon"],',
|
||||
' [property "name"]: [string "John Lennon"],',
|
||||
' [property "modified"]: {',
|
||||
' [meta "@value"]: [string "2010-05-29T14:17:39+02:00"],',
|
||||
' [meta "@type"]: [string "http://www.w3.org/2001/XMLSchema#dateTime"]',
|
||||
' }',
|
||||
' } ]]',
|
||||
'}');
|
||||
|
||||
LD("json_ld_fake",
|
||||
'{',
|
||||
' [property "@fake"]: [string "@fake"],',
|
||||
' [property "@contextual"]: [string "@identifier"],',
|
||||
' [property "user@domain.com"]: [string "@graphical"],',
|
||||
' [property "@ID"]: [string "@@ID"]',
|
||||
'}');
|
||||
})();
|
||||
|
|
@ -1,301 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("julia", function(_conf, parserConf) {
|
||||
var ERRORCLASS = 'error';
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
||||
}
|
||||
|
||||
var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/;
|
||||
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
|
||||
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*!*/;
|
||||
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
|
||||
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
|
||||
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall'];
|
||||
var builtinList = ['true', 'false', 'enumerate', 'open', 'close', 'nothing', 'NaN', 'Inf', 'print', 'println', 'Int', 'Int8', 'Uint8', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Int64', 'Uint64', 'Int128', 'Uint128', 'Bool', 'Char', 'Float16', 'Float32', 'Float64', 'Array', 'Vector', 'Matrix', 'String', 'UTF8String', 'ASCIIString', 'error', 'warn', 'info', '@printf'];
|
||||
|
||||
//var stringPrefixes = new RegExp("^[br]?('|\")")
|
||||
var stringPrefixes = /^(`|'|"{3}|([br]?"))/;
|
||||
var keywords = wordRegexp(keywordList);
|
||||
var builtins = wordRegexp(builtinList);
|
||||
var openers = wordRegexp(blockOpeners);
|
||||
var closers = wordRegexp(blockClosers);
|
||||
var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
|
||||
var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/;
|
||||
var indentInfo = null;
|
||||
|
||||
function in_array(state) {
|
||||
var ch = cur_scope(state);
|
||||
if(ch=="[" || ch=="{") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function cur_scope(state) {
|
||||
if(state.scopes.length==0) {
|
||||
return null;
|
||||
}
|
||||
return state.scopes[state.scopes.length - 1];
|
||||
}
|
||||
|
||||
// tokenizers
|
||||
function tokenBase(stream, state) {
|
||||
// Handle scope changes
|
||||
var leaving_expr = state.leaving_expr;
|
||||
if(stream.sol()) {
|
||||
leaving_expr = false;
|
||||
}
|
||||
state.leaving_expr = false;
|
||||
if(leaving_expr) {
|
||||
if(stream.match(/^'+/)) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(stream.match(/^\.{2,3}/)) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ch = stream.peek();
|
||||
// Handle Comments
|
||||
if (ch === '#') {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
if(ch==='[') {
|
||||
state.scopes.push("[");
|
||||
}
|
||||
|
||||
if(ch==='{') {
|
||||
state.scopes.push("{");
|
||||
}
|
||||
|
||||
var scope=cur_scope(state);
|
||||
|
||||
if(scope==='[' && ch===']') {
|
||||
state.scopes.pop();
|
||||
state.leaving_expr=true;
|
||||
}
|
||||
|
||||
if(scope==='{' && ch==='}') {
|
||||
state.scopes.pop();
|
||||
state.leaving_expr=true;
|
||||
}
|
||||
|
||||
if(ch===')') {
|
||||
state.leaving_expr = true;
|
||||
}
|
||||
|
||||
var match;
|
||||
if(!in_array(state) && (match=stream.match(openers, false))) {
|
||||
state.scopes.push(match);
|
||||
}
|
||||
|
||||
if(!in_array(state) && stream.match(closers, false)) {
|
||||
state.scopes.pop();
|
||||
}
|
||||
|
||||
if(in_array(state)) {
|
||||
if(stream.match(/^end/)) {
|
||||
return 'number';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(stream.match(/^=>/)) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
|
||||
// Handle Number Literals
|
||||
if (stream.match(/^[0-9\.]/, false)) {
|
||||
var imMatcher = RegExp(/^im\b/);
|
||||
var floatLiteral = false;
|
||||
// Floats
|
||||
if (stream.match(/^\d*\.(?!\.)\d+([ef][\+\-]?\d+)?/i)) { floatLiteral = true; }
|
||||
if (stream.match(/^\d+\.(?!\.)\d*/)) { floatLiteral = true; }
|
||||
if (stream.match(/^\.\d+/)) { floatLiteral = true; }
|
||||
if (floatLiteral) {
|
||||
// Float literals may be "imaginary"
|
||||
stream.match(imMatcher);
|
||||
state.leaving_expr = true;
|
||||
return 'number';
|
||||
}
|
||||
// Integers
|
||||
var intLiteral = false;
|
||||
// Hex
|
||||
if (stream.match(/^0x[0-9a-f]+/i)) { intLiteral = true; }
|
||||
// Binary
|
||||
if (stream.match(/^0b[01]+/i)) { intLiteral = true; }
|
||||
// Octal
|
||||
if (stream.match(/^0o[0-7]+/i)) { intLiteral = true; }
|
||||
// Decimal
|
||||
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
|
||||
intLiteral = true;
|
||||
}
|
||||
// Zero by itself with no other piece of number.
|
||||
if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
|
||||
if (intLiteral) {
|
||||
// Integer literals may be "long"
|
||||
stream.match(imMatcher);
|
||||
state.leaving_expr = true;
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
|
||||
if(stream.match(/^(::)|(<:)/)) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
// Handle symbols
|
||||
if(!leaving_expr && stream.match(symbol)) {
|
||||
return 'string';
|
||||
}
|
||||
|
||||
// Handle operators and Delimiters
|
||||
if (stream.match(operators)) {
|
||||
return 'operator';
|
||||
}
|
||||
|
||||
|
||||
// Handle Strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
if (stream.match(macro)) {
|
||||
return 'meta';
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(delimiters)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(builtins)) {
|
||||
return 'builtin';
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
state.leaving_expr=true;
|
||||
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';
|
||||
|
||||
function tokenString(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"\\]/);
|
||||
if (stream.eat('\\')) {
|
||||
stream.next();
|
||||
if (singleline && stream.eol()) {
|
||||
return OUTCLASS;
|
||||
}
|
||||
} else if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
stream.eat(/['"]/);
|
||||
}
|
||||
}
|
||||
if (singleline) {
|
||||
if (parserConf.singleLineStringErrors) {
|
||||
return ERRORCLASS;
|
||||
} else {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
}
|
||||
return OUTCLASS;
|
||||
}
|
||||
tokenString.isString = true;
|
||||
return tokenString;
|
||||
}
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
indentInfo = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle '.' connected identifiers
|
||||
if (current === '.') {
|
||||
style = stream.match(identifiers, false) ? null : ERRORCLASS;
|
||||
if (style === null && state.lastStyle === 'meta') {
|
||||
// Apply 'meta' style to '.' connected identifiers when
|
||||
// appropriate.
|
||||
style = 'meta';
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var external = {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
scopes: [],
|
||||
leaving_expr: false
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var style = tokenLexer(stream, state);
|
||||
state.lastStyle = style;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var delta = 0;
|
||||
if(textAfter=="end" || textAfter=="]" || textAfter=="}" || textAfter=="else" || textAfter=="elseif" || textAfter=="catch" || textAfter=="finally") {
|
||||
delta = -1;
|
||||
}
|
||||
return (state.scopes.length + delta) * 4;
|
||||
},
|
||||
|
||||
lineComment: "#",
|
||||
fold: "indent",
|
||||
electricChars: "edlsifyh]}"
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
|
||||
CodeMirror.defineMIME("text/x-julia", "julia");
|
||||
|
||||
});
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Kotlin mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="kotlin.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Kotlin</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Kotlin mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
package org.wasabi.http
|
||||
|
||||
import java.util.concurrent.Executors
|
||||
import java.net.InetSocketAddress
|
||||
import org.wasabi.app.AppConfiguration
|
||||
import io.netty.bootstrap.ServerBootstrap
|
||||
import io.netty.channel.nio.NioEventLoopGroup
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel
|
||||
import org.wasabi.app.AppServer
|
||||
|
||||
public class HttpServer(private val appServer: AppServer) {
|
||||
|
||||
val bootstrap: ServerBootstrap
|
||||
val primaryGroup: NioEventLoopGroup
|
||||
val workerGroup: NioEventLoopGroup
|
||||
|
||||
{
|
||||
// Define worker groups
|
||||
primaryGroup = NioEventLoopGroup()
|
||||
workerGroup = NioEventLoopGroup()
|
||||
|
||||
// Initialize bootstrap of server
|
||||
bootstrap = ServerBootstrap()
|
||||
|
||||
bootstrap.group(primaryGroup, workerGroup)
|
||||
bootstrap.channel(javaClass<NioServerSocketChannel>())
|
||||
bootstrap.childHandler(NettyPipelineInitializer(appServer))
|
||||
}
|
||||
|
||||
public fun start(wait: Boolean = true) {
|
||||
val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
|
||||
|
||||
if (wait) {
|
||||
channel?.closeFuture()?.sync()
|
||||
}
|
||||
}
|
||||
|
||||
public fun stop() {
|
||||
// Shutdown all event loops
|
||||
primaryGroup.shutdownGracefully()
|
||||
workerGroup.shutdownGracefully()
|
||||
|
||||
// Wait till all threads are terminated
|
||||
primaryGroup.terminationFuture().sync()
|
||||
workerGroup.terminationFuture().sync()
|
||||
}
|
||||
}
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: {name: "kotlin"},
|
||||
lineNumbers: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
</script>
|
||||
<h3>Mode for Kotlin (http://kotlin.jetbrains.org/)</h3>
|
||||
<p>Developed by Hadi Hariri (https://github.com/hhariri).</p>
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-kotlin</code>.</p>
|
||||
</article>
|
||||
|
|
@ -1,280 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("kotlin", function (config, parserConfig) {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var multiLineStrings = parserConfig.multiLineStrings;
|
||||
|
||||
var keywords = words(
|
||||
"package continue return object while break class data trait throw super" +
|
||||
" when type this else This try val var fun for is in if do as true false null get set");
|
||||
var softKeywords = words("import" +
|
||||
" where by get set abstract enum open annotation override private public internal" +
|
||||
" protected catch out vararg inline finally final ref");
|
||||
var blockKeywords = words("catch class do else finally for if where try while enum");
|
||||
var atoms = words("null true false this");
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
// Wildcard import w/o trailing semicolon (import smth.*)
|
||||
if (ch == "." && stream.eat("*")) {
|
||||
return "word";
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
if (stream.eat(/eE/)) {
|
||||
stream.eat(/\+\-/);
|
||||
stream.eatWhile(/\d/);
|
||||
}
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize.push(tokenComment);
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
if (expectExpression(state.lastToken)) {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
}
|
||||
// Commented
|
||||
if (ch == "-" && stream.eat(">")) {
|
||||
curPunc = "->";
|
||||
return null;
|
||||
}
|
||||
if (/[\-+*&%=<>!?|\/~]/.test(ch)) {
|
||||
stream.eatWhile(/[\-+*&%=<>|~]/);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
|
||||
var cur = stream.current();
|
||||
if (atoms.propertyIsEnumerable(cur)) {
|
||||
return "atom";
|
||||
}
|
||||
if (softKeywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "softKeyword";
|
||||
}
|
||||
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
return "word";
|
||||
}
|
||||
|
||||
tokenBase.isBase = true;
|
||||
|
||||
function startString(quote, stream, state) {
|
||||
var tripleQuoted = false;
|
||||
if (quote != "/" && stream.eat(quote)) {
|
||||
if (stream.eat(quote)) tripleQuoted = true;
|
||||
else return "string";
|
||||
}
|
||||
function t(stream, state) {
|
||||
var escaped = false, next, end = !tripleQuoted;
|
||||
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
if (!tripleQuoted) {
|
||||
break;
|
||||
}
|
||||
if (stream.match(quote + quote)) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
|
||||
state.tokenize.push(tokenBaseUntilBrace());
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (next == "$" && !escaped && !stream.eat(" ")) {
|
||||
state.tokenize.push(tokenBaseUntilSpace());
|
||||
return "string";
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (multiLineStrings)
|
||||
state.tokenize.push(t);
|
||||
if (end) state.tokenize.pop();
|
||||
return "string";
|
||||
}
|
||||
|
||||
state.tokenize.push(t);
|
||||
return t(stream, state);
|
||||
}
|
||||
|
||||
function tokenBaseUntilBrace() {
|
||||
var depth = 1;
|
||||
|
||||
function t(stream, state) {
|
||||
if (stream.peek() == "}") {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length - 1](stream, state);
|
||||
}
|
||||
} else if (stream.peek() == "{") {
|
||||
depth++;
|
||||
}
|
||||
return tokenBase(stream, state);
|
||||
}
|
||||
|
||||
t.isBase = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
function tokenBaseUntilSpace() {
|
||||
function t(stream, state) {
|
||||
if (stream.eat(/[\w]/)) {
|
||||
var isWord = stream.eatWhile(/[\w]/);
|
||||
if (isWord) {
|
||||
state.tokenize.pop();
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
state.tokenize.pop();
|
||||
return "string";
|
||||
}
|
||||
|
||||
t.isBase = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize.pop();
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function expectExpression(last) {
|
||||
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
|
||||
last == "newstatement" || last == "keyword" || last == "proplabel";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function (basecolumn) {
|
||||
return {
|
||||
tokenize: [tokenBase],
|
||||
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true,
|
||||
lastToken: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
// Automatic semicolon insertion
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
|
||||
popContext(state);
|
||||
ctx = state.context;
|
||||
}
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = state.tokenize[state.tokenize.length - 1](stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
// Handle indentation for {x -> \n ... }
|
||||
else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
|
||||
popContext(state);
|
||||
state.context.align = false;
|
||||
}
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
state.lastToken = curPunc || style;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function (state, textAfter) {
|
||||
if (!state.tokenize[state.tokenize.length - 1].isBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") {
|
||||
return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
|
||||
}
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : config.indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-kotlin", "kotlin");
|
||||
|
||||
});
|
||||
|
|
@ -1,757 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror", require("../xml/xml")));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../xml/xml"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
|
||||
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
|
||||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
|
||||
var aliases = {
|
||||
html: "htmlmixed",
|
||||
js: "javascript",
|
||||
json: "application/json",
|
||||
c: "text/x-csrc",
|
||||
"c++": "text/x-c++src",
|
||||
java: "text/x-java",
|
||||
csharp: "text/x-csharp",
|
||||
"c#": "text/x-csharp",
|
||||
scala: "text/x-scala"
|
||||
};
|
||||
|
||||
var getMode = (function () {
|
||||
var i, modes = {}, mimes = {}, mime;
|
||||
|
||||
var list = [];
|
||||
for (var m in CodeMirror.modes)
|
||||
if (CodeMirror.modes.propertyIsEnumerable(m)) list.push(m);
|
||||
for (i = 0; i < list.length; i++) {
|
||||
modes[list[i]] = list[i];
|
||||
}
|
||||
var mimesList = [];
|
||||
for (var m in CodeMirror.mimeModes)
|
||||
if (CodeMirror.mimeModes.propertyIsEnumerable(m))
|
||||
mimesList.push({mime: m, mode: CodeMirror.mimeModes[m]});
|
||||
for (i = 0; i < mimesList.length; i++) {
|
||||
mime = mimesList[i].mime;
|
||||
mimes[mime] = mimesList[i].mime;
|
||||
}
|
||||
|
||||
for (var a in aliases) {
|
||||
if (aliases[a] in modes || aliases[a] in mimes)
|
||||
modes[a] = aliases[a];
|
||||
}
|
||||
|
||||
return function (lang) {
|
||||
return modes[lang] ? CodeMirror.getMode(cmCfg, modes[lang]) : null;
|
||||
};
|
||||
}());
|
||||
|
||||
// Should characters that affect highlighting be highlighted separate?
|
||||
// Does not include characters that will be output (such as `1.` and `-` for lists)
|
||||
if (modeCfg.highlightFormatting === undefined)
|
||||
modeCfg.highlightFormatting = false;
|
||||
|
||||
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
|
||||
// Excess `>` will emit `error` token.
|
||||
if (modeCfg.maxBlockquoteDepth === undefined)
|
||||
modeCfg.maxBlockquoteDepth = 0;
|
||||
|
||||
// Should underscores in words open/close em/strong?
|
||||
if (modeCfg.underscoresBreakWords === undefined)
|
||||
modeCfg.underscoresBreakWords = true;
|
||||
|
||||
// Turn on fenced code blocks? ("```" to start/end)
|
||||
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
||||
|
||||
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||
|
||||
var codeDepth = 0;
|
||||
|
||||
var header = 'header'
|
||||
, code = 'comment'
|
||||
, quote = 'quote'
|
||||
, list1 = 'variable-2'
|
||||
, list2 = 'variable-3'
|
||||
, list3 = 'keyword'
|
||||
, hr = 'hr'
|
||||
, image = 'tag'
|
||||
, formatting = 'formatting'
|
||||
, linkinline = 'link'
|
||||
, linkemail = 'link'
|
||||
, linktext = 'link'
|
||||
, linkhref = 'string'
|
||||
, em = 'em'
|
||||
, strong = 'strong';
|
||||
|
||||
var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
|
||||
, ulRE = /^[*\-+]\s+/
|
||||
, olRE = /^[0-9]+\.\s+/
|
||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||
, atxHeaderRE = /^#+/
|
||||
, setextHeaderRE = /^(?:\={1,}|-{1,})$/
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(]+/;
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
state.f = state.inline = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
function switchBlock(stream, state, f) {
|
||||
state.f = state.block = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
|
||||
// Blocks
|
||||
|
||||
function blankLine(state) {
|
||||
// Reset linkTitle state
|
||||
state.linkTitle = false;
|
||||
// Reset EM state
|
||||
state.em = false;
|
||||
// Reset STRONG state
|
||||
state.strong = false;
|
||||
// Reset state.quote
|
||||
state.quote = 0;
|
||||
if (!htmlFound && state.f == htmlBlock) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
}
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
// Mark this line as blank
|
||||
state.thisLineHasContent = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function blockNormal(stream, state) {
|
||||
|
||||
var sol = stream.sol();
|
||||
|
||||
var prevLineIsList = (state.list !== false);
|
||||
if (state.list !== false && state.indentationDiff >= 0) { // Continued list
|
||||
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
||||
state.indentation -= state.indentationDiff;
|
||||
}
|
||||
state.list = null;
|
||||
} else if (state.list !== false && state.indentation > 0) {
|
||||
state.list = null;
|
||||
state.listDepth = Math.floor(state.indentation / 4);
|
||||
} else if (state.list !== false) { // No longer a list
|
||||
state.list = false;
|
||||
state.listDepth = 0;
|
||||
}
|
||||
|
||||
var match = null;
|
||||
if (state.indentationDiff >= 4) {
|
||||
state.indentation -= 4;
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
} else if (stream.eatSpace()) {
|
||||
return null;
|
||||
} else if (match = stream.match(atxHeaderRE)) {
|
||||
state.header = match[0].length <= 6 ? match[0].length : 6;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
|
||||
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (stream.eat('>')) {
|
||||
state.indentation++;
|
||||
state.quote = sol ? 1 : state.quote + 1;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
||||
stream.eatSpace();
|
||||
return getType(state);
|
||||
} else if (stream.peek() === '[') {
|
||||
return switchInline(stream, state, footnoteLink);
|
||||
} else if (stream.match(hrRE, true)) {
|
||||
return hr;
|
||||
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||
var listType = null;
|
||||
if (stream.match(ulRE, true)) {
|
||||
listType = 'ul';
|
||||
} else {
|
||||
stream.match(olRE, true);
|
||||
listType = 'ol';
|
||||
}
|
||||
state.indentation += 4;
|
||||
state.list = true;
|
||||
state.listDepth++;
|
||||
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
||||
state.taskList = true;
|
||||
}
|
||||
state.f = state.inline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||
return getType(state);
|
||||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```([\w+#]*)/, true)) {
|
||||
// try switching mode
|
||||
state.localMode = getMode(RegExp.$1);
|
||||
if (state.localMode) state.localState = state.localMode.startState();
|
||||
switchBlock(stream, state, local);
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
return switchInline(stream, state, state.inline);
|
||||
}
|
||||
|
||||
function htmlBlock(stream, state) {
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
|
||||
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
state.htmlState = null;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
function local(stream, state) {
|
||||
if (stream.sol() && stream.match(/^```/, true)) {
|
||||
state.localMode = state.localState = null;
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
var returnType = getType(state);
|
||||
state.code = false;
|
||||
return returnType;
|
||||
} else if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState);
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
// Inline
|
||||
function getType(state) {
|
||||
var styles = [];
|
||||
|
||||
if (state.formatting) {
|
||||
styles.push(formatting);
|
||||
|
||||
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
||||
|
||||
for (var i = 0; i < state.formatting.length; i++) {
|
||||
styles.push(formatting + "-" + state.formatting[i]);
|
||||
|
||||
if (state.formatting[i] === "header") {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||
}
|
||||
|
||||
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
||||
// Add `error` instead if the maximum blockquote nesting depth is passed
|
||||
if (state.formatting[i] === "quote") {
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||
} else {
|
||||
styles.push("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.taskOpen) {
|
||||
styles.push("meta");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
if (state.taskClosed) {
|
||||
styles.push("property");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
if (state.linkHref) {
|
||||
styles.push(linkhref);
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
if (state.strong) { styles.push(strong); }
|
||||
if (state.em) { styles.push(em); }
|
||||
|
||||
if (state.linkText) { styles.push(linktext); }
|
||||
|
||||
if (state.code) { styles.push(code); }
|
||||
|
||||
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||
|
||||
if (state.quote) {
|
||||
styles.push(quote);
|
||||
|
||||
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(quote + "-" + state.quote);
|
||||
} else {
|
||||
styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.list !== false) {
|
||||
var listMod = (state.listDepth - 1) % 3;
|
||||
if (!listMod) {
|
||||
styles.push(list1);
|
||||
} else if (listMod === 1) {
|
||||
styles.push(list2);
|
||||
} else {
|
||||
styles.push(list3);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.trailingSpaceNewLine) {
|
||||
styles.push("trailing-space-new-line");
|
||||
} else if (state.trailingSpace) {
|
||||
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
||||
}
|
||||
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
function handleText(stream, state) {
|
||||
if (stream.match(textRE, true)) {
|
||||
return getType(state);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function inlineNormal(stream, state) {
|
||||
var style = state.text(stream, state);
|
||||
if (typeof style !== 'undefined')
|
||||
return style;
|
||||
|
||||
if (state.list) { // List marker (*, +, -, 1., etc)
|
||||
state.list = null;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (state.taskList) {
|
||||
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
|
||||
if (taskOpen) state.taskOpen = true;
|
||||
else state.taskClosed = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "task";
|
||||
state.taskList = false;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
state.taskOpen = false;
|
||||
state.taskClosed = false;
|
||||
|
||||
if (state.header && stream.match(/^#+$/, true)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
// Get sol() value now, before character is consumed
|
||||
var sol = stream.sol();
|
||||
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
if (modeCfg.highlightFormatting) {
|
||||
var type = getType(state);
|
||||
return type ? type + " formatting-escape" : "formatting-escape";
|
||||
}
|
||||
}
|
||||
|
||||
// Matches link titles present on next line
|
||||
if (state.linkTitle) {
|
||||
state.linkTitle = false;
|
||||
var matchCh = ch;
|
||||
if (ch === '(') {
|
||||
matchCh = ')';
|
||||
}
|
||||
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
||||
if (stream.match(new RegExp(regex), true)) {
|
||||
return linkhref;
|
||||
}
|
||||
}
|
||||
|
||||
// If this block is changed, it may need to be updated in GFM mode
|
||||
if (ch === '`') {
|
||||
var previousFormatting = state.formatting;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code";
|
||||
var t = getType(state);
|
||||
var before = stream.pos;
|
||||
stream.eatWhile('`');
|
||||
var difference = 1 + stream.pos - before;
|
||||
if (!state.code) {
|
||||
codeDepth = difference;
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
} else {
|
||||
if (difference === codeDepth) { // Must be exact
|
||||
state.code = false;
|
||||
return t;
|
||||
}
|
||||
state.formatting = previousFormatting;
|
||||
return getType(state);
|
||||
}
|
||||
} else if (state.code) {
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
||||
stream.match(/\[[^\]]*\]/);
|
||||
state.inline = state.f = linkHref;
|
||||
return image;
|
||||
}
|
||||
|
||||
if (ch === '[' && stream.match(/.*\](\(| ?\[)/, false)) {
|
||||
state.linkText = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === ']' && state.linkText) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
state.linkText = false;
|
||||
state.inline = state.f = linkHref;
|
||||
return type;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkemail;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\w/, false)) {
|
||||
if (stream.string.indexOf(">") != -1) {
|
||||
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
||||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
||||
state.md_inside = true;
|
||||
}
|
||||
}
|
||||
stream.backUp(1);
|
||||
state.htmlState = CodeMirror.startState(htmlMode);
|
||||
return switchBlock(stream, state, htmlBlock);
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\/\w*?>/)) {
|
||||
state.md_inside = false;
|
||||
return "tag";
|
||||
}
|
||||
|
||||
var ignoreUnderscore = false;
|
||||
if (!modeCfg.underscoresBreakWords) {
|
||||
if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
|
||||
var prevPos = stream.pos - 2;
|
||||
if (prevPos >= 0) {
|
||||
var prevCh = stream.string.charAt(prevPos);
|
||||
if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
|
||||
ignoreUnderscore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
|
||||
if (sol && stream.peek() === ' ') {
|
||||
// Do nothing, surrounded by newline and space
|
||||
} else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
var t = getType(state);
|
||||
state.strong = false;
|
||||
return t;
|
||||
} else if (!state.strong && stream.eat(ch)) { // Add STRONG
|
||||
state.strong = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
return getType(state);
|
||||
} else if (state.em === ch) { // Remove EM
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
var t = getType(state);
|
||||
state.em = false;
|
||||
return t;
|
||||
} else if (!state.em) { // Add EM
|
||||
state.em = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
return getType(state);
|
||||
}
|
||||
} else if (ch === ' ') {
|
||||
if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
|
||||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||
return getType(state);
|
||||
} else { // Not surrounded by spaces, back up pointer
|
||||
stream.backUp(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === ' ') {
|
||||
if (stream.match(/ +$/, false)) {
|
||||
state.trailingSpace++;
|
||||
} else if (state.trailingSpace) {
|
||||
state.trailingSpaceNewLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
function linkInline(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === ">") {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
stream.match(/^[^>]+/, true);
|
||||
|
||||
return linkinline;
|
||||
}
|
||||
|
||||
function linkHref(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
var ch = stream.next();
|
||||
if (ch === '(' || ch === '[') {
|
||||
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
}
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function getLinkHrefInside(endChar) {
|
||||
return function(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === endChar) {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
var returnState = getType(state);
|
||||
state.linkHref = false;
|
||||
return returnState;
|
||||
}
|
||||
|
||||
if (stream.match(inlineRE(endChar), true)) {
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
};
|
||||
}
|
||||
|
||||
function footnoteLink(stream, state) {
|
||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||
state.f = footnoteLinkInside;
|
||||
stream.next(); // Consume [
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
state.linkText = true;
|
||||
return getType(state);
|
||||
}
|
||||
return switchInline(stream, state, inlineNormal);
|
||||
}
|
||||
|
||||
function footnoteLinkInside(stream, state) {
|
||||
if (stream.match(/^\]:/, true)) {
|
||||
state.f = state.inline = footnoteUrl;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var returnType = getType(state);
|
||||
state.linkText = false;
|
||||
return returnType;
|
||||
}
|
||||
|
||||
stream.match(/^[^\]]+/, true);
|
||||
|
||||
return linktext;
|
||||
}
|
||||
|
||||
function footnoteUrl(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
// Match URL
|
||||
stream.match(/^[^\s]+/, true);
|
||||
// Check for link title
|
||||
if (stream.peek() === undefined) { // End of line, set flag to check next line
|
||||
state.linkTitle = true;
|
||||
} else { // More content on line, check if link title
|
||||
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||
}
|
||||
state.f = state.inline = inlineNormal;
|
||||
return linkhref;
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
function inlineRE(endChar) {
|
||||
if (!savedInlineRE[endChar]) {
|
||||
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
|
||||
endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
// Match any non-endChar, escaped character, as well as the closing
|
||||
// endChar.
|
||||
savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
|
||||
}
|
||||
return savedInlineRE[endChar];
|
||||
}
|
||||
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {
|
||||
f: blockNormal,
|
||||
|
||||
prevLineHasContent: false,
|
||||
thisLineHasContent: false,
|
||||
|
||||
block: blockNormal,
|
||||
htmlState: null,
|
||||
indentation: 0,
|
||||
|
||||
inline: inlineNormal,
|
||||
text: handleText,
|
||||
|
||||
formatting: false,
|
||||
linkText: false,
|
||||
linkHref: false,
|
||||
linkTitle: false,
|
||||
em: false,
|
||||
strong: false,
|
||||
header: 0,
|
||||
taskList: false,
|
||||
list: false,
|
||||
listDepth: 0,
|
||||
quote: 0,
|
||||
trailingSpace: 0,
|
||||
trailingSpaceNewLine: false
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(s) {
|
||||
return {
|
||||
f: s.f,
|
||||
|
||||
prevLineHasContent: s.prevLineHasContent,
|
||||
thisLineHasContent: s.thisLineHasContent,
|
||||
|
||||
block: s.block,
|
||||
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||
indentation: s.indentation,
|
||||
|
||||
localMode: s.localMode,
|
||||
localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
|
||||
|
||||
inline: s.inline,
|
||||
text: s.text,
|
||||
formatting: false,
|
||||
linkTitle: s.linkTitle,
|
||||
em: s.em,
|
||||
strong: s.strong,
|
||||
header: s.header,
|
||||
taskList: s.taskList,
|
||||
list: s.list,
|
||||
listDepth: s.listDepth,
|
||||
quote: s.quote,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
|
||||
// Reset state.formatting
|
||||
state.formatting = false;
|
||||
|
||||
if (stream.sol()) {
|
||||
var forceBlankLine = stream.match(/^\s*$/, true) || state.header;
|
||||
|
||||
// Reset state.header
|
||||
state.header = 0;
|
||||
|
||||
if (forceBlankLine) {
|
||||
state.prevLineHasContent = false;
|
||||
return blankLine(state);
|
||||
} else {
|
||||
state.prevLineHasContent = state.thisLineHasContent;
|
||||
state.thisLineHasContent = true;
|
||||
}
|
||||
|
||||
// Reset state.taskList
|
||||
state.taskList = false;
|
||||
|
||||
// Reset state.code
|
||||
state.code = false;
|
||||
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
|
||||
state.f = state.block;
|
||||
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
||||
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
||||
if (difference > 4) difference = 4;
|
||||
var adjustedIndentation = state.indentation + difference;
|
||||
state.indentationDiff = adjustedIndentation - state.indentation;
|
||||
state.indentation = adjustedIndentation;
|
||||
if (indentation > 0) return null;
|
||||
}
|
||||
var result = state.f(stream, state);
|
||||
if (stream.start == stream.pos) return this.token(stream, state);
|
||||
else return result;
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
|
||||
if (state.localState) return {state: state.localState, mode: state.localMode};
|
||||
return {state: state, mode: mode};
|
||||
},
|
||||
|
||||
blankLine: blankLine,
|
||||
|
||||
getType: getType,
|
||||
|
||||
fold: "markdown"
|
||||
};
|
||||
return mode;
|
||||
}, "xml");
|
||||
|
||||
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
|
||||
});
|
||||
|
|
@ -1,754 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
|
||||
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
FT("formatting_emAsterisk",
|
||||
"[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
|
||||
|
||||
FT("formatting_emUnderscore",
|
||||
"[em&formatting&formatting-em _][em foo][em&formatting&formatting-em _]");
|
||||
|
||||
FT("formatting_strongAsterisk",
|
||||
"[strong&formatting&formatting-strong **][strong foo][strong&formatting&formatting-strong **]");
|
||||
|
||||
FT("formatting_strongUnderscore",
|
||||
"[strong&formatting&formatting-strong __][strong foo][strong&formatting&formatting-strong __]");
|
||||
|
||||
FT("formatting_codeBackticks",
|
||||
"[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
|
||||
|
||||
FT("formatting_doubleBackticks",
|
||||
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
|
||||
|
||||
FT("formatting_atxHeader",
|
||||
"[header&header-1&formatting&formatting-header&formatting-header-1 #][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]");
|
||||
|
||||
FT("formatting_setextHeader",
|
||||
"foo",
|
||||
"[header&header-1&formatting&formatting-header&formatting-header-1 =]");
|
||||
|
||||
FT("formatting_blockquote",
|
||||
"[quote"e-1&formatting&formatting-quote&formatting-quote-1 > ][quote"e-1 foo]");
|
||||
|
||||
FT("formatting_list",
|
||||
"[variable-2&formatting&formatting-list&formatting-list-ul - ][variable-2 foo]");
|
||||
FT("formatting_list",
|
||||
"[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]");
|
||||
|
||||
FT("formatting_link",
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string (][string http://example.com/][string&formatting&formatting-link-string )]");
|
||||
|
||||
FT("formatting_linkReference",
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string [][string bar][string&formatting&formatting-link-string ]]]",
|
||||
"[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string http://example.com/]");
|
||||
|
||||
FT("formatting_linkWeb",
|
||||
"[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]");
|
||||
|
||||
FT("formatting_linkEmail",
|
||||
"[link&formatting&formatting-link <][link user@example.com][link&formatting&formatting-link >]");
|
||||
|
||||
FT("formatting_escape",
|
||||
"[formatting-escape \\*]");
|
||||
|
||||
MT("plainText",
|
||||
"foo");
|
||||
|
||||
// Don't style single trailing space
|
||||
MT("trailingSpace1",
|
||||
"foo ");
|
||||
|
||||
// Two or more trailing spaces should be styled with line break character
|
||||
MT("trailingSpace2",
|
||||
"foo[trailing-space-a ][trailing-space-new-line ]");
|
||||
|
||||
MT("trailingSpace3",
|
||||
"foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]");
|
||||
|
||||
MT("trailingSpace4",
|
||||
"foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]");
|
||||
|
||||
// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
|
||||
MT("codeBlocksUsing4Spaces",
|
||||
" [comment foo]");
|
||||
|
||||
// Code blocks using 4 spaces with internal indentation
|
||||
MT("codeBlocksUsing4SpacesIndentation",
|
||||
" [comment bar]",
|
||||
" [comment hello]",
|
||||
" [comment world]",
|
||||
" [comment foo]",
|
||||
"bar");
|
||||
|
||||
// Code blocks using 4 spaces with internal indentation
|
||||
MT("codeBlocksUsing4SpacesIndentation",
|
||||
" foo",
|
||||
" [comment bar]",
|
||||
" [comment hello]",
|
||||
" [comment world]");
|
||||
|
||||
// Code blocks should end even after extra indented lines
|
||||
MT("codeBlocksWithTrailingIndentedLine",
|
||||
" [comment foo]",
|
||||
" [comment bar]",
|
||||
" [comment baz]",
|
||||
" ",
|
||||
"hello");
|
||||
|
||||
// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
|
||||
MT("codeBlocksUsing1Tab",
|
||||
"\t[comment foo]");
|
||||
|
||||
// Inline code using backticks
|
||||
MT("inlineCodeUsingBackticks",
|
||||
"foo [comment `bar`]");
|
||||
|
||||
// Block code using single backtick (shouldn't work)
|
||||
MT("blockCodeSingleBacktick",
|
||||
"[comment `]",
|
||||
"foo",
|
||||
"[comment `]");
|
||||
|
||||
// Unclosed backticks
|
||||
// Instead of simply marking as CODE, it would be nice to have an
|
||||
// incomplete flag for CODE, that is styled slightly different.
|
||||
MT("unclosedBackticks",
|
||||
"foo [comment `bar]");
|
||||
|
||||
// Per documentation: "To include a literal backtick character within a
|
||||
// code span, you can use multiple backticks as the opening and closing
|
||||
// delimiters"
|
||||
MT("doubleBackticks",
|
||||
"[comment ``foo ` bar``]");
|
||||
|
||||
// Tests based on Dingus
|
||||
// http://daringfireball.net/projects/markdown/dingus
|
||||
//
|
||||
// Multiple backticks within an inline code block
|
||||
MT("consecutiveBackticks",
|
||||
"[comment `foo```bar`]");
|
||||
|
||||
// Multiple backticks within an inline code block with a second code block
|
||||
MT("consecutiveBackticks",
|
||||
"[comment `foo```bar`] hello [comment `world`]");
|
||||
|
||||
// Unclosed with several different groups of backticks
|
||||
MT("unclosedBackticks",
|
||||
"[comment ``foo ``` bar` hello]");
|
||||
|
||||
// Closed with several different groups of backticks
|
||||
MT("closedBackticks",
|
||||
"[comment ``foo ``` bar` hello``] world");
|
||||
|
||||
// atx headers
|
||||
// http://daringfireball.net/projects/markdown/syntax#header
|
||||
|
||||
MT("atxH1",
|
||||
"[header&header-1 # foo]");
|
||||
|
||||
MT("atxH2",
|
||||
"[header&header-2 ## foo]");
|
||||
|
||||
MT("atxH3",
|
||||
"[header&header-3 ### foo]");
|
||||
|
||||
MT("atxH4",
|
||||
"[header&header-4 #### foo]");
|
||||
|
||||
MT("atxH5",
|
||||
"[header&header-5 ##### foo]");
|
||||
|
||||
MT("atxH6",
|
||||
"[header&header-6 ###### foo]");
|
||||
|
||||
// H6 - 7x '#' should still be H6, per Dingus
|
||||
// http://daringfireball.net/projects/markdown/dingus
|
||||
MT("atxH6NotH7",
|
||||
"[header&header-6 ####### foo]");
|
||||
|
||||
// Inline styles should be parsed inside headers
|
||||
MT("atxH1inline",
|
||||
"[header&header-1 # foo ][header&header-1&em *bar*]");
|
||||
|
||||
// Setext headers - H1, H2
|
||||
// Per documentation, "Any number of underlining =’s or -’s will work."
|
||||
// http://daringfireball.net/projects/markdown/syntax#header
|
||||
// Ideally, the text would be marked as `header` as well, but this is
|
||||
// not really feasible at the moment. So, instead, we're testing against
|
||||
// what works today, to avoid any regressions.
|
||||
//
|
||||
// Check if single underlining = works
|
||||
MT("setextH1",
|
||||
"foo",
|
||||
"[header&header-1 =]");
|
||||
|
||||
// Check if 3+ ='s work
|
||||
MT("setextH1",
|
||||
"foo",
|
||||
"[header&header-1 ===]");
|
||||
|
||||
// Check if single underlining - works
|
||||
MT("setextH2",
|
||||
"foo",
|
||||
"[header&header-2 -]");
|
||||
|
||||
// Check if 3+ -'s work
|
||||
MT("setextH2",
|
||||
"foo",
|
||||
"[header&header-2 ---]");
|
||||
|
||||
// Single-line blockquote with trailing space
|
||||
MT("blockquoteSpace",
|
||||
"[quote"e-1 > foo]");
|
||||
|
||||
// Single-line blockquote
|
||||
MT("blockquoteNoSpace",
|
||||
"[quote"e-1 >foo]");
|
||||
|
||||
// No blank line before blockquote
|
||||
MT("blockquoteNoBlankLine",
|
||||
"foo",
|
||||
"[quote"e-1 > bar]");
|
||||
|
||||
// Nested blockquote
|
||||
MT("blockquoteSpace",
|
||||
"[quote"e-1 > foo]",
|
||||
"[quote"e-1 >][quote"e-2 > foo]",
|
||||
"[quote"e-1 >][quote"e-2 >][quote"e-3 > foo]");
|
||||
|
||||
// Single-line blockquote followed by normal paragraph
|
||||
MT("blockquoteThenParagraph",
|
||||
"[quote"e-1 >foo]",
|
||||
"",
|
||||
"bar");
|
||||
|
||||
// Multi-line blockquote (lazy mode)
|
||||
MT("multiBlockquoteLazy",
|
||||
"[quote"e-1 >foo]",
|
||||
"[quote"e-1 bar]");
|
||||
|
||||
// Multi-line blockquote followed by normal paragraph (lazy mode)
|
||||
MT("multiBlockquoteLazyThenParagraph",
|
||||
"[quote"e-1 >foo]",
|
||||
"[quote"e-1 bar]",
|
||||
"",
|
||||
"hello");
|
||||
|
||||
// Multi-line blockquote (non-lazy mode)
|
||||
MT("multiBlockquote",
|
||||
"[quote"e-1 >foo]",
|
||||
"[quote"e-1 >bar]");
|
||||
|
||||
// Multi-line blockquote followed by normal paragraph (non-lazy mode)
|
||||
MT("multiBlockquoteThenParagraph",
|
||||
"[quote"e-1 >foo]",
|
||||
"[quote"e-1 >bar]",
|
||||
"",
|
||||
"hello");
|
||||
|
||||
// Check list types
|
||||
|
||||
MT("listAsterisk",
|
||||
"foo",
|
||||
"bar",
|
||||
"",
|
||||
"[variable-2 * foo]",
|
||||
"[variable-2 * bar]");
|
||||
|
||||
MT("listPlus",
|
||||
"foo",
|
||||
"bar",
|
||||
"",
|
||||
"[variable-2 + foo]",
|
||||
"[variable-2 + bar]");
|
||||
|
||||
MT("listDash",
|
||||
"foo",
|
||||
"bar",
|
||||
"",
|
||||
"[variable-2 - foo]",
|
||||
"[variable-2 - bar]");
|
||||
|
||||
MT("listNumber",
|
||||
"foo",
|
||||
"bar",
|
||||
"",
|
||||
"[variable-2 1. foo]",
|
||||
"[variable-2 2. bar]");
|
||||
|
||||
// Lists require a preceding blank line (per Dingus)
|
||||
MT("listBogus",
|
||||
"foo",
|
||||
"1. bar",
|
||||
"2. hello");
|
||||
|
||||
// List after header
|
||||
MT("listAfterHeader",
|
||||
"[header&header-1 # foo]",
|
||||
"[variable-2 - bar]");
|
||||
|
||||
// Formatting in lists (*)
|
||||
MT("listAsteriskFormatting",
|
||||
"[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
|
||||
"[variable-2 * ][variable-2&strong **foo**][variable-2 bar]",
|
||||
"[variable-2 * ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
|
||||
"[variable-2 * ][variable-2&comment `foo`][variable-2 bar]");
|
||||
|
||||
// Formatting in lists (+)
|
||||
MT("listPlusFormatting",
|
||||
"[variable-2 + ][variable-2&em *foo*][variable-2 bar]",
|
||||
"[variable-2 + ][variable-2&strong **foo**][variable-2 bar]",
|
||||
"[variable-2 + ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
|
||||
"[variable-2 + ][variable-2&comment `foo`][variable-2 bar]");
|
||||
|
||||
// Formatting in lists (-)
|
||||
MT("listDashFormatting",
|
||||
"[variable-2 - ][variable-2&em *foo*][variable-2 bar]",
|
||||
"[variable-2 - ][variable-2&strong **foo**][variable-2 bar]",
|
||||
"[variable-2 - ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
|
||||
"[variable-2 - ][variable-2&comment `foo`][variable-2 bar]");
|
||||
|
||||
// Formatting in lists (1.)
|
||||
MT("listNumberFormatting",
|
||||
"[variable-2 1. ][variable-2&em *foo*][variable-2 bar]",
|
||||
"[variable-2 2. ][variable-2&strong **foo**][variable-2 bar]",
|
||||
"[variable-2 3. ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
|
||||
"[variable-2 4. ][variable-2&comment `foo`][variable-2 bar]");
|
||||
|
||||
// Paragraph lists
|
||||
MT("listParagraph",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]");
|
||||
|
||||
// Multi-paragraph lists
|
||||
//
|
||||
// 4 spaces
|
||||
MT("listMultiParagraph",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
" [variable-2 hello]");
|
||||
|
||||
// 4 spaces, extra blank lines (should still be list, per Dingus)
|
||||
MT("listMultiParagraphExtra",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
"",
|
||||
" [variable-2 hello]");
|
||||
|
||||
// 4 spaces, plus 1 space (should still be list, per Dingus)
|
||||
MT("listMultiParagraphExtraSpace",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
" [variable-2 hello]",
|
||||
"",
|
||||
" [variable-2 world]");
|
||||
|
||||
// 1 tab
|
||||
MT("listTab",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
"\t[variable-2 hello]");
|
||||
|
||||
// No indent
|
||||
MT("listNoIndent",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
"hello");
|
||||
|
||||
// Blockquote
|
||||
MT("blockquote",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
" [variable-2"e"e-1 > hello]");
|
||||
|
||||
// Code block
|
||||
MT("blockquoteCode",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
"[variable-2 * bar]",
|
||||
"",
|
||||
" [comment > hello]",
|
||||
"",
|
||||
" [variable-2 world]");
|
||||
|
||||
// Code block followed by text
|
||||
MT("blockquoteCodeText",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-2 bar]",
|
||||
"",
|
||||
" [comment hello]",
|
||||
"",
|
||||
" [variable-2 world]");
|
||||
|
||||
// Nested list
|
||||
|
||||
MT("listAsteriskNested",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 * bar]");
|
||||
|
||||
MT("listPlusNested",
|
||||
"[variable-2 + foo]",
|
||||
"",
|
||||
" [variable-3 + bar]");
|
||||
|
||||
MT("listDashNested",
|
||||
"[variable-2 - foo]",
|
||||
"",
|
||||
" [variable-3 - bar]");
|
||||
|
||||
MT("listNumberNested",
|
||||
"[variable-2 1. foo]",
|
||||
"",
|
||||
" [variable-3 2. bar]");
|
||||
|
||||
MT("listMixed",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 + bar]",
|
||||
"",
|
||||
" [keyword - hello]",
|
||||
"",
|
||||
" [variable-2 1. world]");
|
||||
|
||||
MT("listBlockquote",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 + bar]",
|
||||
"",
|
||||
" [quote"e-1&variable-3 > hello]");
|
||||
|
||||
MT("listCode",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 + bar]",
|
||||
"",
|
||||
" [comment hello]");
|
||||
|
||||
// Code with internal indentation
|
||||
MT("listCodeIndentation",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [comment bar]",
|
||||
" [comment hello]",
|
||||
" [comment world]",
|
||||
" [comment foo]",
|
||||
" [variable-2 bar]");
|
||||
|
||||
// List nesting edge cases
|
||||
MT("listNested",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 * bar]",
|
||||
"",
|
||||
" [variable-2 hello]"
|
||||
);
|
||||
MT("listNested",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 * bar]",
|
||||
"",
|
||||
" [variable-3 * foo]"
|
||||
);
|
||||
|
||||
// Code followed by text
|
||||
MT("listCodeText",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [comment bar]",
|
||||
"",
|
||||
"hello");
|
||||
|
||||
// Following tests directly from official Markdown documentation
|
||||
// http://daringfireball.net/projects/markdown/syntax#hr
|
||||
|
||||
MT("hrSpace",
|
||||
"[hr * * *]");
|
||||
|
||||
MT("hr",
|
||||
"[hr ***]");
|
||||
|
||||
MT("hrLong",
|
||||
"[hr *****]");
|
||||
|
||||
MT("hrSpaceDash",
|
||||
"[hr - - -]");
|
||||
|
||||
MT("hrDashLong",
|
||||
"[hr ---------------------------------------]");
|
||||
|
||||
// Inline link with title
|
||||
MT("linkTitle",
|
||||
"[link [[foo]]][string (http://example.com/ \"bar\")] hello");
|
||||
|
||||
// Inline link without title
|
||||
MT("linkNoTitle",
|
||||
"[link [[foo]]][string (http://example.com/)] bar");
|
||||
|
||||
// Inline link with image
|
||||
MT("linkImage",
|
||||
"[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
|
||||
|
||||
// Inline link with Em
|
||||
MT("linkEm",
|
||||
"[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
|
||||
|
||||
// Inline link with Strong
|
||||
MT("linkStrong",
|
||||
"[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
|
||||
|
||||
// Inline link with EmStrong
|
||||
MT("linkEmStrong",
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
|
||||
|
||||
// Image with title
|
||||
MT("imageTitle",
|
||||
"[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
|
||||
|
||||
// Image without title
|
||||
MT("imageNoTitle",
|
||||
"[tag ![[foo]]][string (http://example.com/)] bar");
|
||||
|
||||
// Image with asterisks
|
||||
MT("imageAsterisks",
|
||||
"[tag ![[*foo*]]][string (http://example.com/)] bar");
|
||||
|
||||
// Not a link. Should be normal text due to square brackets being used
|
||||
// regularly in text, especially in quoted material, and no space is allowed
|
||||
// between square brackets and parentheses (per Dingus).
|
||||
MT("notALink",
|
||||
"[[foo]] (bar)");
|
||||
|
||||
// Reference-style links
|
||||
MT("linkReference",
|
||||
"[link [[foo]]][string [[bar]]] hello");
|
||||
|
||||
// Reference-style links with Em
|
||||
MT("linkReferenceEm",
|
||||
"[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
|
||||
|
||||
// Reference-style links with Strong
|
||||
MT("linkReferenceStrong",
|
||||
"[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
|
||||
|
||||
// Reference-style links with EmStrong
|
||||
MT("linkReferenceEmStrong",
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string [[bar]]] hello");
|
||||
|
||||
// Reference-style links with optional space separator (per docuentation)
|
||||
// "You can optionally use a space to separate the sets of brackets"
|
||||
MT("linkReferenceSpace",
|
||||
"[link [[foo]]] [string [[bar]]] hello");
|
||||
|
||||
// Should only allow a single space ("...use *a* space...")
|
||||
MT("linkReferenceDoubleSpace",
|
||||
"[[foo]] [[bar]] hello");
|
||||
|
||||
// Reference-style links with implicit link name
|
||||
MT("linkImplicit",
|
||||
"[link [[foo]]][string [[]]] hello");
|
||||
|
||||
// @todo It would be nice if, at some point, the document was actually
|
||||
// checked to see if the referenced link exists
|
||||
|
||||
// Link label, for reference-style links (taken from documentation)
|
||||
|
||||
MT("labelNoTitle",
|
||||
"[link [[foo]]:] [string http://example.com/]");
|
||||
|
||||
MT("labelIndented",
|
||||
" [link [[foo]]:] [string http://example.com/]");
|
||||
|
||||
MT("labelSpaceTitle",
|
||||
"[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
|
||||
|
||||
MT("labelDoubleTitle",
|
||||
"[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
|
||||
|
||||
MT("labelTitleDoubleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/ \"bar\"]");
|
||||
|
||||
MT("labelTitleSingleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/ 'bar']");
|
||||
|
||||
MT("labelTitleParenthese",
|
||||
"[link [[foo]]:] [string http://example.com/ (bar)]");
|
||||
|
||||
MT("labelTitleInvalid",
|
||||
"[link [[foo]]:] [string http://example.com/] bar");
|
||||
|
||||
MT("labelLinkAngleBrackets",
|
||||
"[link [[foo]]:] [string <http://example.com/> \"bar\"]");
|
||||
|
||||
MT("labelTitleNextDoubleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[string \"bar\"] hello");
|
||||
|
||||
MT("labelTitleNextSingleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[string 'bar'] hello");
|
||||
|
||||
MT("labelTitleNextParenthese",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[string (bar)] hello");
|
||||
|
||||
MT("labelTitleNextMixed",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"(bar\" hello");
|
||||
|
||||
MT("linkWeb",
|
||||
"[link <http://example.com/>] foo");
|
||||
|
||||
MT("linkWebDouble",
|
||||
"[link <http://example.com/>] foo [link <http://example.com/>]");
|
||||
|
||||
MT("linkEmail",
|
||||
"[link <user@example.com>] foo");
|
||||
|
||||
MT("linkEmailDouble",
|
||||
"[link <user@example.com>] foo [link <user@example.com>]");
|
||||
|
||||
MT("emAsterisk",
|
||||
"[em *foo*] bar");
|
||||
|
||||
MT("emUnderscore",
|
||||
"[em _foo_] bar");
|
||||
|
||||
MT("emInWordAsterisk",
|
||||
"foo[em *bar*]hello");
|
||||
|
||||
MT("emInWordUnderscore",
|
||||
"foo[em _bar_]hello");
|
||||
|
||||
// Per documentation: "...surround an * or _ with spaces, it’ll be
|
||||
// treated as a literal asterisk or underscore."
|
||||
|
||||
MT("emEscapedBySpaceIn",
|
||||
"foo [em _bar _ hello_] world");
|
||||
|
||||
MT("emEscapedBySpaceOut",
|
||||
"foo _ bar[em _hello_]world");
|
||||
|
||||
MT("emEscapedByNewline",
|
||||
"foo",
|
||||
"_ bar[em _hello_]world");
|
||||
|
||||
// Unclosed emphasis characters
|
||||
// Instead of simply marking as EM / STRONG, it would be nice to have an
|
||||
// incomplete flag for EM and STRONG, that is styled slightly different.
|
||||
MT("emIncompleteAsterisk",
|
||||
"foo [em *bar]");
|
||||
|
||||
MT("emIncompleteUnderscore",
|
||||
"foo [em _bar]");
|
||||
|
||||
MT("strongAsterisk",
|
||||
"[strong **foo**] bar");
|
||||
|
||||
MT("strongUnderscore",
|
||||
"[strong __foo__] bar");
|
||||
|
||||
MT("emStrongAsterisk",
|
||||
"[em *foo][em&strong **bar*][strong hello**] world");
|
||||
|
||||
MT("emStrongUnderscore",
|
||||
"[em _foo][em&strong __bar_][strong hello__] world");
|
||||
|
||||
// "...same character must be used to open and close an emphasis span.""
|
||||
MT("emStrongMixed",
|
||||
"[em _foo][em&strong **bar*hello__ world]");
|
||||
|
||||
MT("emStrongMixed",
|
||||
"[em *foo][em&strong __bar_hello** world]");
|
||||
|
||||
// These characters should be escaped:
|
||||
// \ backslash
|
||||
// ` backtick
|
||||
// * asterisk
|
||||
// _ underscore
|
||||
// {} curly braces
|
||||
// [] square brackets
|
||||
// () parentheses
|
||||
// # hash mark
|
||||
// + plus sign
|
||||
// - minus sign (hyphen)
|
||||
// . dot
|
||||
// ! exclamation mark
|
||||
|
||||
MT("escapeBacktick",
|
||||
"foo \\`bar\\`");
|
||||
|
||||
MT("doubleEscapeBacktick",
|
||||
"foo \\\\[comment `bar\\\\`]");
|
||||
|
||||
MT("escapeAsterisk",
|
||||
"foo \\*bar\\*");
|
||||
|
||||
MT("doubleEscapeAsterisk",
|
||||
"foo \\\\[em *bar\\\\*]");
|
||||
|
||||
MT("escapeUnderscore",
|
||||
"foo \\_bar\\_");
|
||||
|
||||
MT("doubleEscapeUnderscore",
|
||||
"foo \\\\[em _bar\\\\_]");
|
||||
|
||||
MT("escapeHash",
|
||||
"\\# foo");
|
||||
|
||||
MT("doubleEscapeHash",
|
||||
"\\\\# foo");
|
||||
|
||||
MT("escapeNewline",
|
||||
"\\",
|
||||
"[em *foo*]");
|
||||
|
||||
|
||||
// Tests to make sure GFM-specific things aren't getting through
|
||||
|
||||
MT("taskList",
|
||||
"[variable-2 * [ ]] bar]");
|
||||
|
||||
MT("fencedCodeBlocks",
|
||||
"[comment ```]",
|
||||
"foo",
|
||||
"[comment ```]");
|
||||
|
||||
// Tests that require XML mode
|
||||
|
||||
MT("xmlMode",
|
||||
"[tag&bracket <][tag div][tag&bracket >]",
|
||||
"*foo*",
|
||||
"[tag&bracket <][tag http://github.com][tag&bracket />]",
|
||||
"[tag&bracket </][tag div][tag&bracket >]",
|
||||
"[link <http://github.com/>]");
|
||||
|
||||
MT("xmlModeWithMarkdownInside",
|
||||
"[tag&bracket <][tag div] [attribute markdown]=[string 1][tag&bracket >]",
|
||||
"[em *foo*]",
|
||||
"[link <http://github.com/>]",
|
||||
"[tag </div>]",
|
||||
"[link <http://github.com/>]",
|
||||
"[tag&bracket <][tag div][tag&bracket >]",
|
||||
"[tag&bracket </][tag div][tag&bracket >]");
|
||||
|
||||
})();
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.modeInfo = [
|
||||
{name: "APL", mime: "text/apl", mode: "apl"},
|
||||
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"},
|
||||
{name: "C", mime: "text/x-csrc", mode: "clike"},
|
||||
{name: "C++", mime: "text/x-c++src", mode: "clike"},
|
||||
{name: "Cobol", mime: "text/x-cobol", mode: "cobol"},
|
||||
{name: "Java", mime: "text/x-java", mode: "clike"},
|
||||
{name: "C#", mime: "text/x-csharp", mode: "clike"},
|
||||
{name: "Scala", mime: "text/x-scala", mode: "clike"},
|
||||
{name: "Clojure", mime: "text/x-clojure", mode: "clojure"},
|
||||
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript"},
|
||||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp"},
|
||||
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"},
|
||||
{name: "CSS", mime: "text/css", mode: "css"},
|
||||
{name: "D", mime: "text/x-d", mode: "d"},
|
||||
{name: "diff", mime: "text/x-diff", mode: "diff"},
|
||||
{name: "DTD", mime: "application/xml-dtd", mode: "dtd"},
|
||||
{name: "Dylan", mime: "text/x-dylan", mode: "dylan"},
|
||||
{name: "ECL", mime: "text/x-ecl", mode: "ecl"},
|
||||
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel"},
|
||||
{name: "Erlang", mime: "text/x-erlang", mode: "erlang"},
|
||||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran"},
|
||||
{name: "F#", mime: "text/x-fsharp", mode: "mllike"},
|
||||
{name: "Gas", mime: "text/x-gas", mode: "gas"},
|
||||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin"},
|
||||
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"},
|
||||
{name: "Go", mime: "text/x-go", mode: "go"},
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy"},
|
||||
{name: "HAML", mime: "text/x-haml", mode: "haml"},
|
||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell"},
|
||||
{name: "Haxe", mime: "text/x-haxe", mode: "haxe"},
|
||||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded"},
|
||||
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded"},
|
||||
{name: "JavaServer Pages", mime: "application/x-jsp", mode: "htmlembedded"},
|
||||
{name: "HTML", mime: "text/html", mode: "htmlmixed"},
|
||||
{name: "HTTP", mime: "message/http", mode: "http"},
|
||||
{name: "Jade", mime: "text/x-jade", mode: "jade"},
|
||||
{name: "JavaScript", mime: "text/javascript", mode: "javascript"},
|
||||
{name: "JavaScript", mime: "application/javascript", mode: "javascript"},
|
||||
{name: "JSON", mime: "application/x-json", mode: "javascript"},
|
||||
{name: "JSON", mime: "application/json", mode: "javascript"},
|
||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript"},
|
||||
{name: "TypeScript", mime: "application/typescript", mode: "javascript"},
|
||||
{name: "Jinja2", mime: null, mode: "jinja2"},
|
||||
{name: "Julia", mime: "text/x-julia", mode: "julia"},
|
||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin"},
|
||||
{name: "LESS", mime: "text/x-less", mode: "css"},
|
||||
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript"},
|
||||
{name: "Lua", mime: "text/x-lua", mode: "lua"},
|
||||
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown"},
|
||||
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
|
||||
{name: "Modelica", mime: "text/x-modelica", mode: "modelica"},
|
||||
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"},
|
||||
{name: "NTriples", mime: "text/n-triples", mode: "ntriples"},
|
||||
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike"},
|
||||
{name: "Octave", mime: "text/x-octave", mode: "octave"},
|
||||
{name: "Pascal", mime: "text/x-pascal", mode: "pascal"},
|
||||
{name: "PEG.js", mime: null, mode: "pegjs"},
|
||||
{name: "Perl", mime: "text/x-perl", mode: "perl"},
|
||||
{name: "PHP", mime: "text/x-php", mode: "php"},
|
||||
{name: "PHP(HTML)", mime: "application/x-httpd-php", mode: "php"},
|
||||
{name: "Pig", mime: "text/x-pig", mode: "pig"},
|
||||
{name: "Plain Text", mime: "text/plain", mode: "null"},
|
||||
{name: "Properties files", mime: "text/x-properties", mode: "properties"},
|
||||
{name: "Python", mime: "text/x-python", mode: "python"},
|
||||
{name: "Puppet", mime: "text/x-puppet", mode: "puppet"},
|
||||
{name: "Cython", mime: "text/x-cython", mode: "python"},
|
||||
{name: "R", mime: "text/x-rsrc", mode: "r"},
|
||||
{name: "reStructuredText", mime: "text/x-rst", mode: "rst"},
|
||||
{name: "Ruby", mime: "text/x-ruby", mode: "ruby"},
|
||||
{name: "Rust", mime: "text/x-rustsrc", mode: "rust"},
|
||||
{name: "Sass", mime: "text/x-sass", mode: "sass"},
|
||||
{name: "Scheme", mime: "text/x-scheme", mode: "scheme"},
|
||||
{name: "SCSS", mime: "text/x-scss", mode: "css"},
|
||||
{name: "Shell", mime: "text/x-sh", mode: "shell"},
|
||||
{name: "Sieve", mime: "application/sieve", mode: "sieve"},
|
||||
{name: "Slim", mime: "text/x-slim", mode: "slim"},
|
||||
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk"},
|
||||
{name: "Smarty", mime: "text/x-smarty", mode: "smarty"},
|
||||
{name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
|
||||
{name: "Solr", mime: "text/x-solr", mode: "solr"},
|
||||
{name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql"},
|
||||
{name: "SQL", mime: "text/x-sql", mode: "sql"},
|
||||
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
|
||||
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
|
||||
{name: "LaTeX", mime: "text/x-latex", mode: "stex"},
|
||||
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog"},
|
||||
{name: "Tcl", mime: "text/x-tcl", mode: "tcl"},
|
||||
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
|
||||
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
|
||||
{name: "TOML", mime: "text/x-toml", mode: "toml"},
|
||||
{name: "Turtle", mime: "text/turtle", mode: "turtle"},
|
||||
{name: "VB.NET", mime: "text/x-vb", mode: "vb"},
|
||||
{name: "VBScript", mime: "text/vbscript", mode: "vbscript"},
|
||||
{name: "Velocity", mime: "text/velocity", mode: "velocity"},
|
||||
{name: "Verilog", mime: "text/x-verilog", mode: "verilog"},
|
||||
{name: "XML", mime: "application/xml", mode: "xml"},
|
||||
{name: "XQuery", mime: "application/xquery", mode: "xquery"},
|
||||
{name: "YAML", mime: "text/x-yaml", mode: "yaml"},
|
||||
{name: "Z80", mime: "text/x-z80", mode: "z80"}
|
||||
];
|
||||
|
||||
});
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: NTriples mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="ntriples.js"></script>
|
||||
<style type="text/css">
|
||||
.CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">NTriples</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>NTriples mode</h2>
|
||||
<form>
|
||||
<textarea id="ntriples" name="ntriples">
|
||||
<http://Sub1> <http://pred1> <http://obj> .
|
||||
<http://Sub2> <http://pred2#an2> "literal 1" .
|
||||
<http://Sub3#an3> <http://pred3> _:bnode3 .
|
||||
_:bnode4 <http://pred4> "literal 2"@lang .
|
||||
_:bnode5 <http://pred5> "literal 3"^^<http://type> .
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("ntriples"), {});
|
||||
</script>
|
||||
<p><strong>MIME types defined:</strong> <code>text/n-triples</code>.</p>
|
||||
</article>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,14 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("divide_equal_operator",
|
||||
"[variable bar] [operator /=] [variable foo]");
|
||||
|
||||
MT("divide_equal_operator_no_spacing",
|
||||
"[variable foo][operator /=][number 42]");
|
||||
|
||||
})();
|
||||
|
|
@ -1,451 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("rust", function() {
|
||||
var indentUnit = 4, altIndentUnit = 2;
|
||||
var valKeywords = {
|
||||
"if": "if-style", "while": "if-style", "else": "else-style",
|
||||
"do": "else-style", "ret": "else-style", "fail": "else-style",
|
||||
"break": "atom", "cont": "atom", "const": "let", "resource": "fn",
|
||||
"let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
|
||||
"impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
|
||||
"as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
|
||||
"claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
|
||||
"export": "else-style", "copy": "op", "log": "op", "log_err": "op",
|
||||
"use": "op", "bind": "op", "self": "atom"
|
||||
};
|
||||
var typeKeywords = function() {
|
||||
var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
|
||||
var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" ");
|
||||
for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom";
|
||||
return keywords;
|
||||
}();
|
||||
var operatorChar = /[+\-*&%=<>!?|\.@]/;
|
||||
|
||||
// Tokenizer
|
||||
|
||||
// Used as scratch variable to communicate multiple values without
|
||||
// consing up tons of objects.
|
||||
var tcat, content;
|
||||
function r(tc, style) {
|
||||
tcat = tc;
|
||||
return style;
|
||||
}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"') {
|
||||
state.tokenize = tokenString;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (ch == "'") {
|
||||
tcat = "atom";
|
||||
if (stream.eat("\\")) {
|
||||
if (stream.skipTo("'")) { stream.next(); return "string"; }
|
||||
else { return "error"; }
|
||||
} else {
|
||||
stream.next();
|
||||
return stream.eat("'") ? "string" : "error";
|
||||
}
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("/")) { stream.skipToEnd(); return "comment"; }
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment(1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
if (ch == "#") {
|
||||
if (stream.eat("[")) { tcat = "open-attr"; return null; }
|
||||
stream.eatWhile(/\w/);
|
||||
return r("macro", "meta");
|
||||
}
|
||||
if (ch == ":" && stream.match(":<")) {
|
||||
return r("op", null);
|
||||
}
|
||||
if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) {
|
||||
var flp = false;
|
||||
if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) {
|
||||
stream.eatWhile(/\d/);
|
||||
if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); }
|
||||
if (stream.match(/^e[+\-]?\d+/i)) { flp = true; }
|
||||
}
|
||||
if (flp) stream.match(/^f(?:32|64)/);
|
||||
else stream.match(/^[ui](?:8|16|32|64)/);
|
||||
return r("atom", "number");
|
||||
}
|
||||
if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null);
|
||||
if (ch == "-" && stream.eat(">")) return r("->", null);
|
||||
if (ch.match(operatorChar)) {
|
||||
stream.eatWhile(operatorChar);
|
||||
return r("op", null);
|
||||
}
|
||||
stream.eatWhile(/\w/);
|
||||
content = stream.current();
|
||||
if (stream.match(/^::\w/)) {
|
||||
stream.backUp(1);
|
||||
return r("prefix", "variable-2");
|
||||
}
|
||||
if (state.keywords.propertyIsEnumerable(content))
|
||||
return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword");
|
||||
return r("name", "variable");
|
||||
}
|
||||
|
||||
function tokenString(stream, state) {
|
||||
var ch, escaped = false;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == '"' && !escaped) {
|
||||
state.tokenize = tokenBase;
|
||||
return r("atom", "string");
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
// Hack to not confuse the parser when a string is split in
|
||||
// pieces.
|
||||
return r("op", "string");
|
||||
}
|
||||
|
||||
function tokenComment(depth) {
|
||||
return function(stream, state) {
|
||||
var lastCh = null, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && lastCh == "*") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = tokenComment(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
if (ch == "*" && lastCh == "/") {
|
||||
state.tokenize = tokenComment(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
lastCh = ch;
|
||||
}
|
||||
return "comment";
|
||||
};
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
var cx = {state: null, stream: null, marked: null, cc: null};
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
function pushlex(type, info) {
|
||||
var result = function() {
|
||||
var state = cx.state;
|
||||
state.lexical = {indented: state.indented, column: cx.stream.column(),
|
||||
type: type, prev: state.lexical, info: info};
|
||||
};
|
||||
result.lex = true;
|
||||
return result;
|
||||
}
|
||||
function poplex() {
|
||||
var state = cx.state;
|
||||
if (state.lexical.prev) {
|
||||
if (state.lexical.type == ")")
|
||||
state.indented = state.lexical.indented;
|
||||
state.lexical = state.lexical.prev;
|
||||
}
|
||||
}
|
||||
function typecx() { cx.state.keywords = typeKeywords; }
|
||||
function valcx() { cx.state.keywords = valKeywords; }
|
||||
poplex.lex = typecx.lex = valcx.lex = true;
|
||||
|
||||
function commasep(comb, end) {
|
||||
function more(type) {
|
||||
if (type == ",") return cont(comb, more);
|
||||
if (type == end) return cont();
|
||||
return cont(more);
|
||||
}
|
||||
return function(type) {
|
||||
if (type == end) return cont();
|
||||
return pass(comb, more);
|
||||
};
|
||||
}
|
||||
|
||||
function stat_of(comb, tag) {
|
||||
return cont(pushlex("stat", tag), comb, poplex, block);
|
||||
}
|
||||
function block(type) {
|
||||
if (type == "}") return cont();
|
||||
if (type == "let") return stat_of(letdef1, "let");
|
||||
if (type == "fn") return stat_of(fndef);
|
||||
if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
|
||||
if (type == "enum") return stat_of(enumdef);
|
||||
if (type == "mod") return stat_of(mod);
|
||||
if (type == "iface") return stat_of(iface);
|
||||
if (type == "impl") return stat_of(impl);
|
||||
if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
|
||||
if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
|
||||
return pass(pushlex("stat"), expression, poplex, endstatement, block);
|
||||
}
|
||||
function endstatement(type) {
|
||||
if (type == ";") return cont();
|
||||
return pass();
|
||||
}
|
||||
function expression(type) {
|
||||
if (type == "atom" || type == "name") return cont(maybeop);
|
||||
if (type == "{") return cont(pushlex("}"), exprbrace, poplex);
|
||||
if (type.match(/[\[\(]/)) return matchBrackets(type, expression);
|
||||
if (type.match(/[\]\)\};,]/)) return pass();
|
||||
if (type == "if-style") return cont(expression, expression);
|
||||
if (type == "else-style" || type == "op") return cont(expression);
|
||||
if (type == "for") return cont(pattern, maybetype, inop, expression, expression);
|
||||
if (type == "alt") return cont(expression, altbody);
|
||||
if (type == "fn") return cont(fndef);
|
||||
if (type == "macro") return cont(macro);
|
||||
return cont();
|
||||
}
|
||||
function maybeop(type) {
|
||||
if (content == ".") return cont(maybeprop);
|
||||
if (content == "::<"){return cont(typarams, maybeop);}
|
||||
if (type == "op" || content == ":") return cont(expression);
|
||||
if (type == "(" || type == "[") return matchBrackets(type, expression);
|
||||
return pass();
|
||||
}
|
||||
function maybeprop() {
|
||||
if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
|
||||
return pass(expression);
|
||||
}
|
||||
function exprbrace(type) {
|
||||
if (type == "op") {
|
||||
if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
|
||||
if (content == "||") return cont(poplex, pushlex("}", "block"), block);
|
||||
}
|
||||
if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
|
||||
&& !cx.stream.match("::", false)))
|
||||
return pass(record_of(expression));
|
||||
return pass(block);
|
||||
}
|
||||
function record_of(comb) {
|
||||
function ro(type) {
|
||||
if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
|
||||
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
|
||||
if (type == ":") return cont(comb, ro);
|
||||
if (type == "}") return cont();
|
||||
return cont(ro);
|
||||
}
|
||||
return ro;
|
||||
}
|
||||
function blockvars(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(blockvars);}
|
||||
if (type == "op" && content == "|") return cont();
|
||||
return cont(blockvars);
|
||||
}
|
||||
|
||||
function letdef1(type) {
|
||||
if (type.match(/[\]\)\};]/)) return cont();
|
||||
if (content == "=") return cont(expression, letdef2);
|
||||
if (type == ",") return cont(letdef1);
|
||||
return pass(pattern, maybetype, letdef1);
|
||||
}
|
||||
function letdef2(type) {
|
||||
if (type.match(/[\]\)\};,]/)) return pass(letdef1);
|
||||
else return pass(expression, letdef2);
|
||||
}
|
||||
function maybetype(type) {
|
||||
if (type == ":") return cont(typecx, rtype, valcx);
|
||||
return pass();
|
||||
}
|
||||
function inop(type) {
|
||||
if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();}
|
||||
return pass();
|
||||
}
|
||||
function fndef(type) {
|
||||
if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
|
||||
if (type == "name") {cx.marked = "def"; return cont(fndef);}
|
||||
if (content == "<") return cont(typarams, fndef);
|
||||
if (type == "{") return pass(expression);
|
||||
if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
|
||||
if (type == "->") return cont(typecx, rtype, valcx, fndef);
|
||||
if (type == ";") return cont();
|
||||
return cont(fndef);
|
||||
}
|
||||
function tydef(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(tydef);}
|
||||
if (content == "<") return cont(typarams, tydef);
|
||||
if (content == "=") return cont(typecx, rtype, valcx);
|
||||
return cont(tydef);
|
||||
}
|
||||
function enumdef(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(enumdef);}
|
||||
if (content == "<") return cont(typarams, enumdef);
|
||||
if (content == "=") return cont(typecx, rtype, valcx, endstatement);
|
||||
if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
|
||||
return cont(enumdef);
|
||||
}
|
||||
function enumblock(type) {
|
||||
if (type == "}") return cont();
|
||||
if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
|
||||
if (content.match(/^\w+$/)) cx.marked = "def";
|
||||
return cont(enumblock);
|
||||
}
|
||||
function mod(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(mod);}
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
return pass();
|
||||
}
|
||||
function iface(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(iface);}
|
||||
if (content == "<") return cont(typarams, iface);
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
return pass();
|
||||
}
|
||||
function impl(type) {
|
||||
if (content == "<") return cont(typarams, impl);
|
||||
if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
|
||||
if (type == "name") {cx.marked = "def"; return cont(impl);}
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
return pass();
|
||||
}
|
||||
function typarams() {
|
||||
if (content == ">") return cont();
|
||||
if (content == ",") return cont(typarams);
|
||||
if (content == ":") return cont(rtype, typarams);
|
||||
return pass(rtype, typarams);
|
||||
}
|
||||
function argdef(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(argdef);}
|
||||
if (type == ":") return cont(typecx, rtype, valcx);
|
||||
return pass();
|
||||
}
|
||||
function rtype(type) {
|
||||
if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
|
||||
if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
|
||||
if (type == "atom") return cont(rtypemaybeparam);
|
||||
if (type == "op" || type == "obj") return cont(rtype);
|
||||
if (type == "fn") return cont(fntype);
|
||||
if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
|
||||
return matchBrackets(type, rtype);
|
||||
}
|
||||
function rtypemaybeparam() {
|
||||
if (content == "<") return cont(typarams);
|
||||
return pass();
|
||||
}
|
||||
function fntype(type) {
|
||||
if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype);
|
||||
if (type == "->") return cont(rtype);
|
||||
return pass();
|
||||
}
|
||||
function pattern(type) {
|
||||
if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);}
|
||||
if (type == "atom") return cont(patternmaybeop);
|
||||
if (type == "op") return cont(pattern);
|
||||
if (type.match(/[\]\)\};,]/)) return pass();
|
||||
return matchBrackets(type, pattern);
|
||||
}
|
||||
function patternmaybeop(type) {
|
||||
if (type == "op" && content == ".") return cont();
|
||||
if (content == "to") {cx.marked = "keyword"; return cont(pattern);}
|
||||
else return pass();
|
||||
}
|
||||
function altbody(type) {
|
||||
if (type == "{") return cont(pushlex("}", "alt"), altblock1, poplex);
|
||||
return pass();
|
||||
}
|
||||
function altblock1(type) {
|
||||
if (type == "}") return cont();
|
||||
if (type == "|") return cont(altblock1);
|
||||
if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);}
|
||||
if (type.match(/[\]\);,]/)) return cont(altblock1);
|
||||
return pass(pattern, altblock2);
|
||||
}
|
||||
function altblock2(type) {
|
||||
if (type == "{") return cont(pushlex("}", "alt"), block, poplex, altblock1);
|
||||
else return pass(altblock1);
|
||||
}
|
||||
|
||||
function macro(type) {
|
||||
if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression);
|
||||
return pass();
|
||||
}
|
||||
function matchBrackets(type, comb) {
|
||||
if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex);
|
||||
if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex);
|
||||
if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex);
|
||||
return cont();
|
||||
}
|
||||
|
||||
function parse(state, stream, style) {
|
||||
var cc = state.cc;
|
||||
// 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;
|
||||
|
||||
while (true) {
|
||||
var combinator = cc.length ? cc.pop() : block;
|
||||
if (combinator(tcat)) {
|
||||
while(cc.length && cc[cc.length - 1].lex)
|
||||
cc.pop()();
|
||||
return cx.marked || style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
cc: [],
|
||||
lexical: {indented: -indentUnit, column: 0, type: "top", align: false},
|
||||
keywords: valKeywords,
|
||||
indented: 0
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = false;
|
||||
state.indented = stream.indentation();
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
tcat = content = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = true;
|
||||
if (tcat == "prefix") return style;
|
||||
if (!content) content = stream.current();
|
||||
return parse(state, stream, style);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
|
||||
type = lexical.type, closing = firstChar == type;
|
||||
if (type == "stat") return lexical.indented + indentUnit;
|
||||
if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||
return lexical.indented + (closing ? 0 : (lexical.info == "alt" ? altIndentUnit : indentUnit));
|
||||
},
|
||||
|
||||
electricChars: "{}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-rustsrc", "rust");
|
||||
|
||||
});
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("sass", function(config) {
|
||||
function tokenRegexp(words) {
|
||||
return new RegExp("^" + words.join("|"));
|
||||
}
|
||||
|
||||
var keywords = ["true", "false", "null", "auto"];
|
||||
var keywordsRegexp = new RegExp("^" + keywords.join("|"));
|
||||
|
||||
var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-", "\\!=", "/", "\\*", "%", "and", "or", "not"];
|
||||
var opRegexp = tokenRegexp(operators);
|
||||
|
||||
var pseudoElementsRegexp = /^::?[\w\-]+/;
|
||||
|
||||
function urlTokens(stream, state) {
|
||||
var ch = stream.peek();
|
||||
|
||||
if (ch === ")") {
|
||||
stream.next();
|
||||
state.tokenizer = tokenBase;
|
||||
return "operator";
|
||||
} else if (ch === "(") {
|
||||
stream.next();
|
||||
stream.eatSpace();
|
||||
|
||||
return "operator";
|
||||
} else if (ch === "'" || ch === '"') {
|
||||
state.tokenizer = buildStringTokenizer(stream.next());
|
||||
return "string";
|
||||
} else {
|
||||
state.tokenizer = buildStringTokenizer(")", false);
|
||||
return "string";
|
||||
}
|
||||
}
|
||||
function comment(indentation, multiLine) {
|
||||
return function(stream, state) {
|
||||
if (stream.sol() && stream.indentation() <= indentation) {
|
||||
state.tokenizer = tokenBase;
|
||||
return tokenBase(stream, state);
|
||||
}
|
||||
|
||||
if (multiLine && stream.skipTo("*/")) {
|
||||
stream.next();
|
||||
stream.next();
|
||||
state.tokenizer = tokenBase;
|
||||
} else {
|
||||
stream.next();
|
||||
}
|
||||
|
||||
return "comment";
|
||||
};
|
||||
}
|
||||
|
||||
function buildStringTokenizer(quote, greedy) {
|
||||
if(greedy == null) { greedy = true; }
|
||||
|
||||
function stringTokenizer(stream, state) {
|
||||
var nextChar = stream.next();
|
||||
var peekChar = stream.peek();
|
||||
var previousChar = stream.string.charAt(stream.pos-2);
|
||||
|
||||
var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
|
||||
|
||||
if (endingString) {
|
||||
if (nextChar !== quote && greedy) { stream.next(); }
|
||||
state.tokenizer = tokenBase;
|
||||
return "string";
|
||||
} else if (nextChar === "#" && peekChar === "{") {
|
||||
state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
|
||||
stream.next();
|
||||
return "operator";
|
||||
} else {
|
||||
return "string";
|
||||
}
|
||||
}
|
||||
|
||||
return stringTokenizer;
|
||||
}
|
||||
|
||||
function buildInterpolationTokenizer(currentTokenizer) {
|
||||
return function(stream, state) {
|
||||
if (stream.peek() === "}") {
|
||||
stream.next();
|
||||
state.tokenizer = currentTokenizer;
|
||||
return "operator";
|
||||
} else {
|
||||
return tokenBase(stream, state);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function indent(state) {
|
||||
if (state.indentCount == 0) {
|
||||
state.indentCount++;
|
||||
var lastScopeOffset = state.scopes[0].offset;
|
||||
var currentOffset = lastScopeOffset + config.indentUnit;
|
||||
state.scopes.unshift({ offset:currentOffset });
|
||||
}
|
||||
}
|
||||
|
||||
function dedent(state) {
|
||||
if (state.scopes.length == 1) return;
|
||||
|
||||
state.scopes.shift();
|
||||
}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.peek();
|
||||
|
||||
// Comment
|
||||
if (stream.match("/*")) {
|
||||
state.tokenizer = comment(stream.indentation(), true);
|
||||
return state.tokenizer(stream, state);
|
||||
}
|
||||
if (stream.match("//")) {
|
||||
state.tokenizer = comment(stream.indentation(), false);
|
||||
return state.tokenizer(stream, state);
|
||||
}
|
||||
|
||||
// Interpolation
|
||||
if (stream.match("#{")) {
|
||||
state.tokenizer = buildInterpolationTokenizer(tokenBase);
|
||||
return "operator";
|
||||
}
|
||||
|
||||
if (ch === ".") {
|
||||
stream.next();
|
||||
|
||||
// Match class selectors
|
||||
if (stream.match(/^[\w-]+/)) {
|
||||
indent(state);
|
||||
return "atom";
|
||||
} else if (stream.peek() === "#") {
|
||||
indent(state);
|
||||
return "atom";
|
||||
} else {
|
||||
return "operator";
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === "#") {
|
||||
stream.next();
|
||||
|
||||
// Hex numbers
|
||||
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/))
|
||||
return "number";
|
||||
|
||||
// ID selectors
|
||||
if (stream.match(/^[\w-]+/)) {
|
||||
indent(state);
|
||||
return "atom";
|
||||
}
|
||||
|
||||
if (stream.peek() === "#") {
|
||||
indent(state);
|
||||
return "atom";
|
||||
}
|
||||
}
|
||||
|
||||
// Numbers
|
||||
if (stream.match(/^-?[0-9\.]+/))
|
||||
return "number";
|
||||
|
||||
// Units
|
||||
if (stream.match(/^(px|em|in)\b/))
|
||||
return "unit";
|
||||
|
||||
if (stream.match(keywordsRegexp))
|
||||
return "keyword";
|
||||
|
||||
if (stream.match(/^url/) && stream.peek() === "(") {
|
||||
state.tokenizer = urlTokens;
|
||||
return "atom";
|
||||
}
|
||||
|
||||
// Variables
|
||||
if (ch === "$") {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\w-]/);
|
||||
|
||||
if (stream.peek() === ":") {
|
||||
stream.next();
|
||||
return "variable-2";
|
||||
} else {
|
||||
return "variable-3";
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === "!") {
|
||||
stream.next();
|
||||
return stream.match(/^[\w]+/) ? "keyword": "operator";
|
||||
}
|
||||
|
||||
if (ch === "=") {
|
||||
stream.next();
|
||||
|
||||
// Match shortcut mixin definition
|
||||
if (stream.match(/^[\w-]+/)) {
|
||||
indent(state);
|
||||
return "meta";
|
||||
} else {
|
||||
return "operator";
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === "+") {
|
||||
stream.next();
|
||||
|
||||
// Match shortcut mixin definition
|
||||
if (stream.match(/^[\w-]+/))
|
||||
return "variable-3";
|
||||
else
|
||||
return "operator";
|
||||
}
|
||||
|
||||
// Indent Directives
|
||||
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
|
||||
indent(state);
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// Other Directives
|
||||
if (ch === "@") {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\w-]/);
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// Strings
|
||||
if (ch === '"' || ch === "'") {
|
||||
stream.next();
|
||||
state.tokenizer = buildStringTokenizer(ch);
|
||||
return "string";
|
||||
}
|
||||
|
||||
// Pseudo element selectors
|
||||
if (ch == ":" && stream.match(pseudoElementsRegexp))
|
||||
return "keyword";
|
||||
|
||||
// atoms
|
||||
if (stream.eatWhile(/[\w-&]/)) {
|
||||
// matches a property definition
|
||||
if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false))
|
||||
return "property";
|
||||
else
|
||||
return "atom";
|
||||
}
|
||||
|
||||
if (stream.match(opRegexp))
|
||||
return "operator";
|
||||
|
||||
// If we haven't returned by now, we move 1 character
|
||||
// and return an error
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
if (stream.sol()) state.indentCount = 0;
|
||||
var style = state.tokenizer(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
if (current === "@return")
|
||||
dedent(state);
|
||||
|
||||
if (style === "atom")
|
||||
indent(state);
|
||||
|
||||
if (style !== null) {
|
||||
var startOfToken = stream.pos - current.length;
|
||||
var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
|
||||
|
||||
var newScopes = [];
|
||||
|
||||
for (var i = 0; i < state.scopes.length; i++) {
|
||||
var scope = state.scopes[i];
|
||||
|
||||
if (scope.offset <= withCurrentIndent)
|
||||
newScopes.push(scope);
|
||||
}
|
||||
|
||||
state.scopes = newScopes;
|
||||
}
|
||||
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenizer: tokenBase,
|
||||
scopes: [{offset: 0, type: "sass"}],
|
||||
indentCount: 0,
|
||||
definedVars: [],
|
||||
definedMixins: []
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
state.lastToken = { style: style, content: stream.current() };
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state) {
|
||||
return state.scopes[0].offset;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-sass", "sass");
|
||||
|
||||
});
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode('shell', function() {
|
||||
|
||||
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) {
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
var sol = stream.sol();
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
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(stream.eol() || !/\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) {
|
||||
return tokenize(stream, state);
|
||||
},
|
||||
lineComment: '#'
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-sh', 'shell');
|
||||
|
||||
});
|
||||
|
|
@ -1,221 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* Smarty 2 and 3 mode.
|
||||
*/
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("smarty", function(config) {
|
||||
"use strict";
|
||||
|
||||
// our default settings; check to see if they're overridden
|
||||
var settings = {
|
||||
rightDelimiter: '}',
|
||||
leftDelimiter: '{',
|
||||
smartyVersion: 2 // for backward compatibility
|
||||
};
|
||||
if (config.hasOwnProperty("leftDelimiter")) {
|
||||
settings.leftDelimiter = config.leftDelimiter;
|
||||
}
|
||||
if (config.hasOwnProperty("rightDelimiter")) {
|
||||
settings.rightDelimiter = config.rightDelimiter;
|
||||
}
|
||||
if (config.hasOwnProperty("smartyVersion") && config.smartyVersion === 3) {
|
||||
settings.smartyVersion = 3;
|
||||
}
|
||||
|
||||
var keyFunctions = ["debug", "extends", "function", "include", "literal"];
|
||||
var last;
|
||||
var regs = {
|
||||
operatorChars: /[+\-*&%=<>!?]/,
|
||||
validIdentifier: /[a-zA-Z0-9_]/,
|
||||
stringChar: /['"]/
|
||||
};
|
||||
|
||||
var helpers = {
|
||||
cont: function(style, lastType) {
|
||||
last = lastType;
|
||||
return style;
|
||||
},
|
||||
chain: function(stream, state, parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// our various parsers
|
||||
var parsers = {
|
||||
|
||||
// the main tokenizer
|
||||
tokenizer: function(stream, state) {
|
||||
if (stream.match(settings.leftDelimiter, true)) {
|
||||
if (stream.eat("*")) {
|
||||
return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
|
||||
} else {
|
||||
// Smarty 3 allows { and } surrounded by whitespace to NOT slip into Smarty mode
|
||||
state.depth++;
|
||||
var isEol = stream.eol();
|
||||
var isFollowedByWhitespace = /\s/.test(stream.peek());
|
||||
if (settings.smartyVersion === 3 && settings.leftDelimiter === "{" && (isEol || isFollowedByWhitespace)) {
|
||||
state.depth--;
|
||||
return null;
|
||||
} else {
|
||||
state.tokenize = parsers.smarty;
|
||||
last = "startTag";
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
// parsing Smarty content
|
||||
smarty: function(stream, state) {
|
||||
if (stream.match(settings.rightDelimiter, true)) {
|
||||
if (settings.smartyVersion === 3) {
|
||||
state.depth--;
|
||||
if (state.depth <= 0) {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
}
|
||||
} else {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
}
|
||||
return helpers.cont("tag", null);
|
||||
}
|
||||
|
||||
if (stream.match(settings.leftDelimiter, true)) {
|
||||
state.depth++;
|
||||
return helpers.cont("tag", "startTag");
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "$") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("variable-2", "variable");
|
||||
} else if (ch == "|") {
|
||||
return helpers.cont("operator", "pipe");
|
||||
} else if (ch == ".") {
|
||||
return helpers.cont("operator", "property");
|
||||
} else if (regs.stringChar.test(ch)) {
|
||||
state.tokenize = parsers.inAttribute(ch);
|
||||
return helpers.cont("string", "string");
|
||||
} else if (regs.operatorChars.test(ch)) {
|
||||
stream.eatWhile(regs.operatorChars);
|
||||
return helpers.cont("operator", "operator");
|
||||
} else if (ch == "[" || ch == "]") {
|
||||
return helpers.cont("bracket", "bracket");
|
||||
} else if (ch == "(" || ch == ")") {
|
||||
return helpers.cont("bracket", "operator");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/\d/);
|
||||
return helpers.cont("number", "number");
|
||||
} else {
|
||||
|
||||
if (state.last == "variable") {
|
||||
if (ch == "@") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("property", "property");
|
||||
} else if (ch == "|") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("qualifier", "modifier");
|
||||
}
|
||||
} else if (state.last == "pipe") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("qualifier", "modifier");
|
||||
} else if (state.last == "whitespace") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("attribute", "modifier");
|
||||
} if (state.last == "property") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("property", null);
|
||||
} else if (/\s/.test(ch)) {
|
||||
last = "whitespace";
|
||||
return null;
|
||||
}
|
||||
|
||||
var str = "";
|
||||
if (ch != "/") {
|
||||
str += ch;
|
||||
}
|
||||
var c = null;
|
||||
while (c = stream.eat(regs.validIdentifier)) {
|
||||
str += c;
|
||||
}
|
||||
for (var i=0, j=keyFunctions.length; i<j; i++) {
|
||||
if (keyFunctions[i] == str) {
|
||||
return helpers.cont("keyword", "keyword");
|
||||
}
|
||||
}
|
||||
if (/\s/.test(ch)) {
|
||||
return null;
|
||||
}
|
||||
return helpers.cont("tag", "tag");
|
||||
}
|
||||
},
|
||||
|
||||
inAttribute: function(quote) {
|
||||
return function(stream, state) {
|
||||
var prevChar = null;
|
||||
var currChar = null;
|
||||
while (!stream.eol()) {
|
||||
currChar = stream.peek();
|
||||
if (stream.next() == quote && prevChar !== '\\') {
|
||||
state.tokenize = parsers.smarty;
|
||||
break;
|
||||
}
|
||||
prevChar = currChar;
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
},
|
||||
|
||||
inBlock: function(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// the public API for CodeMirror
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: parsers.tokenizer,
|
||||
mode: "smarty",
|
||||
last: null,
|
||||
depth: 0
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
state.last = last;
|
||||
return style;
|
||||
},
|
||||
electricChars: ""
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-smarty", "smarty");
|
||||
|
||||
});
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Smarty mixed mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../mode/xml/xml.js"></script>
|
||||
<script src="../../mode/javascript/javascript.js"></script>
|
||||
<script src="../../mode/css/css.js"></script>
|
||||
<script src="../../mode/htmlmixed/htmlmixed.js"></script>
|
||||
<script src="../../mode/smarty/smarty.js"></script>
|
||||
<script src="../../mode/smartymixed/smartymixed.js"></script>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Smarty mixed</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Smarty mixed mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
{**
|
||||
* @brief Smarty mixed mode
|
||||
* @author Ruslan Osmanov
|
||||
* @date 29.06.2013
|
||||
*}
|
||||
<html>
|
||||
<head>
|
||||
<title>{$title|htmlspecialchars|truncate:30}</title>
|
||||
</head>
|
||||
<body class="{$bodyclass}">
|
||||
{* Multiline smarty
|
||||
* comment, no {$variables} here
|
||||
*}
|
||||
{literal}
|
||||
{literal} is just an HTML text.
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var a = {$just_a_normal_js_object : "value"};
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode : "smartymixed",
|
||||
tabSize : 2,
|
||||
indentUnit : 2,
|
||||
indentWithTabs : false,
|
||||
lineNumbers : true,
|
||||
smartyVersion : 3
|
||||
});
|
||||
// ]]>
|
||||
</script>
|
||||
<style>
|
||||
/* CSS content
|
||||
{$no_smarty} */
|
||||
.some-class { font-weight: bolder; color: "orange"; }
|
||||
</style>
|
||||
{/literal}
|
||||
|
||||
{extends file="parent.tpl"}
|
||||
{include file="template.tpl"}
|
||||
|
||||
{* some example Smarty content *}
|
||||
{if isset($name) && $name == 'Blog'}
|
||||
This is a {$var}.
|
||||
{$integer = 4511}, {$array[] = "a"}, {$stringvar = "string"}
|
||||
{$integer = 4512} {$array[] = "a"} {$stringvar = "string"}
|
||||
{assign var='bob' value=$var.prop}
|
||||
{elseif $name == $foo}
|
||||
{function name=menu level=0}
|
||||
{foreach $data as $entry}
|
||||
{if is_array($entry)}
|
||||
- {$entry@key}
|
||||
{menu data=$entry level=$level+1}
|
||||
{else}
|
||||
{$entry}
|
||||
{* One
|
||||
* Two
|
||||
* Three
|
||||
*}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/function}
|
||||
{/if}
|
||||
</body>
|
||||
<!-- R.O. -->
|
||||
</html>
|
||||
</textarea></form>
|
||||
|
||||
<script type="text/javascript">
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode : "smartymixed",
|
||||
tabSize : 2,
|
||||
indentUnit : 2,
|
||||
indentWithTabs : false,
|
||||
lineNumbers : true,
|
||||
smartyVersion : 3,
|
||||
matchBrackets : true,
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>The Smarty mixed mode depends on the Smarty and HTML mixed modes. HTML
|
||||
mixed mode itself depends on XML, JavaScript, and CSS modes.</p>
|
||||
|
||||
<p>It takes the same options, as Smarty and HTML mixed modes.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-smarty</code>.</p>
|
||||
</article>
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* @file smartymixed.js
|
||||
* @brief Smarty Mixed Codemirror mode (Smarty + Mixed HTML)
|
||||
* @author Ruslan Osmanov <rrosmanov at gmail dot com>
|
||||
* @version 3.0
|
||||
* @date 05.07.2013
|
||||
*/
|
||||
|
||||
// Warning: Don't base other modes on this one. This here is a
|
||||
// terrible way to write a mixed mode.
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../smarty/smarty"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../smarty/smarty"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("smartymixed", function(config) {
|
||||
var htmlMixedMode = CodeMirror.getMode(config, "htmlmixed");
|
||||
var smartyMode = CodeMirror.getMode(config, "smarty");
|
||||
|
||||
var settings = {
|
||||
rightDelimiter: '}',
|
||||
leftDelimiter: '{'
|
||||
};
|
||||
|
||||
if (config.hasOwnProperty("leftDelimiter")) {
|
||||
settings.leftDelimiter = config.leftDelimiter;
|
||||
}
|
||||
if (config.hasOwnProperty("rightDelimiter")) {
|
||||
settings.rightDelimiter = config.rightDelimiter;
|
||||
}
|
||||
|
||||
function reEsc(str) { return str.replace(/[^\s\w]/g, "\\$&"); }
|
||||
|
||||
var reLeft = reEsc(settings.leftDelimiter), reRight = reEsc(settings.rightDelimiter);
|
||||
var regs = {
|
||||
smartyComment: new RegExp("^" + reRight + "\\*"),
|
||||
literalOpen: new RegExp(reLeft + "literal" + reRight),
|
||||
literalClose: new RegExp(reLeft + "\/literal" + reRight),
|
||||
hasLeftDelimeter: new RegExp(".*" + reLeft),
|
||||
htmlHasLeftDelimeter: new RegExp("[^<>]*" + reLeft)
|
||||
};
|
||||
|
||||
var helpers = {
|
||||
chain: function(stream, state, parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
},
|
||||
|
||||
cleanChain: function(stream, state, parser) {
|
||||
state.tokenize = null;
|
||||
state.localState = null;
|
||||
state.localMode = null;
|
||||
return (typeof parser == "string") ? (parser ? parser : null) : parser(stream, state);
|
||||
},
|
||||
|
||||
maybeBackup: function(stream, pat, style) {
|
||||
var cur = stream.current();
|
||||
var close = cur.search(pat),
|
||||
m;
|
||||
if (close > - 1) stream.backUp(cur.length - close);
|
||||
else if (m = cur.match(/<\/?$/)) {
|
||||
stream.backUp(cur.length);
|
||||
if (!stream.match(pat, false)) stream.match(cur[0]);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
};
|
||||
|
||||
var parsers = {
|
||||
html: function(stream, state) {
|
||||
if (!state.inLiteral && stream.match(regs.htmlHasLeftDelimeter, false) && state.htmlMixedState.htmlState.tagName === null) {
|
||||
state.tokenize = parsers.smarty;
|
||||
state.localMode = smartyMode;
|
||||
state.localState = smartyMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
|
||||
return helpers.maybeBackup(stream, settings.leftDelimiter, smartyMode.token(stream, state.localState));
|
||||
} else if (!state.inLiteral && stream.match(settings.leftDelimiter, false)) {
|
||||
state.tokenize = parsers.smarty;
|
||||
state.localMode = smartyMode;
|
||||
state.localState = smartyMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
|
||||
return helpers.maybeBackup(stream, settings.leftDelimiter, smartyMode.token(stream, state.localState));
|
||||
}
|
||||
return htmlMixedMode.token(stream, state.htmlMixedState);
|
||||
},
|
||||
|
||||
smarty: function(stream, state) {
|
||||
if (stream.match(settings.leftDelimiter, false)) {
|
||||
if (stream.match(regs.smartyComment, false)) {
|
||||
return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
|
||||
}
|
||||
} else if (stream.match(settings.rightDelimiter, false)) {
|
||||
stream.eat(settings.rightDelimiter);
|
||||
state.tokenize = parsers.html;
|
||||
state.localMode = htmlMixedMode;
|
||||
state.localState = state.htmlMixedState;
|
||||
return "tag";
|
||||
}
|
||||
|
||||
return helpers.maybeBackup(stream, settings.rightDelimiter, smartyMode.token(stream, state.localState));
|
||||
},
|
||||
|
||||
inBlock: function(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
helpers.cleanChain(stream, state, "");
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var state = htmlMixedMode.startState();
|
||||
return {
|
||||
token: parsers.html,
|
||||
localMode: null,
|
||||
localState: null,
|
||||
htmlMixedState: state,
|
||||
tokenize: null,
|
||||
inLiteral: false
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
var local = null, tok = (state.tokenize || state.token);
|
||||
if (state.localState) {
|
||||
local = CodeMirror.copyState((tok != parsers.html ? smartyMode : htmlMixedMode), state.localState);
|
||||
}
|
||||
return {
|
||||
token: state.token,
|
||||
tokenize: state.tokenize,
|
||||
localMode: state.localMode,
|
||||
localState: local,
|
||||
htmlMixedState: CodeMirror.copyState(htmlMixedMode, state.htmlMixedState),
|
||||
inLiteral: state.inLiteral
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.match(settings.leftDelimiter, false)) {
|
||||
if (!state.inLiteral && stream.match(regs.literalOpen, true)) {
|
||||
state.inLiteral = true;
|
||||
return "keyword";
|
||||
} else if (state.inLiteral && stream.match(regs.literalClose, true)) {
|
||||
state.inLiteral = false;
|
||||
return "keyword";
|
||||
}
|
||||
}
|
||||
if (state.inLiteral && state.localState != state.htmlMixedState) {
|
||||
state.tokenize = parsers.html;
|
||||
state.localMode = htmlMixedMode;
|
||||
state.localState = state.htmlMixedState;
|
||||
}
|
||||
|
||||
var style = (state.tokenize || state.token)(stream, state);
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.localMode == smartyMode
|
||||
|| (state.inLiteral && !state.localMode)
|
||||
|| regs.hasLeftDelimeter.test(textAfter)) {
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
return htmlMixedMode.indent(state.htmlMixedState, textAfter);
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
return {
|
||||
state: state.localState || state.htmlMixedState,
|
||||
mode: state.localMode || htmlMixedMode
|
||||
};
|
||||
}
|
||||
};
|
||||
}, "htmlmixed", "smarty");
|
||||
|
||||
CodeMirror.defineMIME("text/x-smarty", "smartymixed");
|
||||
// vim: et ts=2 sts=2 sw=2
|
||||
|
||||
});
|
||||
|
|
@ -1,392 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("sql", function(config, parserConfig) {
|
||||
"use strict";
|
||||
|
||||
var client = parserConfig.client || {},
|
||||
atoms = parserConfig.atoms || {"false": true, "true": true, "null": true},
|
||||
builtin = parserConfig.builtin || {},
|
||||
keywords = parserConfig.keywords || {},
|
||||
operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
|
||||
support = parserConfig.support || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true};
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
// call hooks from the mime type
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
|
||||
if (support.hexNumber == true &&
|
||||
((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
|
||||
|| (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/))) {
|
||||
// hex
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html
|
||||
return "number";
|
||||
} else if (support.binaryNumber == true &&
|
||||
(((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
|
||||
|| (ch == "0" && stream.match(/^b[01]+/)))) {
|
||||
// bitstring
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/bit-field-literals.html
|
||||
return "number";
|
||||
} else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
|
||||
// numbers
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html
|
||||
stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
|
||||
support.decimallessFloat == true && stream.eat('.');
|
||||
return "number";
|
||||
} else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) {
|
||||
// placeholders
|
||||
return "variable-3";
|
||||
} else if (ch == "'" || (ch == '"' && support.doubleQuote)) {
|
||||
// strings
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
|
||||
state.tokenize = tokenLiteral(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if ((((support.nCharCast == true && (ch == "n" || ch == "N"))
|
||||
|| (support.charsetCast == true && ch == "_" && stream.match(/[a-z][a-z0-9]*/i)))
|
||||
&& (stream.peek() == "'" || stream.peek() == '"'))) {
|
||||
// charset casting: _utf8'str', N'str', n'str'
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
|
||||
return "keyword";
|
||||
} else if (/^[\(\),\;\[\]]/.test(ch)) {
|
||||
// no highlightning
|
||||
return null;
|
||||
} else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) {
|
||||
// 1-line comment
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if ((support.commentHash && ch == "#")
|
||||
|| (ch == "-" && stream.eat("-") && (!support.commentSpaceRequired || stream.eat(" ")))) {
|
||||
// 1-line comments
|
||||
// ref: https://kb.askmonty.org/en/comment-syntax/
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "/" && stream.eat("*")) {
|
||||
// multi-line comments
|
||||
// ref: https://kb.askmonty.org/en/comment-syntax/
|
||||
state.tokenize = tokenComment;
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ".") {
|
||||
// .1 for 0.1
|
||||
if (support.zerolessFloat == true && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) {
|
||||
return "number";
|
||||
}
|
||||
// .table_name (ODBC)
|
||||
// // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html
|
||||
if (support.ODBCdotTable == true && stream.match(/^[a-zA-Z_]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
} else if (operatorChars.test(ch)) {
|
||||
// operators
|
||||
stream.eatWhile(operatorChars);
|
||||
return null;
|
||||
} else if (ch == '{' &&
|
||||
(stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/))) {
|
||||
// dates (weird ODBC syntax)
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
|
||||
return "number";
|
||||
} else {
|
||||
stream.eatWhile(/^[_\w\d]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
// dates (standard SQL syntax)
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
|
||||
if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+"[^"]*"/)))
|
||||
return "number";
|
||||
if (atoms.hasOwnProperty(word)) return "atom";
|
||||
if (builtin.hasOwnProperty(word)) return "builtin";
|
||||
if (keywords.hasOwnProperty(word)) return "keyword";
|
||||
if (client.hasOwnProperty(word)) return "string-2";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 'string', with char specified in quote escaped by '\'
|
||||
function tokenLiteral(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function tokenComment(stream, state) {
|
||||
while (true) {
|
||||
if (stream.skipTo("*")) {
|
||||
stream.next();
|
||||
if (stream.eat("/")) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function pushContext(stream, state, type) {
|
||||
state.context = {
|
||||
prev: state.context,
|
||||
indent: stream.indentation(),
|
||||
col: stream.column(),
|
||||
type: type
|
||||
};
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
state.indent = state.context.indent;
|
||||
state.context = state.context.prev;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: tokenBase, context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (state.context && state.context.align == null)
|
||||
state.context.align = false;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
var style = state.tokenize(stream, state);
|
||||
if (style == "comment") return style;
|
||||
|
||||
if (state.context && state.context.align == null)
|
||||
state.context.align = true;
|
||||
|
||||
var tok = stream.current();
|
||||
if (tok == "(")
|
||||
pushContext(stream, state, ")");
|
||||
else if (tok == "[")
|
||||
pushContext(stream, state, "]");
|
||||
else if (state.context && state.context.type == tok)
|
||||
popContext(state);
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var cx = state.context;
|
||||
if (!cx) return 0;
|
||||
var closing = textAfter.charAt(0) == cx.type;
|
||||
if (cx.align) return cx.col + (closing ? 0 : 1);
|
||||
else return cx.indent + (closing ? 0 : config.indentUnit);
|
||||
},
|
||||
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : null
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
// `identifier`
|
||||
function hookIdentifier(stream) {
|
||||
// MySQL/MariaDB identifiers
|
||||
// ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "`" && !stream.eat("`")) return "variable-2";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// variable token
|
||||
function hookVar(stream) {
|
||||
// variables
|
||||
// @@prefix.varName @varName
|
||||
// varName can be quoted with ` or ' or "
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html
|
||||
if (stream.eat("@")) {
|
||||
stream.match(/^session\./);
|
||||
stream.match(/^local\./);
|
||||
stream.match(/^global\./);
|
||||
}
|
||||
|
||||
if (stream.eat("'")) {
|
||||
stream.match(/^.*'/);
|
||||
return "variable-2";
|
||||
} else if (stream.eat('"')) {
|
||||
stream.match(/^.*"/);
|
||||
return "variable-2";
|
||||
} else if (stream.eat("`")) {
|
||||
stream.match(/^.*`/);
|
||||
return "variable-2";
|
||||
} else if (stream.match(/^[0-9a-zA-Z$\.\_]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// short client keyword token
|
||||
function hookClient(stream) {
|
||||
// \N means NULL
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/null-values.html
|
||||
if (stream.eat("N")) {
|
||||
return "atom";
|
||||
}
|
||||
// \g, etc
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html
|
||||
return stream.match(/^[a-zA-Z.#!?]/) ? "variable-2" : null;
|
||||
}
|
||||
|
||||
// these keywords are used by all SQL dialects (however, a mode can still overwrite it)
|
||||
var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from having in insert into is join like not on or order select set table union update values where ";
|
||||
|
||||
// turn a space-separated list into an array
|
||||
function set(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// A generic SQL Mode. It's not a standard, it just try to support what is generally supported
|
||||
CodeMirror.defineMIME("text/x-sql", {
|
||||
name: "sql",
|
||||
keywords: set(sqlKeywords + "begin"),
|
||||
builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mssql", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered"),
|
||||
builtin: set("bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table "),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date datetimeoffset datetime2 smalldatetime datetime time"),
|
||||
hooks: {
|
||||
"@": hookVar
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mysql", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general get global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
||||
builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=&|^]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"),
|
||||
hooks: {
|
||||
"@": hookVar,
|
||||
"`": hookIdentifier,
|
||||
"\\": hookClient
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mariadb", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "accessible action add after algorithm all always analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general generated get global grant grants group groupby_concat handler hard hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password persistent phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show shutdown signal slave slow smallint snapshot soft soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views virtual warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
||||
builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=&|^]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"),
|
||||
hooks: {
|
||||
"@": hookVar,
|
||||
"`": hookIdentifier,
|
||||
"\\": hookClient
|
||||
}
|
||||
});
|
||||
|
||||
// the query language used by Apache Cassandra is called CQL, but this mime type
|
||||
// is called Cassandra to avoid confusion with Contextual Query Language
|
||||
CodeMirror.defineMIME("text/x-cassandra", {
|
||||
name: "sql",
|
||||
client: { },
|
||||
keywords: set("use select from using consistency where limit first reversed first and in insert into values using consistency ttl update set delete truncate begin batch apply create keyspace with columnfamily primary key index on drop alter type add any one quorum all local_quorum each_quorum"),
|
||||
builtin: set("ascii bigint blob boolean counter decimal double float int text timestamp uuid varchar varint"),
|
||||
atoms: set("false true"),
|
||||
operatorChars: /^[<>=]/,
|
||||
dateSQL: { },
|
||||
support: set("commentSlashSlash decimallessFloat"),
|
||||
hooks: { }
|
||||
});
|
||||
|
||||
// this is based on Peter Raganitsch's 'plsql' mode
|
||||
CodeMirror.defineMIME("text/x-plsql", {
|
||||
name: "sql",
|
||||
client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"),
|
||||
keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"),
|
||||
builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"),
|
||||
operatorChars: /^[*+\-%<>!=~]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("doubleQuote nCharCast zerolessFloat binaryNumber hexNumber")
|
||||
});
|
||||
|
||||
// Created to support specific hive keywords
|
||||
CodeMirror.defineMIME("text/x-hive", {
|
||||
name: "sql",
|
||||
keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external false fetch fields fileformat first format formatted from full function functions grant group having hold_ddltime idxproperties if import in index indexes inpath inputdriver inputformat insert intersect into is items join keys lateral left like limit lines load local location lock locks mapjoin materialized minus msck no_drop nocompress not of offline on option or order out outer outputdriver outputformat overwrite partition partitioned partitions percent plus preserve procedure purge range rcfile read readonly reads rebuild recordreader recordwriter recover reduce regexp rename repair replace restrict revoke right rlike row schema schemas semi sequencefile serde serdeproperties set shared show show_database sort sorted ssl statistics stored streamtable table tables tablesample tblproperties temporary terminated textfile then tmp to touch transform trigger true unarchive undo union uniquejoin unlock update use using utc utc_tmestamp view when where while with"),
|
||||
builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date timestamp"),
|
||||
support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
|
||||
});
|
||||
}());
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
How Properties of Mime Types are used by SQL Mode
|
||||
=================================================
|
||||
|
||||
keywords:
|
||||
A list of keywords you want to be highlighted.
|
||||
functions:
|
||||
A list of function names you want to be highlighted.
|
||||
builtin:
|
||||
A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
|
||||
operatorChars:
|
||||
All characters that must be handled as operators.
|
||||
client:
|
||||
Commands parsed and executed by the client (not the server).
|
||||
support:
|
||||
A list of supported syntaxes which are not common, but are supported by more than 1 DBMS.
|
||||
* ODBCdotTable: .tableName
|
||||
* zerolessFloat: .1
|
||||
* doubleQuote
|
||||
* nCharCast: N'string'
|
||||
* charsetCast: _utf8'string'
|
||||
* commentHash: use # char for comments
|
||||
* commentSlashSlash: use // for comments
|
||||
* commentSpaceRequired: require a space after -- for comments
|
||||
atoms:
|
||||
Keywords that must be highlighted as atoms,. Some DBMS's support more atoms than others:
|
||||
UNKNOWN, INFINITY, UNDERFLOW, NaN...
|
||||
dateSQL:
|
||||
Used for date/time SQL standard syntax, because not all DBMS's support same temporal types.
|
||||
*/
|
||||
|
|
@ -1,261 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/*
|
||||
* Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de)
|
||||
* Licence: MIT
|
||||
*/
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("stex", function() {
|
||||
"use strict";
|
||||
|
||||
function pushCommand(state, command) {
|
||||
state.cmdState.push(command);
|
||||
}
|
||||
|
||||
function peekCommand(state) {
|
||||
if (state.cmdState.length > 0) {
|
||||
return state.cmdState[state.cmdState.length - 1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function popCommand(state) {
|
||||
var plug = state.cmdState.pop();
|
||||
if (plug) {
|
||||
plug.closeBracket();
|
||||
}
|
||||
}
|
||||
|
||||
// returns the non-default plugin closest to the end of the list
|
||||
function getMostPowerful(state) {
|
||||
var context = state.cmdState;
|
||||
for (var i = context.length - 1; i >= 0; i--) {
|
||||
var plug = context[i];
|
||||
if (plug.name == "DEFAULT") {
|
||||
continue;
|
||||
}
|
||||
return plug;
|
||||
}
|
||||
return { styleIdentifier: function() { return null; } };
|
||||
}
|
||||
|
||||
function addPluginPattern(pluginName, cmdStyle, styles) {
|
||||
return function () {
|
||||
this.name = pluginName;
|
||||
this.bracketNo = 0;
|
||||
this.style = cmdStyle;
|
||||
this.styles = styles;
|
||||
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
|
||||
|
||||
this.styleIdentifier = function() {
|
||||
return this.styles[this.bracketNo - 1] || null;
|
||||
};
|
||||
this.openBracket = function() {
|
||||
this.bracketNo++;
|
||||
return "bracket";
|
||||
};
|
||||
this.closeBracket = function() {};
|
||||
};
|
||||
}
|
||||
|
||||
var plugins = {};
|
||||
|
||||
plugins["importmodule"] = addPluginPattern("importmodule", "tag", ["string", "builtin"]);
|
||||
plugins["documentclass"] = addPluginPattern("documentclass", "tag", ["", "atom"]);
|
||||
plugins["usepackage"] = addPluginPattern("usepackage", "tag", ["atom"]);
|
||||
plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]);
|
||||
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
|
||||
|
||||
plugins["DEFAULT"] = function () {
|
||||
this.name = "DEFAULT";
|
||||
this.style = "tag";
|
||||
|
||||
this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
|
||||
};
|
||||
|
||||
function setState(state, f) {
|
||||
state.f = f;
|
||||
}
|
||||
|
||||
// called when in a normal (no environment) context
|
||||
function normal(source, state) {
|
||||
var plug;
|
||||
// Do we look like '\command' ? If so, attempt to apply the plugin 'command'
|
||||
if (source.match(/^\\[a-zA-Z@]+/)) {
|
||||
var cmdName = source.current().slice(1);
|
||||
plug = plugins[cmdName] || plugins["DEFAULT"];
|
||||
plug = new plug();
|
||||
pushCommand(state, plug);
|
||||
setState(state, beginParams);
|
||||
return plug.style;
|
||||
}
|
||||
|
||||
// escape characters
|
||||
if (source.match(/^\\[$&%#{}_]/)) {
|
||||
return "tag";
|
||||
}
|
||||
|
||||
// white space control characters
|
||||
if (source.match(/^\\[,;!\/\\]/)) {
|
||||
return "tag";
|
||||
}
|
||||
|
||||
// find if we're starting various math modes
|
||||
if (source.match("\\[")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match("$$")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match("$")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "$"); });
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
var ch = source.next();
|
||||
if (ch == "%") {
|
||||
// special case: % at end of its own line; stay in same state
|
||||
if (!source.eol()) {
|
||||
setState(state, inCComment);
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
else if (ch == '}' || ch == ']') {
|
||||
plug = peekCommand(state);
|
||||
if (plug) {
|
||||
plug.closeBracket(ch);
|
||||
setState(state, beginParams);
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
return "bracket";
|
||||
} else if (ch == '{' || ch == '[') {
|
||||
plug = plugins["DEFAULT"];
|
||||
plug = new plug();
|
||||
pushCommand(state, plug);
|
||||
return "bracket";
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
source.eatWhile(/[\w.%]/);
|
||||
return "atom";
|
||||
}
|
||||
else {
|
||||
source.eatWhile(/[\w\-_]/);
|
||||
plug = getMostPowerful(state);
|
||||
if (plug.name == 'begin') {
|
||||
plug.argument = source.current();
|
||||
}
|
||||
return plug.styleIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
function inCComment(source, state) {
|
||||
source.skipToEnd();
|
||||
setState(state, normal);
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function inMathMode(source, state, endModeSeq) {
|
||||
if (source.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
if (source.match(endModeSeq)) {
|
||||
setState(state, normal);
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match(/^\\[a-zA-Z@]+/)) {
|
||||
return "tag";
|
||||
}
|
||||
if (source.match(/^[a-zA-Z]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
// escape characters
|
||||
if (source.match(/^\\[$&%#{}_]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// white space control characters
|
||||
if (source.match(/^\\[,;!\/]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// special math-mode characters
|
||||
if (source.match(/^[\^_&]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// non-special characters
|
||||
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
|
||||
return null;
|
||||
}
|
||||
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
|
||||
return "number";
|
||||
}
|
||||
var ch = source.next();
|
||||
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
|
||||
return "bracket";
|
||||
}
|
||||
|
||||
// eat comments here, because inCComment returns us to normal state!
|
||||
if (ch == "%") {
|
||||
if (!source.eol()) {
|
||||
source.skipToEnd();
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
function beginParams(source, state) {
|
||||
var ch = source.peek(), lastPlug;
|
||||
if (ch == '{' || ch == '[') {
|
||||
lastPlug = peekCommand(state);
|
||||
lastPlug.openBracket(ch);
|
||||
source.eat(ch);
|
||||
setState(state, normal);
|
||||
return "bracket";
|
||||
}
|
||||
if (/[ \t\r]/.test(ch)) {
|
||||
source.eat(ch);
|
||||
return null;
|
||||
}
|
||||
setState(state, normal);
|
||||
popCommand(state);
|
||||
|
||||
return normal(source, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
cmdState: [],
|
||||
f: normal
|
||||
};
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
cmdState: s.cmdState.slice(),
|
||||
f: s.f
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
return state.f(stream, state);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-stex", "stex");
|
||||
CodeMirror.defineMIME("text/x-latex", "stex");
|
||||
|
||||
});
|
||||
|
|
@ -1,369 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/***
|
||||
|''Name''|tiddlywiki.js|
|
||||
|''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror|
|
||||
|''Author''|PMario|
|
||||
|''Version''|0.1.7|
|
||||
|''Status''|''stable''|
|
||||
|''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
|
||||
|''Documentation''|http://codemirror.tiddlyspace.com/|
|
||||
|''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
|
||||
|''CoreVersion''|2.5.0|
|
||||
|''Requires''|codemirror.js|
|
||||
|''Keywords''|syntax highlighting color code mirror codemirror|
|
||||
! Info
|
||||
CoreVersion parameter is needed for TiddlyWiki only!
|
||||
***/
|
||||
//{{{
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("tiddlywiki", function () {
|
||||
// Tokenizer
|
||||
var textwords = {};
|
||||
|
||||
var keywords = function () {
|
||||
function kw(type) {
|
||||
return { type: type, style: "macro"};
|
||||
}
|
||||
return {
|
||||
"allTags": kw('allTags'), "closeAll": kw('closeAll'), "list": kw('list'),
|
||||
"newJournal": kw('newJournal'), "newTiddler": kw('newTiddler'),
|
||||
"permaview": kw('permaview'), "saveChanges": kw('saveChanges'),
|
||||
"search": kw('search'), "slider": kw('slider'), "tabs": kw('tabs'),
|
||||
"tag": kw('tag'), "tagging": kw('tagging'), "tags": kw('tags'),
|
||||
"tiddler": kw('tiddler'), "timeline": kw('timeline'),
|
||||
"today": kw('today'), "version": kw('version'), "option": kw('option'),
|
||||
|
||||
"with": kw('with'),
|
||||
"filter": kw('filter')
|
||||
};
|
||||
}();
|
||||
|
||||
var isSpaceName = /[\w_\-]/i,
|
||||
reHR = /^\-\-\-\-+$/, // <hr>
|
||||
reWikiCommentStart = /^\/\*\*\*$/, // /***
|
||||
reWikiCommentStop = /^\*\*\*\/$/, // ***/
|
||||
reBlockQuote = /^<<<$/,
|
||||
|
||||
reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
|
||||
reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
|
||||
reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
|
||||
reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
|
||||
|
||||
reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
|
||||
reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
|
||||
|
||||
reUntilCodeStop = /.*?\}\}\}/;
|
||||
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
// Used as scratch variables to communicate multiple values without
|
||||
// consing up tons of objects.
|
||||
var type, content;
|
||||
|
||||
function ret(tp, style, cont) {
|
||||
type = tp;
|
||||
content = cont;
|
||||
return style;
|
||||
}
|
||||
|
||||
function jsTokenBase(stream, state) {
|
||||
var sol = stream.sol(), ch;
|
||||
|
||||
state.block = false; // indicates the start of a code block.
|
||||
|
||||
ch = stream.peek(); // don't eat, to make matching simpler
|
||||
|
||||
// check start of blocks
|
||||
if (sol && /[<\/\*{}\-]/.test(ch)) {
|
||||
if (stream.match(reCodeBlockStart)) {
|
||||
state.block = true;
|
||||
return chain(stream, state, twTokenCode);
|
||||
}
|
||||
if (stream.match(reBlockQuote)) {
|
||||
return ret('quote', 'quote');
|
||||
}
|
||||
if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
|
||||
return ret('code', 'comment');
|
||||
}
|
||||
if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
|
||||
return ret('code', 'comment');
|
||||
}
|
||||
if (stream.match(reHR)) {
|
||||
return ret('hr', 'hr');
|
||||
}
|
||||
} // sol
|
||||
ch = stream.next();
|
||||
|
||||
if (sol && /[\/\*!#;:>|]/.test(ch)) {
|
||||
if (ch == "!") { // tw header
|
||||
stream.skipToEnd();
|
||||
return ret("header", "header");
|
||||
}
|
||||
if (ch == "*") { // tw list
|
||||
stream.eatWhile('*');
|
||||
return ret("list", "comment");
|
||||
}
|
||||
if (ch == "#") { // tw numbered list
|
||||
stream.eatWhile('#');
|
||||
return ret("list", "comment");
|
||||
}
|
||||
if (ch == ";") { // definition list, term
|
||||
stream.eatWhile(';');
|
||||
return ret("list", "comment");
|
||||
}
|
||||
if (ch == ":") { // definition list, description
|
||||
stream.eatWhile(':');
|
||||
return ret("list", "comment");
|
||||
}
|
||||
if (ch == ">") { // single line quote
|
||||
stream.eatWhile(">");
|
||||
return ret("quote", "quote");
|
||||
}
|
||||
if (ch == '|') {
|
||||
return ret('table', 'header');
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == '{' && stream.match(/\{\{/)) {
|
||||
return chain(stream, state, twTokenCode);
|
||||
}
|
||||
|
||||
// rudimentary html:// file:// link matching. TW knows much more ...
|
||||
if (/[hf]/i.test(ch)) {
|
||||
if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
|
||||
return ret("link", "link");
|
||||
}
|
||||
}
|
||||
// just a little string indicator, don't want to have the whole string covered
|
||||
if (ch == '"') {
|
||||
return ret('string', 'string');
|
||||
}
|
||||
if (ch == '~') { // _no_ CamelCase indicator should be bold
|
||||
return ret('text', 'brace');
|
||||
}
|
||||
if (/[\[\]]/.test(ch)) { // check for [[..]]
|
||||
if (stream.peek() == ch) {
|
||||
stream.next();
|
||||
return ret('brace', 'brace');
|
||||
}
|
||||
}
|
||||
if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
|
||||
stream.eatWhile(isSpaceName);
|
||||
return ret("link", "link");
|
||||
}
|
||||
if (/\d/.test(ch)) { // numbers
|
||||
stream.eatWhile(/\d/);
|
||||
return ret("number", "number");
|
||||
}
|
||||
if (ch == "/") { // tw invisible comment
|
||||
if (stream.eat("%")) {
|
||||
return chain(stream, state, twTokenComment);
|
||||
}
|
||||
else if (stream.eat("/")) { //
|
||||
return chain(stream, state, twTokenEm);
|
||||
}
|
||||
}
|
||||
if (ch == "_") { // tw underline
|
||||
if (stream.eat("_")) {
|
||||
return chain(stream, state, twTokenUnderline);
|
||||
}
|
||||
}
|
||||
// strikethrough and mdash handling
|
||||
if (ch == "-") {
|
||||
if (stream.eat("-")) {
|
||||
// if strikethrough looks ugly, change CSS.
|
||||
if (stream.peek() != ' ')
|
||||
return chain(stream, state, twTokenStrike);
|
||||
// mdash
|
||||
if (stream.peek() == ' ')
|
||||
return ret('text', 'brace');
|
||||
}
|
||||
}
|
||||
if (ch == "'") { // tw bold
|
||||
if (stream.eat("'")) {
|
||||
return chain(stream, state, twTokenStrong);
|
||||
}
|
||||
}
|
||||
if (ch == "<") { // tw macro
|
||||
if (stream.eat("<")) {
|
||||
return chain(stream, state, twTokenMacro);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ret(ch);
|
||||
}
|
||||
|
||||
// core macro handling
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var word = stream.current(),
|
||||
known = textwords.propertyIsEnumerable(word) && textwords[word];
|
||||
|
||||
return known ? ret(known.type, known.style, word) : ret("text", null, word);
|
||||
|
||||
} // jsTokenBase()
|
||||
|
||||
// tw invisible comment
|
||||
function twTokenComment(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "%");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
// tw strong / bold
|
||||
function twTokenStrong(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "'" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "'");
|
||||
}
|
||||
return ret("text", "strong");
|
||||
}
|
||||
|
||||
// tw code
|
||||
function twTokenCode(stream, state) {
|
||||
var ch, sb = state.block;
|
||||
|
||||
if (sb && stream.current()) {
|
||||
return ret("code", "comment");
|
||||
}
|
||||
|
||||
if (!sb && stream.match(reUntilCodeStop)) {
|
||||
state.tokenize = jsTokenBase;
|
||||
return ret("code", "comment");
|
||||
}
|
||||
|
||||
if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
|
||||
state.tokenize = jsTokenBase;
|
||||
return ret("code", "comment");
|
||||
}
|
||||
|
||||
ch = stream.next();
|
||||
return (sb) ? ret("code", "comment") : ret("code", "comment");
|
||||
}
|
||||
|
||||
// tw em / italic
|
||||
function twTokenEm(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "/");
|
||||
}
|
||||
return ret("text", "em");
|
||||
}
|
||||
|
||||
// tw underlined text
|
||||
function twTokenUnderline(stream, state) {
|
||||
var maybeEnd = false,
|
||||
ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "_" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "_");
|
||||
}
|
||||
return ret("text", "underlined");
|
||||
}
|
||||
|
||||
// tw strike through text looks ugly
|
||||
// change CSS if needed
|
||||
function twTokenStrike(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "-" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "-");
|
||||
}
|
||||
return ret("text", "strikethrough");
|
||||
}
|
||||
|
||||
// macro
|
||||
function twTokenMacro(stream, state) {
|
||||
var ch, word, known;
|
||||
|
||||
if (stream.current() == '<<') {
|
||||
return ret('brace', 'macro');
|
||||
}
|
||||
|
||||
ch = stream.next();
|
||||
if (!ch) {
|
||||
state.tokenize = jsTokenBase;
|
||||
return ret(ch);
|
||||
}
|
||||
if (ch == ">") {
|
||||
if (stream.peek() == '>') {
|
||||
stream.next();
|
||||
state.tokenize = jsTokenBase;
|
||||
return ret("brace", "macro");
|
||||
}
|
||||
}
|
||||
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
word = stream.current();
|
||||
known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||
|
||||
if (known) {
|
||||
return ret(known.type, known.style, word);
|
||||
}
|
||||
else {
|
||||
return ret("macro", null, word);
|
||||
}
|
||||
}
|
||||
|
||||
// Interface
|
||||
return {
|
||||
startState: function () {
|
||||
return {
|
||||
tokenize: jsTokenBase,
|
||||
indented: 0,
|
||||
level: 0
|
||||
};
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
return style;
|
||||
},
|
||||
|
||||
electricChars: ""
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
|
||||
});
|
||||
|
||||
//}}}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: VB.NET mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="vb.js"></script>
|
||||
<script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
|
||||
.CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
|
||||
.CodeMirror pre { font-family: Inconsolata; font-size: 14px}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">VB.NET</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>VB.NET mode</h2>
|
||||
|
||||
<script type="text/javascript">
|
||||
function test(golden, text) {
|
||||
var ok = true;
|
||||
var i = 0;
|
||||
function callback(token, style, lineNo, pos){
|
||||
//console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
|
||||
var result = [String(token), String(style)];
|
||||
if (golden[i][0] != result[0] || golden[i][1] != result[1]){
|
||||
return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
|
||||
ok = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
CodeMirror.runMode(text, "text/x-vb",callback);
|
||||
|
||||
if (ok) return "Tests OK";
|
||||
}
|
||||
function testTypes() {
|
||||
var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
|
||||
var text = "Integer Float";
|
||||
return test(golden,text);
|
||||
}
|
||||
function testIf(){
|
||||
var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
|
||||
var text = 'If True End If';
|
||||
return test(golden, text);
|
||||
}
|
||||
function testDecl(){
|
||||
var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
|
||||
var text = 'Dim x as Integer';
|
||||
return test(golden, text);
|
||||
}
|
||||
function testAll(){
|
||||
var result = "";
|
||||
|
||||
result += testTypes() + "\n";
|
||||
result += testIf() + "\n";
|
||||
result += testDecl() + "\n";
|
||||
return result;
|
||||
|
||||
}
|
||||
function initText(editor) {
|
||||
var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
|
||||
editor.setValue(content);
|
||||
for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
|
||||
}
|
||||
function init() {
|
||||
editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
|
||||
lineNumbers: true,
|
||||
mode: "text/x-vb",
|
||||
readOnly: false
|
||||
});
|
||||
runTest();
|
||||
}
|
||||
function runTest() {
|
||||
document.getElementById('testresult').innerHTML = testAll();
|
||||
initText(editor);
|
||||
|
||||
}
|
||||
document.body.onload = init;
|
||||
</script>
|
||||
|
||||
<div id="edit">
|
||||
<textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
|
||||
</div>
|
||||
<pre id="testresult"></pre>
|
||||
<p>MIME type defined: <code>text/x-vb</code>.</p>
|
||||
|
||||
</article>
|
||||
|
|
@ -1,359 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
||||
|
||||
var indentUnit = config.indentUnit,
|
||||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
||||
dontAlignCalls = parserConfig.dontAlignCalls,
|
||||
noIndentKeywords = parserConfig.noIndentKeywords || [],
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keywords from IEEE 1800-2012
|
||||
*/
|
||||
var keywords = words(
|
||||
"accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind " +
|
||||
"bins binsof bit break buf bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config " +
|
||||
"const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable " +
|
||||
"dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup " +
|
||||
"endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask " +
|
||||
"enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin " +
|
||||
"function generate genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import " +
|
||||
"incdir include initial inout input inside instance int integer interconnect interface intersect join join_any " +
|
||||
"join_none large let liblist library local localparam logic longint macromodule matches medium modport module " +
|
||||
"nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 null or output package packed " +
|
||||
"parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup " +
|
||||
"pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg " +
|
||||
"reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime " +
|
||||
"s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify " +
|
||||
"specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on " +
|
||||
"table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior " +
|
||||
"trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void " +
|
||||
"wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor");
|
||||
|
||||
/** Operators from IEEE 1800-2012
|
||||
unary_operator ::=
|
||||
+ | - | ! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
|
||||
binary_operator ::=
|
||||
+ | - | * | / | % | == | != | === | !== | ==? | !=? | && | || | **
|
||||
| < | <= | > | >= | & | | | ^ | ^~ | ~^ | >> | << | >>> | <<<
|
||||
| -> | <->
|
||||
inc_or_dec_operator ::= ++ | --
|
||||
unary_module_path_operator ::=
|
||||
! | ~ | & | ~& | | | ~| | ^ | ~^ | ^~
|
||||
binary_module_path_operator ::=
|
||||
== | != | && | || | & | | | ^ | ^~ | ~^
|
||||
*/
|
||||
var isOperatorChar = /[\+\-\*\/!~&|^%=?:]/;
|
||||
var isBracketChar = /[\[\]{}()]/;
|
||||
|
||||
var unsignedNumber = /\d[0-9_]*/;
|
||||
var decimalLiteral = /\d*\s*'s?d\s*\d[0-9_]*/i;
|
||||
var binaryLiteral = /\d*\s*'s?b\s*[xz01][xz01_]*/i;
|
||||
var octLiteral = /\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i;
|
||||
var hexLiteral = /\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i;
|
||||
var realLiteral = /(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i;
|
||||
|
||||
var closingBracketOrWord = /^((\w+)|[)}\]])/;
|
||||
var closingBracket = /[)}\]]/;
|
||||
|
||||
var curPunc;
|
||||
var curKeyword;
|
||||
|
||||
// Block openings which are closed by a matching keyword in the form of ("end" + keyword)
|
||||
// E.g. "task" => "endtask"
|
||||
var blockKeywords = words(
|
||||
"case checker class clocking config function generate group interface module package" +
|
||||
"primitive program property specify sequence table task"
|
||||
);
|
||||
|
||||
// Opening/closing pairs
|
||||
var openClose = {};
|
||||
for (var keyword in blockKeywords) {
|
||||
openClose[keyword] = "end" + keyword;
|
||||
}
|
||||
openClose["begin"] = "end";
|
||||
openClose["casex"] = "endcase";
|
||||
openClose["casez"] = "endcase";
|
||||
openClose["do" ] = "while";
|
||||
openClose["fork" ] = "join;join_any;join_none";
|
||||
|
||||
// This is a bit of a hack but will work to not indent after import/epxort statements
|
||||
// as long as the function/task name is on the same line
|
||||
openClose["import"] = "function;task";
|
||||
openClose["export"] = "function;task";
|
||||
|
||||
for (var i in noIndentKeywords) {
|
||||
var keyword = noIndentKeywords[i];
|
||||
if (openClose[keyword]) {
|
||||
openClose[keyword] = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while");
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.peek();
|
||||
if (/[,;:\.]/.test(ch)) {
|
||||
curPunc = stream.next();
|
||||
return null;
|
||||
}
|
||||
if (isBracketChar.test(ch)) {
|
||||
curPunc = stream.next();
|
||||
return "bracket";
|
||||
}
|
||||
// Macros (tick-defines)
|
||||
if (ch == '`') {
|
||||
stream.next();
|
||||
if (stream.eatWhile(/[\w\$_]/)) {
|
||||
return "def";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// System calls
|
||||
if (ch == '$') {
|
||||
stream.next();
|
||||
if (stream.eatWhile(/[\w\$_]/)) {
|
||||
return "meta";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Time literals
|
||||
if (ch == '#') {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\d_.]/);
|
||||
return "def";
|
||||
}
|
||||
// Strings
|
||||
if (ch == '"') {
|
||||
stream.next();
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
// Comments
|
||||
if (ch == "/") {
|
||||
stream.next();
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
// Numeric literals
|
||||
if (stream.match(realLiteral) ||
|
||||
stream.match(decimalLiteral) ||
|
||||
stream.match(binaryLiteral) ||
|
||||
stream.match(octLiteral) ||
|
||||
stream.match(hexLiteral) ||
|
||||
stream.match(unsignedNumber) ||
|
||||
stream.match(realLiteral)) {
|
||||
return "number";
|
||||
}
|
||||
|
||||
// Operators
|
||||
if (stream.eatWhile(isOperatorChar)) {
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// Keywords / plain variables
|
||||
if (stream.eatWhile(/[\w\$_]/)) {
|
||||
var cur = stream.current();
|
||||
if (keywords[cur]) {
|
||||
if (openClose[cur]) {
|
||||
curPunc = "newblock";
|
||||
}
|
||||
if (statementKeywords[cur]) {
|
||||
curPunc = "newstatement";
|
||||
}
|
||||
curKeyword = cur;
|
||||
return "keyword";
|
||||
}
|
||||
return "variable";
|
||||
}
|
||||
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
var indent = state.indented;
|
||||
var c = new Context(indent, col, type, null, state.context);
|
||||
return state.context = c;
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}") {
|
||||
state.indented = state.context.indented;
|
||||
}
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
function isClosing(text, contextClosing) {
|
||||
if (text == contextClosing) {
|
||||
return true;
|
||||
} else {
|
||||
// contextClosing may be mulitple keywords separated by ;
|
||||
var closingKeywords = contextClosing.split(";");
|
||||
for (var i in closingKeywords) {
|
||||
if (text == closingKeywords[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function buildElectricInputRegEx() {
|
||||
// Reindentation should occur on any bracket char: {}()[]
|
||||
// or on a match of any of the block closing keywords, at
|
||||
// the end of a line
|
||||
var allClosings = [];
|
||||
for (var i in openClose) {
|
||||
if (openClose[i]) {
|
||||
var closings = openClose[i].split(";");
|
||||
for (var j in closings) {
|
||||
allClosings.push(closings[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
var re = new RegExp("[{}()\\[\\]]|(" + allClosings.join("|") + ")$");
|
||||
return re;
|
||||
}
|
||||
|
||||
// Interface
|
||||
return {
|
||||
|
||||
// Regex to force current line to reindent
|
||||
electricInput: buildElectricInputRegEx(),
|
||||
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
curKeyword = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta" || style == "variable") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if (curPunc == ctx.type) {
|
||||
popContext(state);
|
||||
}
|
||||
else if ((curPunc == ";" && ctx.type == "statement") ||
|
||||
(ctx.type && isClosing(curKeyword, ctx.type))) {
|
||||
ctx = popContext(state);
|
||||
while (ctx && ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == "{") { pushContext(state, stream.column(), "}"); }
|
||||
else if (curPunc == "[") { pushContext(state, stream.column(), "]"); }
|
||||
else if (curPunc == "(") { pushContext(state, stream.column(), ")"); }
|
||||
else if (ctx && ctx.type == "endcase" && curPunc == ":") { pushContext(state, stream.column(), "statement"); }
|
||||
else if (curPunc == "newstatement") {
|
||||
pushContext(state, stream.column(), "statement");
|
||||
} else if (curPunc == "newblock") {
|
||||
var close = openClose[curKeyword];
|
||||
pushContext(state, stream.column(), close);
|
||||
}
|
||||
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = false;
|
||||
var possibleClosing = textAfter.match(closingBracketOrWord);
|
||||
if (possibleClosing) {
|
||||
closing = isClosing(possibleClosing[0], ctx.type);
|
||||
}
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
||||
else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1);
|
||||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-verilog", {
|
||||
name: "verilog"
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-systemverilog", {
|
||||
name: "systemverilog"
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "codemirror",
|
||||
"version":"4.6.0",
|
||||
"main": "lib/codemirror.js",
|
||||
"description": "In-browser code editing made bearable",
|
||||
"licenses": [{"type": "MIT",
|
||||
"url": "http://codemirror.net/LICENSE"}],
|
||||
"directories": {"lib": "./lib"},
|
||||
"scripts": {"test": "node ./test/run.js"},
|
||||
"devDependencies": {"node-static": "0.6.0",
|
||||
"phantomjs": "1.9.2-5"},
|
||||
"bugs": "http://github.com/marijnh/CodeMirror/issues",
|
||||
"keywords": ["JavaScript", "CodeMirror", "Editor"],
|
||||
"homepage": "http://codemirror.net",
|
||||
"maintainers":[{"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com",
|
||||
"web": "http://marijnhaverbeke.nl"}],
|
||||
"repository": {"type": "git",
|
||||
"url": "https://github.com/marijnh/CodeMirror.git"}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
Simple linter, based on the Acorn [1] parser module
|
||||
|
||||
All of the existing linters either cramp my style or have huge
|
||||
dependencies (Closure). So here's a very simple, non-invasive one
|
||||
that only spots
|
||||
|
||||
- missing semicolons and trailing commas
|
||||
- variables or properties that are reserved words
|
||||
- assigning to a variable you didn't declare
|
||||
- access to non-whitelisted globals
|
||||
(use a '// declare global: foo, bar' comment to declare extra
|
||||
globals in a file)
|
||||
|
||||
[1]: https://github.com/marijnh/acorn/
|
||||
*/
|
||||
|
||||
var topAllowedGlobals = Object.create(null);
|
||||
("Error RegExp Number String Array Function Object Math Date undefined " +
|
||||
"parseInt parseFloat Infinity NaN isNaN " +
|
||||
"window document navigator prompt alert confirm console " +
|
||||
"screen FileReader Worker postMessage importScripts " +
|
||||
"setInterval clearInterval setTimeout clearTimeout " +
|
||||
"CodeMirror " +
|
||||
"test exports require module define")
|
||||
.split(" ").forEach(function(n) { topAllowedGlobals[n] = true; });
|
||||
|
||||
var fs = require("fs"), acorn = require("./acorn.js"), walk = require("./walk.js");
|
||||
|
||||
var scopePasser = walk.make({
|
||||
ScopeBody: function(node, prev, c) { c(node, node.scope); }
|
||||
});
|
||||
|
||||
var cBlob = /^\/\/ CodeMirror, copyright \(c\) by Marijn Haverbeke and others\n\/\/ Distributed under an MIT license: http:\/\/codemirror.net\/LICENSE\n\n/;
|
||||
|
||||
function checkFile(fileName) {
|
||||
var file = fs.readFileSync(fileName, "utf8"), notAllowed;
|
||||
if (notAllowed = file.match(/[\x00-\x08\x0b\x0c\x0e-\x19\uFEFF\t]|[ \t]\n/)) {
|
||||
var msg;
|
||||
if (notAllowed[0] == "\t") msg = "Found tab character";
|
||||
else if (notAllowed[0].indexOf("\n") > -1) msg = "Trailing whitespace";
|
||||
else msg = "Undesirable character " + notAllowed[0].charCodeAt(0);
|
||||
var info = acorn.getLineInfo(file, notAllowed.index);
|
||||
fail(msg + " at line " + info.line + ", column " + info.column, {source: fileName});
|
||||
}
|
||||
|
||||
if (!cBlob.test(file))
|
||||
fail("Missing license blob", {source: fileName});
|
||||
|
||||
var globalsSeen = Object.create(null);
|
||||
|
||||
try {
|
||||
var parsed = acorn.parse(file, {
|
||||
locations: true,
|
||||
ecmaVersion: 3,
|
||||
strictSemicolons: true,
|
||||
allowTrailingCommas: false,
|
||||
forbidReserved: "everywhere",
|
||||
sourceFile: fileName
|
||||
});
|
||||
} catch (e) {
|
||||
fail(e.message, {source: fileName});
|
||||
return;
|
||||
}
|
||||
|
||||
var scopes = [];
|
||||
|
||||
walk.simple(parsed, {
|
||||
ScopeBody: function(node, scope) {
|
||||
node.scope = scope;
|
||||
scopes.push(scope);
|
||||
}
|
||||
}, walk.scopeVisitor, {vars: Object.create(null)});
|
||||
|
||||
var ignoredGlobals = Object.create(null);
|
||||
|
||||
function inScope(name, scope) {
|
||||
for (var cur = scope; cur; cur = cur.prev)
|
||||
if (name in cur.vars) return true;
|
||||
}
|
||||
function checkLHS(node, scope) {
|
||||
if (node.type == "Identifier" && !(node.name in ignoredGlobals) &&
|
||||
!inScope(node.name, scope)) {
|
||||
ignoredGlobals[node.name] = true;
|
||||
fail("Assignment to global variable", node.loc);
|
||||
}
|
||||
}
|
||||
|
||||
walk.simple(parsed, {
|
||||
UpdateExpression: function(node, scope) {checkLHS(node.argument, scope);},
|
||||
AssignmentExpression: function(node, scope) {checkLHS(node.left, scope);},
|
||||
Identifier: function(node, scope) {
|
||||
if (node.name == "arguments") return;
|
||||
// Mark used identifiers
|
||||
for (var cur = scope; cur; cur = cur.prev)
|
||||
if (node.name in cur.vars) {
|
||||
cur.vars[node.name].used = true;
|
||||
return;
|
||||
}
|
||||
globalsSeen[node.name] = node.loc;
|
||||
},
|
||||
FunctionExpression: function(node) {
|
||||
if (node.id) fail("Named function expression", node.loc);
|
||||
},
|
||||
ForStatement: function(node) {
|
||||
checkReusedIndex(node);
|
||||
},
|
||||
MemberExpression: function(node) {
|
||||
if (node.object.type == "Identifier" && node.object.name == "console" && !node.computed)
|
||||
fail("Found console." + node.property.name, node.loc);
|
||||
},
|
||||
DebuggerStatement: function(node) {
|
||||
fail("Found debugger statement", node.loc);
|
||||
}
|
||||
}, scopePasser);
|
||||
|
||||
function checkReusedIndex(node) {
|
||||
if (!node.init || node.init.type != "VariableDeclaration") return;
|
||||
var name = node.init.declarations[0].id.name;
|
||||
walk.recursive(node.body, null, {
|
||||
Function: function() {},
|
||||
VariableDeclaration: function(node, st, c) {
|
||||
for (var i = 0; i < node.declarations.length; i++)
|
||||
if (node.declarations[i].id.name == name)
|
||||
fail("redefined loop variable", node.declarations[i].id.loc);
|
||||
walk.base.VariableDeclaration(node, st, c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var allowedGlobals = Object.create(topAllowedGlobals), m;
|
||||
if (m = file.match(/\/\/ declare global:\s+(.*)/))
|
||||
m[1].split(/,\s*/g).forEach(function(n) { allowedGlobals[n] = true; });
|
||||
for (var glob in globalsSeen)
|
||||
if (!(glob in allowedGlobals))
|
||||
fail("Access to global variable " + glob + ". Add a '// declare global: " + glob +
|
||||
"' comment or add this variable in test/lint/lint.js.", globalsSeen[glob]);
|
||||
|
||||
for (var i = 0; i < scopes.length; ++i) {
|
||||
var scope = scopes[i];
|
||||
for (var name in scope.vars) {
|
||||
var info = scope.vars[name];
|
||||
if (!info.used && info.type != "catch clause" && info.type != "function name" && name.charAt(0) != "_")
|
||||
fail("Unused " + info.type + " " + name, info.node.loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var failed = false;
|
||||
function fail(msg, pos) {
|
||||
if (pos.start) msg += " (" + pos.start.line + ":" + pos.start.column + ")";
|
||||
console.log(pos.source + ": " + msg);
|
||||
failed = true;
|
||||
}
|
||||
|
||||
function checkDir(dir) {
|
||||
fs.readdirSync(dir).forEach(function(file) {
|
||||
var fname = dir + "/" + file;
|
||||
if (/\.js$/.test(file)) checkFile(fname);
|
||||
else if (fs.lstatSync(fname).isDirectory()) checkDir(fname);
|
||||
});
|
||||
}
|
||||
|
||||
exports.checkDir = checkDir;
|
||||
exports.checkFile = checkFile;
|
||||
exports.success = function() { return !failed; };
|
||||
|
|
@ -1,313 +0,0 @@
|
|||
// AST walker module for Mozilla Parser API compatible trees
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") return mod(exports); // CommonJS
|
||||
if (typeof define == "function" && define.amd) return define(["exports"], mod); // AMD
|
||||
mod((this.acorn || (this.acorn = {})).walk = {}); // Plain browser env
|
||||
})(function(exports) {
|
||||
"use strict";
|
||||
|
||||
// A simple walk is one where you simply specify callbacks to be
|
||||
// called on specific nodes. The last two arguments are optional. A
|
||||
// simple use would be
|
||||
//
|
||||
// walk.simple(myTree, {
|
||||
// Expression: function(node) { ... }
|
||||
// });
|
||||
//
|
||||
// to do something with all expressions. All Parser API node types
|
||||
// can be used to identify node types, as well as Expression,
|
||||
// Statement, and ScopeBody, which denote categories of nodes.
|
||||
//
|
||||
// The base argument can be used to pass a custom (recursive)
|
||||
// walker, and state can be used to give this walked an initial
|
||||
// state.
|
||||
exports.simple = function(node, visitors, base, state) {
|
||||
if (!base) base = exports.base;
|
||||
function c(node, st, override) {
|
||||
var type = override || node.type, found = visitors[type];
|
||||
base[type](node, st, c);
|
||||
if (found) found(node, st);
|
||||
}
|
||||
c(node, state);
|
||||
};
|
||||
|
||||
// A recursive walk is one where your functions override the default
|
||||
// walkers. They can modify and replace the state parameter that's
|
||||
// threaded through the walk, and can opt how and whether to walk
|
||||
// their child nodes (by calling their third argument on these
|
||||
// nodes).
|
||||
exports.recursive = function(node, state, funcs, base) {
|
||||
var visitor = funcs ? exports.make(funcs, base) : base;
|
||||
function c(node, st, override) {
|
||||
visitor[override || node.type](node, st, c);
|
||||
}
|
||||
c(node, state);
|
||||
};
|
||||
|
||||
function makeTest(test) {
|
||||
if (typeof test == "string")
|
||||
return function(type) { return type == test; };
|
||||
else if (!test)
|
||||
return function() { return true; };
|
||||
else
|
||||
return test;
|
||||
}
|
||||
|
||||
function Found(node, state) { this.node = node; this.state = state; }
|
||||
|
||||
// Find a node with a given start, end, and type (all are optional,
|
||||
// null can be used as wildcard). Returns a {node, state} object, or
|
||||
// undefined when it doesn't find a matching node.
|
||||
exports.findNodeAt = function(node, start, end, test, base, state) {
|
||||
test = makeTest(test);
|
||||
try {
|
||||
if (!base) base = exports.base;
|
||||
var c = function(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if ((start == null || node.start <= start) &&
|
||||
(end == null || node.end >= end))
|
||||
base[type](node, st, c);
|
||||
if (test(type, node) &&
|
||||
(start == null || node.start == start) &&
|
||||
(end == null || node.end == end))
|
||||
throw new Found(node, st);
|
||||
};
|
||||
c(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) return e;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// Find the innermost node of a given type that contains the given
|
||||
// position. Interface similar to findNodeAt.
|
||||
exports.findNodeAround = function(node, pos, test, base, state) {
|
||||
test = makeTest(test);
|
||||
try {
|
||||
if (!base) base = exports.base;
|
||||
var c = function(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if (node.start > pos || node.end < pos) return;
|
||||
base[type](node, st, c);
|
||||
if (test(type, node)) throw new Found(node, st);
|
||||
};
|
||||
c(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) return e;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// Find the outermost matching node after a given position.
|
||||
exports.findNodeAfter = function(node, pos, test, base, state) {
|
||||
test = makeTest(test);
|
||||
try {
|
||||
if (!base) base = exports.base;
|
||||
var c = function(node, st, override) {
|
||||
if (node.end < pos) return;
|
||||
var type = override || node.type;
|
||||
if (node.start >= pos && test(type, node)) throw new Found(node, st);
|
||||
base[type](node, st, c);
|
||||
};
|
||||
c(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) return e;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// Find the outermost matching node before a given position.
|
||||
exports.findNodeBefore = function(node, pos, test, base, state) {
|
||||
test = makeTest(test);
|
||||
if (!base) base = exports.base;
|
||||
var max;
|
||||
var c = function(node, st, override) {
|
||||
if (node.start > pos) return;
|
||||
var type = override || node.type;
|
||||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
||||
max = new Found(node, st);
|
||||
base[type](node, st, c);
|
||||
};
|
||||
c(node, state);
|
||||
return max;
|
||||
};
|
||||
|
||||
// Used to create a custom walker. Will fill in all missing node
|
||||
// type properties with the defaults.
|
||||
exports.make = function(funcs, base) {
|
||||
if (!base) base = exports.base;
|
||||
var visitor = {};
|
||||
for (var type in base) visitor[type] = base[type];
|
||||
for (var type in funcs) visitor[type] = funcs[type];
|
||||
return visitor;
|
||||
};
|
||||
|
||||
function skipThrough(node, st, c) { c(node, st); }
|
||||
function ignore(_node, _st, _c) {}
|
||||
|
||||
// Node walkers.
|
||||
|
||||
var base = exports.base = {};
|
||||
base.Program = base.BlockStatement = function(node, st, c) {
|
||||
for (var i = 0; i < node.body.length; ++i)
|
||||
c(node.body[i], st, "Statement");
|
||||
};
|
||||
base.Statement = skipThrough;
|
||||
base.EmptyStatement = ignore;
|
||||
base.ExpressionStatement = function(node, st, c) {
|
||||
c(node.expression, st, "Expression");
|
||||
};
|
||||
base.IfStatement = function(node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Statement");
|
||||
if (node.alternate) c(node.alternate, st, "Statement");
|
||||
};
|
||||
base.LabeledStatement = function(node, st, c) {
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.BreakStatement = base.ContinueStatement = ignore;
|
||||
base.WithStatement = function(node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.SwitchStatement = function(node, st, c) {
|
||||
c(node.discriminant, st, "Expression");
|
||||
for (var i = 0; i < node.cases.length; ++i) {
|
||||
var cs = node.cases[i];
|
||||
if (cs.test) c(cs.test, st, "Expression");
|
||||
for (var j = 0; j < cs.consequent.length; ++j)
|
||||
c(cs.consequent[j], st, "Statement");
|
||||
}
|
||||
};
|
||||
base.ReturnStatement = function(node, st, c) {
|
||||
if (node.argument) c(node.argument, st, "Expression");
|
||||
};
|
||||
base.ThrowStatement = function(node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.TryStatement = function(node, st, c) {
|
||||
c(node.block, st, "Statement");
|
||||
if (node.handler) c(node.handler.body, st, "ScopeBody");
|
||||
if (node.finalizer) c(node.finalizer, st, "Statement");
|
||||
};
|
||||
base.WhileStatement = function(node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.DoWhileStatement = base.WhileStatement;
|
||||
base.ForStatement = function(node, st, c) {
|
||||
if (node.init) c(node.init, st, "ForInit");
|
||||
if (node.test) c(node.test, st, "Expression");
|
||||
if (node.update) c(node.update, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInStatement = function(node, st, c) {
|
||||
c(node.left, st, "ForInit");
|
||||
c(node.right, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInit = function(node, st, c) {
|
||||
if (node.type == "VariableDeclaration") c(node, st);
|
||||
else c(node, st, "Expression");
|
||||
};
|
||||
base.DebuggerStatement = ignore;
|
||||
|
||||
base.FunctionDeclaration = function(node, st, c) {
|
||||
c(node, st, "Function");
|
||||
};
|
||||
base.VariableDeclaration = function(node, st, c) {
|
||||
for (var i = 0; i < node.declarations.length; ++i) {
|
||||
var decl = node.declarations[i];
|
||||
if (decl.init) c(decl.init, st, "Expression");
|
||||
}
|
||||
};
|
||||
|
||||
base.Function = function(node, st, c) {
|
||||
c(node.body, st, "ScopeBody");
|
||||
};
|
||||
base.ScopeBody = function(node, st, c) {
|
||||
c(node, st, "Statement");
|
||||
};
|
||||
|
||||
base.Expression = skipThrough;
|
||||
base.ThisExpression = ignore;
|
||||
base.ArrayExpression = function(node, st, c) {
|
||||
for (var i = 0; i < node.elements.length; ++i) {
|
||||
var elt = node.elements[i];
|
||||
if (elt) c(elt, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.ObjectExpression = function(node, st, c) {
|
||||
for (var i = 0; i < node.properties.length; ++i)
|
||||
c(node.properties[i].value, st, "Expression");
|
||||
};
|
||||
base.FunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = function(node, st, c) {
|
||||
for (var i = 0; i < node.expressions.length; ++i)
|
||||
c(node.expressions[i], st, "Expression");
|
||||
};
|
||||
base.UnaryExpression = base.UpdateExpression = function(node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.BinaryExpression = base.AssignmentExpression = base.LogicalExpression = function(node, st, c) {
|
||||
c(node.left, st, "Expression");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.ConditionalExpression = function(node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Expression");
|
||||
c(node.alternate, st, "Expression");
|
||||
};
|
||||
base.NewExpression = base.CallExpression = function(node, st, c) {
|
||||
c(node.callee, st, "Expression");
|
||||
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
|
||||
c(node.arguments[i], st, "Expression");
|
||||
};
|
||||
base.MemberExpression = function(node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
if (node.computed) c(node.property, st, "Expression");
|
||||
};
|
||||
base.Identifier = base.Literal = ignore;
|
||||
|
||||
// A custom walker that keeps track of the scope chain and the
|
||||
// variables defined in it.
|
||||
function makeScope(prev, isCatch) {
|
||||
return {vars: Object.create(null), prev: prev, isCatch: isCatch};
|
||||
}
|
||||
function normalScope(scope) {
|
||||
while (scope.isCatch) scope = scope.prev;
|
||||
return scope;
|
||||
}
|
||||
exports.scopeVisitor = exports.make({
|
||||
Function: function(node, scope, c) {
|
||||
var inner = makeScope(scope);
|
||||
for (var i = 0; i < node.params.length; ++i)
|
||||
inner.vars[node.params[i].name] = {type: "argument", node: node.params[i]};
|
||||
if (node.id) {
|
||||
var decl = node.type == "FunctionDeclaration";
|
||||
(decl ? normalScope(scope) : inner).vars[node.id.name] =
|
||||
{type: decl ? "function" : "function name", node: node.id};
|
||||
}
|
||||
c(node.body, inner, "ScopeBody");
|
||||
},
|
||||
TryStatement: function(node, scope, c) {
|
||||
c(node.block, scope, "Statement");
|
||||
if (node.handler) {
|
||||
var inner = makeScope(scope, true);
|
||||
inner.vars[node.handler.param.name] = {type: "catch clause", node: node.handler.param};
|
||||
c(node.handler.body, inner, "ScopeBody");
|
||||
}
|
||||
if (node.finalizer) c(node.finalizer, scope, "Statement");
|
||||
},
|
||||
VariableDeclaration: function(node, scope, c) {
|
||||
var target = normalScope(scope);
|
||||
for (var i = 0; i < node.declarations.length; ++i) {
|
||||
var decl = node.declarations[i];
|
||||
target.vars[decl.id.name] = {type: "var", node: decl.id};
|
||||
if (decl.init) c(decl.init, scope, "Expression");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
var page = require('webpage').create();
|
||||
|
||||
page.open("http://localhost:3000/test/index.html", function (status) {
|
||||
if (status != "success") {
|
||||
console.log("page couldn't be loaded successfully");
|
||||
phantom.exit(1);
|
||||
}
|
||||
waitFor(function () {
|
||||
return page.evaluate(function () {
|
||||
var output = document.getElementById('status');
|
||||
if (!output) { return false; }
|
||||
return (/^(\d+ failures?|all passed)/i).test(output.innerText);
|
||||
});
|
||||
}, function () {
|
||||
var failed = page.evaluate(function () { return window.failed; });
|
||||
var output = page.evaluate(function () {
|
||||
return document.getElementById('output').innerText + "\n" +
|
||||
document.getElementById('status').innerText;
|
||||
});
|
||||
console.log(output);
|
||||
phantom.exit(failed > 0 ? 1 : 0);
|
||||
});
|
||||
});
|
||||
|
||||
function waitFor (test, cb) {
|
||||
if (test()) {
|
||||
cb();
|
||||
} else {
|
||||
setTimeout(function () { waitFor(test, cb); }, 250);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var lint = require("./lint/lint");
|
||||
|
||||
lint.checkDir("mode");
|
||||
lint.checkDir("lib");
|
||||
lint.checkDir("addon");
|
||||
lint.checkDir("keymap");
|
||||
|
||||
var ok = lint.success();
|
||||
|
||||
var files = new (require('node-static').Server)();
|
||||
|
||||
var server = require('http').createServer(function (req, res) {
|
||||
req.addListener('end', function () {
|
||||
files.serve(req, res, function (err/*, result */) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}).resume();
|
||||
}).addListener('error', function (err) {
|
||||
throw err;
|
||||
}).listen(3000, function () {
|
||||
var childProcess = require('child_process');
|
||||
var phantomjs = require("phantomjs");
|
||||
var childArgs = [
|
||||
require("path").join(__dirname, 'phantom_driver.js')
|
||||
];
|
||||
childProcess.execFile(phantomjs.path, childArgs, function (err, stdout, stderr) {
|
||||
server.close();
|
||||
console.log(stdout);
|
||||
if (err) console.error(err);
|
||||
if (stderr) console.error(stderr);
|
||||
process.exit(err || stderr || !ok ? 1 : 0);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
function test(name) {
|
||||
var text = Array.prototype.slice.call(arguments, 1, arguments.length - 1).join("\n");
|
||||
var body = arguments[arguments.length - 1];
|
||||
return window.test("search_" + name, function() {
|
||||
body(new CodeMirror.Doc(text));
|
||||
});
|
||||
}
|
||||
|
||||
function run(doc, query, insensitive) {
|
||||
var cursor = doc.getSearchCursor(query, null, insensitive);
|
||||
for (var i = 3; i < arguments.length; i += 4) {
|
||||
var found = cursor.findNext();
|
||||
is(found, "not enough results (forward)");
|
||||
eqPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, forward, " + (i - 3) / 4);
|
||||
eqPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, forward, " + (i - 3) / 4);
|
||||
}
|
||||
is(!cursor.findNext(), "too many matches (forward)");
|
||||
for (var i = arguments.length - 4; i >= 3; i -= 4) {
|
||||
var found = cursor.findPrevious();
|
||||
is(found, "not enough results (backwards)");
|
||||
eqPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, backwards, " + (i - 3) / 4);
|
||||
eqPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, backwards, " + (i - 3) / 4);
|
||||
}
|
||||
is(!cursor.findPrevious(), "too many matches (backwards)");
|
||||
}
|
||||
|
||||
test("simple", "abcdefg", "abcdefg", function(doc) {
|
||||
run(doc, "cde", false, 0, 2, 0, 5, 1, 2, 1, 5);
|
||||
});
|
||||
|
||||
test("multiline", "hallo", "goodbye", function(doc) {
|
||||
run(doc, "llo\ngoo", false, 0, 2, 1, 3);
|
||||
run(doc, "blah\nhall", false);
|
||||
run(doc, "bye\neye", false);
|
||||
});
|
||||
|
||||
test("regexp", "abcde", "abcde", function(doc) {
|
||||
run(doc, /bcd/, false, 0, 1, 0, 4, 1, 1, 1, 4);
|
||||
run(doc, /BCD/, false);
|
||||
run(doc, /BCD/i, false, 0, 1, 0, 4, 1, 1, 1, 4);
|
||||
});
|
||||
|
||||
test("insensitive", "hallo", "HALLO", "oink", "hAllO", function(doc) {
|
||||
run(doc, "All", false, 3, 1, 3, 4);
|
||||
run(doc, "All", true, 0, 1, 0, 4, 1, 1, 1, 4, 3, 1, 3, 4);
|
||||
});
|
||||
|
||||
test("multilineInsensitive", "zie ginds komT", "De Stoomboot", "uit Spanje weer aan", function(doc) {
|
||||
run(doc, "komt\nde stoomboot\nuit", false);
|
||||
run(doc, "komt\nde stoomboot\nuit", true, 0, 10, 2, 3);
|
||||
run(doc, "kOMt\ndE stOOmboot\nuiT", true, 0, 10, 2, 3);
|
||||
});
|
||||
|
||||
test("expandingCaseFold", "<b>İİ İİ</b>", "<b>uu uu</b>", function(doc) {
|
||||
if (phantom) return; // A Phantom bug makes this hang
|
||||
run(doc, "</b>", true, 0, 8, 0, 12, 1, 8, 1, 12);
|
||||
run(doc, "İİ", true, 0, 3, 0, 5, 0, 6, 0, 8);
|
||||
});
|
||||
})();
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: 3024 day
|
||||
Author: Jan T. Sott (http://github.com/idleberg)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;}
|
||||
.cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;}
|
||||
|
||||
.cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;}
|
||||
.cm-s-3024-day .CodeMirror-guttermarker { color: #db2d20; }
|
||||
.cm-s-3024-day .CodeMirror-guttermarker-subtle { color: #807d7c; }
|
||||
.cm-s-3024-day .CodeMirror-linenumber {color: #807d7c;}
|
||||
|
||||
.cm-s-3024-day .CodeMirror-cursor {border-left: 1px solid #5c5855 !important;}
|
||||
|
||||
.cm-s-3024-day span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-day span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-string {color: #fded02;}
|
||||
|
||||
.cm-s-3024-day span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-day span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-day span.cm-bracket {color: #3a3432;}
|
||||
.cm-s-3024-day span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-link {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
|
||||
|
||||
.cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: 3024 night
|
||||
Author: Jan T. Sott (http://github.com/idleberg)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;}
|
||||
.cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;}
|
||||
.cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;}
|
||||
.cm-s-3024-night .CodeMirror-guttermarker { color: #db2d20; }
|
||||
.cm-s-3024-night .CodeMirror-guttermarker-subtle { color: #5c5855; }
|
||||
.cm-s-3024-night .CodeMirror-linenumber {color: #5c5855;}
|
||||
|
||||
.cm-s-3024-night .CodeMirror-cursor {border-left: 1px solid #807d7c !important;}
|
||||
|
||||
.cm-s-3024-night span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-night span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-string {color: #fded02;}
|
||||
|
||||
.cm-s-3024-night span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-night span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-night span.cm-bracket {color: #d6d5d4;}
|
||||
.cm-s-3024-night span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-link {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-error {background: #db2d20; color: #807d7c;}
|
||||
|
||||
.cm-s-3024-night .CodeMirror-activeline-background {background: #2F2F2F !important;}
|
||||
.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: Base16 Default Dark
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
|
||||
.cm-s-base16-dark div.CodeMirror-selected {background: #202020 !important;}
|
||||
.cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
|
||||
.cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; }
|
||||
.cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; }
|
||||
.cm-s-base16-dark .CodeMirror-linenumber {color: #505050;}
|
||||
.cm-s-base16-dark .CodeMirror-cursor {border-left: 1px solid #b0b0b0 !important;}
|
||||
|
||||
.cm-s-base16-dark span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-dark span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-number {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-string {color: #f4bf75;}
|
||||
|
||||
.cm-s-base16-dark span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-dark span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-dark span.cm-bracket {color: #e0e0e0;}
|
||||
.cm-s-base16-dark span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-link {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}
|
||||
|
||||
.cm-s-base16-dark .CodeMirror-activeline-background {background: #2F2F2F !important;}
|
||||
.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: Base16 Default Light
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;}
|
||||
.cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;}
|
||||
.cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;}
|
||||
.cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }
|
||||
.cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
|
||||
.cm-s-base16-light .CodeMirror-linenumber {color: #b0b0b0;}
|
||||
.cm-s-base16-light .CodeMirror-cursor {border-left: 1px solid #505050 !important;}
|
||||
|
||||
.cm-s-base16-light span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-light span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-number {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-string {color: #f4bf75;}
|
||||
|
||||
.cm-s-base16-light span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-light span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-light span.cm-bracket {color: #202020;}
|
||||
.cm-s-base16-light span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-link {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-error {background: #ac4142; color: #505050;}
|
||||
|
||||
.cm-s-base16-light .CodeMirror-activeline-background {background: #DDDCDC !important;}
|
||||
.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
.cm-s-eclipse span.cm-meta {color: #FF1717;}
|
||||
.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
|
||||
.cm-s-eclipse span.cm-atom {color: #219;}
|
||||
.cm-s-eclipse span.cm-number {color: #164;}
|
||||
.cm-s-eclipse span.cm-def {color: #00f;}
|
||||
.cm-s-eclipse span.cm-variable {color: black;}
|
||||
.cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-property {color: black;}
|
||||
.cm-s-eclipse span.cm-operator {color: black;}
|
||||
.cm-s-eclipse span.cm-comment {color: #3F7F5F;}
|
||||
.cm-s-eclipse span.cm-string {color: #2A00FF;}
|
||||
.cm-s-eclipse span.cm-string-2 {color: #f50;}
|
||||
.cm-s-eclipse span.cm-qualifier {color: #555;}
|
||||
.cm-s-eclipse span.cm-builtin {color: #30a;}
|
||||
.cm-s-eclipse span.cm-bracket {color: #cc7;}
|
||||
.cm-s-eclipse span.cm-tag {color: #170;}
|
||||
.cm-s-eclipse span.cm-attribute {color: #00c;}
|
||||
.cm-s-eclipse span.cm-link {color: #219;}
|
||||
.cm-s-eclipse span.cm-error {color: #f00;}
|
||||
|
||||
.cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
|
||||
.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-variable {color: black;}
|
||||
.cm-s-elegant span.cm-variable-2 {color: #b11;}
|
||||
.cm-s-elegant span.cm-qualifier {color: #555;}
|
||||
.cm-s-elegant span.cm-keyword {color: #730;}
|
||||
.cm-s-elegant span.cm-builtin {color: #30a;}
|
||||
.cm-s-elegant span.cm-link {color: #762;}
|
||||
.cm-s-elegant span.cm-error {background-color: #fdd;}
|
||||
|
||||
.cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/****************************************************************/
|
||||
/* Based on mbonaci's Brackets mbo theme */
|
||||
/* https://github.com/mbonaci/global/blob/master/Mbo.tmTheme */
|
||||
/* Create your own: http://tmtheme-editor.herokuapp.com */
|
||||
/****************************************************************/
|
||||
|
||||
.cm-s-mbo.CodeMirror {background: #2c2c2c; color: #ffffec;}
|
||||
.cm-s-mbo div.CodeMirror-selected {background: #716C62 !important;}
|
||||
.cm-s-mbo .CodeMirror-gutters {background: #4e4e4e; border-right: 0px;}
|
||||
.cm-s-mbo .CodeMirror-guttermarker { color: white; }
|
||||
.cm-s-mbo .CodeMirror-guttermarker-subtle { color: grey; }
|
||||
.cm-s-mbo .CodeMirror-linenumber {color: #dadada;}
|
||||
.cm-s-mbo .CodeMirror-cursor {border-left: 1px solid #ffffec !important;}
|
||||
|
||||
.cm-s-mbo span.cm-comment {color: #95958a;}
|
||||
.cm-s-mbo span.cm-atom {color: #00a8c6;}
|
||||
.cm-s-mbo span.cm-number {color: #00a8c6;}
|
||||
|
||||
.cm-s-mbo span.cm-property, .cm-s-mbo span.cm-attribute {color: #9ddfe9;}
|
||||
.cm-s-mbo span.cm-keyword {color: #ffb928;}
|
||||
.cm-s-mbo span.cm-string {color: #ffcf6c;}
|
||||
.cm-s-mbo span.cm-string.cm-property {color: #ffffec;}
|
||||
|
||||
.cm-s-mbo span.cm-variable {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-variable-2 {color: #00a8c6;}
|
||||
.cm-s-mbo span.cm-def {color: #ffffec;}
|
||||
.cm-s-mbo span.cm-bracket {color: #fffffc; font-weight: bold;}
|
||||
.cm-s-mbo span.cm-tag {color: #9ddfe9;}
|
||||
.cm-s-mbo span.cm-link {color: #f54b07;}
|
||||
.cm-s-mbo span.cm-error {border-bottom: #636363; color: #ffffec;}
|
||||
.cm-s-mbo span.cm-qualifier {color: #ffffec;}
|
||||
|
||||
.cm-s-mbo .CodeMirror-activeline-background {background: #494b41 !important;}
|
||||
.cm-s-mbo .CodeMirror-matchingbracket {color: #222 !important;}
|
||||
.cm-s-mbo .CodeMirror-matchingtag {background: rgba(255, 255, 255, .37);}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/* Based on the theme at http://bonsaiden.github.com/JavaScript-Garden */
|
||||
|
||||
/*<!--match-->*/
|
||||
.cm-s-midnight span.CodeMirror-matchhighlight { background: #494949; }
|
||||
.cm-s-midnight.CodeMirror-focused span.CodeMirror-matchhighlight { background: #314D67 !important; }
|
||||
|
||||
/*<!--activeline-->*/
|
||||
.cm-s-midnight .CodeMirror-activeline-background {background: #253540 !important;}
|
||||
|
||||
.cm-s-midnight.CodeMirror {
|
||||
background: #0F192A;
|
||||
color: #D1EDFF;
|
||||
}
|
||||
|
||||
.cm-s-midnight.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
|
||||
.cm-s-midnight div.CodeMirror-selected {background: #314D67 !important;}
|
||||
.cm-s-midnight .CodeMirror-gutters {background: #0F192A; border-right: 1px solid;}
|
||||
.cm-s-midnight .CodeMirror-guttermarker { color: white; }
|
||||
.cm-s-midnight .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
|
||||
.cm-s-midnight .CodeMirror-linenumber {color: #D0D0D0;}
|
||||
.cm-s-midnight .CodeMirror-cursor {
|
||||
border-left: 1px solid #F8F8F0 !important;
|
||||
}
|
||||
|
||||
.cm-s-midnight span.cm-comment {color: #428BDD;}
|
||||
.cm-s-midnight span.cm-atom {color: #AE81FF;}
|
||||
.cm-s-midnight span.cm-number {color: #D1EDFF;}
|
||||
|
||||
.cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute {color: #A6E22E;}
|
||||
.cm-s-midnight span.cm-keyword {color: #E83737;}
|
||||
.cm-s-midnight span.cm-string {color: #1DC116;}
|
||||
|
||||
.cm-s-midnight span.cm-variable {color: #FFAA3E;}
|
||||
.cm-s-midnight span.cm-variable-2 {color: #FFAA3E;}
|
||||
.cm-s-midnight span.cm-def {color: #4DD;}
|
||||
.cm-s-midnight span.cm-bracket {color: #D1EDFF;}
|
||||
.cm-s-midnight span.cm-tag {color: #449;}
|
||||
.cm-s-midnight span.cm-link {color: #AE81FF;}
|
||||
.cm-s-midnight span.cm-error {background: #F92672; color: #F8F8F0;}
|
||||
|
||||
.cm-s-midnight .CodeMirror-matchingbracket {
|
||||
text-decoration: underline;
|
||||
color: white !important;
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* Based on Sublime Text's Monokai theme */
|
||||
|
||||
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
|
||||
.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
|
||||
.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
|
||||
.cm-s-monokai .CodeMirror-guttermarker { color: white; }
|
||||
.cm-s-monokai .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
|
||||
.cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
|
||||
.cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
|
||||
|
||||
.cm-s-monokai span.cm-comment {color: #75715e;}
|
||||
.cm-s-monokai span.cm-atom {color: #ae81ff;}
|
||||
.cm-s-monokai span.cm-number {color: #ae81ff;}
|
||||
|
||||
.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
|
||||
.cm-s-monokai span.cm-keyword {color: #f92672;}
|
||||
.cm-s-monokai span.cm-string {color: #e6db74;}
|
||||
|
||||
.cm-s-monokai span.cm-variable {color: #a6e22e;}
|
||||
.cm-s-monokai span.cm-variable-2 {color: #9effff;}
|
||||
.cm-s-monokai span.cm-def {color: #fd971f;}
|
||||
.cm-s-monokai span.cm-bracket {color: #f8f8f2;}
|
||||
.cm-s-monokai span.cm-tag {color: #f92672;}
|
||||
.cm-s-monokai span.cm-link {color: #ae81ff;}
|
||||
.cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
|
||||
|
||||
.cm-s-monokai .CodeMirror-activeline-background {background: #373831 !important;}
|
||||
.cm-s-monokai .CodeMirror-matchingbracket {
|
||||
text-decoration: underline;
|
||||
color: white !important;
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: Paraíso (Dark)
|
||||
Author: Jan T. Sott
|
||||
|
||||
Color scheme by Jan T. Sott (https://github.com/idleberg/Paraiso-CodeMirror)
|
||||
Inspired by the art of Rubens LP (http://www.rubenslp.com.br)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-paraiso-dark.CodeMirror {background: #2f1e2e; color: #b9b6b0;}
|
||||
.cm-s-paraiso-dark div.CodeMirror-selected {background: #41323f !important;}
|
||||
.cm-s-paraiso-dark .CodeMirror-gutters {background: #2f1e2e; border-right: 0px;}
|
||||
.cm-s-paraiso-dark .CodeMirror-guttermarker { color: #ef6155; }
|
||||
.cm-s-paraiso-dark .CodeMirror-guttermarker-subtle { color: #776e71; }
|
||||
.cm-s-paraiso-dark .CodeMirror-linenumber {color: #776e71;}
|
||||
.cm-s-paraiso-dark .CodeMirror-cursor {border-left: 1px solid #8d8687 !important;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-comment {color: #e96ba8;}
|
||||
.cm-s-paraiso-dark span.cm-atom {color: #815ba4;}
|
||||
.cm-s-paraiso-dark span.cm-number {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute {color: #48b685;}
|
||||
.cm-s-paraiso-dark span.cm-keyword {color: #ef6155;}
|
||||
.cm-s-paraiso-dark span.cm-string {color: #fec418;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-variable {color: #48b685;}
|
||||
.cm-s-paraiso-dark span.cm-variable-2 {color: #06b6ef;}
|
||||
.cm-s-paraiso-dark span.cm-def {color: #f99b15;}
|
||||
.cm-s-paraiso-dark span.cm-bracket {color: #b9b6b0;}
|
||||
.cm-s-paraiso-dark span.cm-tag {color: #ef6155;}
|
||||
.cm-s-paraiso-dark span.cm-link {color: #815ba4;}
|
||||
.cm-s-paraiso-dark span.cm-error {background: #ef6155; color: #8d8687;}
|
||||
|
||||
.cm-s-paraiso-dark .CodeMirror-activeline-background {background: #4D344A !important;}
|
||||
.cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: Paraíso (Light)
|
||||
Author: Jan T. Sott
|
||||
|
||||
Color scheme by Jan T. Sott (https://github.com/idleberg/Paraiso-CodeMirror)
|
||||
Inspired by the art of Rubens LP (http://www.rubenslp.com.br)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-paraiso-light.CodeMirror {background: #e7e9db; color: #41323f;}
|
||||
.cm-s-paraiso-light div.CodeMirror-selected {background: #b9b6b0 !important;}
|
||||
.cm-s-paraiso-light .CodeMirror-gutters {background: #e7e9db; border-right: 0px;}
|
||||
.cm-s-paraiso-light .CodeMirror-guttermarker { color: black; }
|
||||
.cm-s-paraiso-light .CodeMirror-guttermarker-subtle { color: #8d8687; }
|
||||
.cm-s-paraiso-light .CodeMirror-linenumber {color: #8d8687;}
|
||||
.cm-s-paraiso-light .CodeMirror-cursor {border-left: 1px solid #776e71 !important;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-comment {color: #e96ba8;}
|
||||
.cm-s-paraiso-light span.cm-atom {color: #815ba4;}
|
||||
.cm-s-paraiso-light span.cm-number {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute {color: #48b685;}
|
||||
.cm-s-paraiso-light span.cm-keyword {color: #ef6155;}
|
||||
.cm-s-paraiso-light span.cm-string {color: #fec418;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-variable {color: #48b685;}
|
||||
.cm-s-paraiso-light span.cm-variable-2 {color: #06b6ef;}
|
||||
.cm-s-paraiso-light span.cm-def {color: #f99b15;}
|
||||
.cm-s-paraiso-light span.cm-bracket {color: #41323f;}
|
||||
.cm-s-paraiso-light span.cm-tag {color: #ef6155;}
|
||||
.cm-s-paraiso-light span.cm-link {color: #815ba4;}
|
||||
.cm-s-paraiso-light span.cm-error {background: #ef6155; color: #776e71;}
|
||||
|
||||
.cm-s-paraiso-light .CodeMirror-activeline-background {background: #CFD1C4 !important;}
|
||||
.cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
.cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; }
|
||||
.cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D !important; }
|
||||
.cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; }
|
||||
.cm-s-the-matrix .CodeMirror-guttermarker { color: #0f0; }
|
||||
.cm-s-the-matrix .CodeMirror-guttermarker-subtle { color: white; }
|
||||
.cm-s-the-matrix .CodeMirror-linenumber { color: #FFFFFF; }
|
||||
.cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00 !important; }
|
||||
|
||||
.cm-s-the-matrix span.cm-keyword {color: #008803; font-weight: bold;}
|
||||
.cm-s-the-matrix span.cm-atom {color: #3FF;}
|
||||
.cm-s-the-matrix span.cm-number {color: #FFB94F;}
|
||||
.cm-s-the-matrix span.cm-def {color: #99C;}
|
||||
.cm-s-the-matrix span.cm-variable {color: #F6C;}
|
||||
.cm-s-the-matrix span.cm-variable-2 {color: #C6F;}
|
||||
.cm-s-the-matrix span.cm-variable-3 {color: #96F;}
|
||||
.cm-s-the-matrix span.cm-property {color: #62FFA0;}
|
||||
.cm-s-the-matrix span.cm-operator {color: #999}
|
||||
.cm-s-the-matrix span.cm-comment {color: #CCCCCC;}
|
||||
.cm-s-the-matrix span.cm-string {color: #39C;}
|
||||
.cm-s-the-matrix span.cm-meta {color: #C9F;}
|
||||
.cm-s-the-matrix span.cm-qualifier {color: #FFF700;}
|
||||
.cm-s-the-matrix span.cm-builtin {color: #30a;}
|
||||
.cm-s-the-matrix span.cm-bracket {color: #cc7;}
|
||||
.cm-s-the-matrix span.cm-tag {color: #FFBD40;}
|
||||
.cm-s-the-matrix span.cm-attribute {color: #FFF700;}
|
||||
.cm-s-the-matrix span.cm-error {color: #FF0000;}
|
||||
|
||||
.cm-s-the-matrix .CodeMirror-activeline-background {background: #040;}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
|
||||
Name: Tomorrow Night - Eighties
|
||||
Author: Chris Kempson
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-tomorrow-night-eighties.CodeMirror {background: #000000; color: #CCCCCC;}
|
||||
.cm-s-tomorrow-night-eighties div.CodeMirror-selected {background: #2D2D2D !important;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-gutters {background: #000000; border-right: 0px;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-guttermarker { color: #f2777a; }
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-guttermarker-subtle { color: #777; }
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-linenumber {color: #515151;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-cursor {border-left: 1px solid #6A6A6A !important;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-comment {color: #d27b53;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-atom {color: #a16a94;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute {color: #99cc99;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-keyword {color: #f2777a;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-string {color: #ffcc66;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-variable {color: #99cc99;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-variable-2 {color: #6699cc;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-def {color: #f99157;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-bracket {color: #CCCCCC;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-tag {color: #f2777a;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-link {color: #a16a94;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-error {background: #f2777a; color: #6A6A6A;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-activeline-background {background: #343600 !important;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
*.txt text eol=lf
|
||||
*.js text eol=lf
|
||||
*.html text eol=lf
|
||||
*.md text eol=lf
|
||||
*.json text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.css text eol=lf
|
||||
*.svg text eol=lf
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/node_modules
|
||||
/demo
|
||||
/doc
|
||||
/test
|
||||
/test*.html
|
||||
/index.html
|
||||
/mode/*/*test.js
|
||||
/mode/*/*.html
|
||||
/mode/index.html
|
||||
.*
|
||||
/bin/authors.sh
|
||||
/bin/lint
|
||||
/bin/release
|
||||
/bin/upload-release.js
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
sudo: false
|
||||
cache: npm
|
||||
|
|
@ -0,0 +1,852 @@
|
|||
List of CodeMirror contributors. Updated before every release.
|
||||
|
||||
4oo4
|
||||
4r2r
|
||||
Aaron Brooks
|
||||
Abdelouahab
|
||||
Abdussalam Abdurrahman
|
||||
Abe Fettig
|
||||
Abhishek Gahlot
|
||||
Adam Ahmed
|
||||
Adam King
|
||||
Adam Particka
|
||||
adanlobato
|
||||
Adán Lobato
|
||||
Aditya Toshniwal
|
||||
Adrian Aichner
|
||||
Adrian Heine
|
||||
Adrien Bertrand
|
||||
aeroson
|
||||
Ahmad Amireh
|
||||
Ahmad M. Zawawi
|
||||
ahoward
|
||||
Akeksandr Motsjonov
|
||||
Alasdair Smith
|
||||
AlbertHilb
|
||||
Alberto González Palomo
|
||||
Alberto Pose
|
||||
Albert Xing
|
||||
Alexander Pavlov
|
||||
Alexander Schepanovski
|
||||
Alexander Shvets
|
||||
Alexander Solovyov
|
||||
Alexandre Bique
|
||||
alexey-k
|
||||
Alex Piggott
|
||||
Aliaksei Chapyzhenka
|
||||
Allen Sarkisyan
|
||||
Ami Fischman
|
||||
Amin Shali
|
||||
Amin Ullah Khan
|
||||
amshali@google.com
|
||||
Amsul
|
||||
amuntean
|
||||
Amy
|
||||
Ananya Sen
|
||||
anaran
|
||||
AndersMad
|
||||
Anders Nawroth
|
||||
Anderson Mesquita
|
||||
Anders Wåglund
|
||||
Andrea G
|
||||
Andreas Reischuck
|
||||
Andres Taylor
|
||||
Andre von Houck
|
||||
Andrew Cheng
|
||||
Andrew Dassonville
|
||||
Andrey Fedorov
|
||||
Andrey Klyuchnikov
|
||||
Andrey Lushnikov
|
||||
Andrey Shchekin
|
||||
Andy Joslin
|
||||
Andy Kimball
|
||||
Andy Li
|
||||
Angelo
|
||||
angelozerr
|
||||
angelo.zerr@gmail.com
|
||||
Ankit
|
||||
Ankit Ahuja
|
||||
Ansel Santosa
|
||||
Anthony Dugois
|
||||
anthonygego
|
||||
Anthony Gégo
|
||||
Anthony Grimes
|
||||
Anton Kovalyov
|
||||
antosarho
|
||||
Apollo Zhu
|
||||
AQNOUCH Mohammed
|
||||
Aram Shatakhtsyan
|
||||
areos
|
||||
Arnab Bose
|
||||
Arnoud Buzing
|
||||
Arsène von Wyss
|
||||
Arthur Müller
|
||||
Arun Narasani
|
||||
as3boyan
|
||||
asolove
|
||||
atelierbram
|
||||
AtomicPages LLC
|
||||
Atul Bhouraskar
|
||||
Aurelian Oancea
|
||||
Axel Lewenhaupt
|
||||
Baptiste Augrain
|
||||
Barret Rennie
|
||||
Bartosz Dziewoński
|
||||
Basarat Ali Syed
|
||||
Bastian Müller
|
||||
belhaj
|
||||
Bem Jones-Bey
|
||||
benbro
|
||||
Beni Cherniavsky-Paskin
|
||||
Benjamin DeCoste
|
||||
Benjamin Young
|
||||
Ben Keen
|
||||
Ben Miller
|
||||
Ben Mosher
|
||||
Bernhard Sirlinger
|
||||
Bert Chang
|
||||
Bharad
|
||||
BigBlueHat
|
||||
Billy Moon
|
||||
binny
|
||||
Bjorn Hansen
|
||||
B Krishna Chaitanya
|
||||
Blaine G
|
||||
blukat29
|
||||
Bo
|
||||
boomyjee
|
||||
Bo Peng
|
||||
borawjm
|
||||
Brad Metcalf
|
||||
Brandon Frohs
|
||||
Brandon Wamboldt
|
||||
Bret Little
|
||||
Brett Zamir
|
||||
Brian Grinstead
|
||||
Brian Sletten
|
||||
brrd
|
||||
Bruce Mitchener
|
||||
Bruno Logerfo
|
||||
Bryan Gin-ge Chen
|
||||
Bryan Massoth
|
||||
Caitlin Potter
|
||||
Calin Barbat
|
||||
callodacity
|
||||
Camilo Roca
|
||||
Casey Klebba
|
||||
César González Íñiguez
|
||||
Chad Jolly
|
||||
Chandra Sekhar Pydi
|
||||
Charles Skelton
|
||||
Cheah Chu Yeow
|
||||
Chhekur
|
||||
Chris Colborne
|
||||
Chris Coyier
|
||||
Chris Ford
|
||||
Chris Granger
|
||||
Chris Houseknecht
|
||||
Chris Lohfink
|
||||
Chris Morgan
|
||||
Chris Reeves
|
||||
Chris Smith
|
||||
Christian Gruen
|
||||
Christian Oyarzun
|
||||
Christian Petrov
|
||||
christopherblaser
|
||||
Christopher Brown
|
||||
Christopher Kramer
|
||||
Christopher Mitchell
|
||||
Christopher Pfohl
|
||||
Christopher Wallis
|
||||
Chunliang Lyu
|
||||
ciaranj
|
||||
clso
|
||||
CodeAnimal
|
||||
CodeBitt
|
||||
coderaiser
|
||||
Cole R Lawrence
|
||||
ComFreek
|
||||
Cristian Prieto
|
||||
Curran Kelleher
|
||||
Curtis Gagliardi
|
||||
dagsta
|
||||
daines
|
||||
Dale Jung
|
||||
Dan Bentley
|
||||
Dan Heberden
|
||||
Daniel, Dao Quang Minh
|
||||
Daniele Di Sarli
|
||||
Daniel Faust
|
||||
Daniel Hanggi
|
||||
Daniel Huigens
|
||||
Daniel Kesler
|
||||
Daniel KJ
|
||||
Daniel Neel
|
||||
Daniel Parnell
|
||||
Daniel Thwaites
|
||||
Danila Malyutin
|
||||
Danny Yoo
|
||||
darealshinji
|
||||
Darius Roberts
|
||||
databricks-david-lewis
|
||||
Dave Brondsema
|
||||
Dave MacLachlan
|
||||
Dave Myers
|
||||
David Barnett
|
||||
David H. Bronke
|
||||
David Mignot
|
||||
David Pathakjee
|
||||
David Rodrigues
|
||||
David Santana
|
||||
David Vázquez
|
||||
David Whittington
|
||||
deebugger
|
||||
Deep Thought
|
||||
Denis Ovsienko
|
||||
Devin Abbott
|
||||
Devon Carew
|
||||
Dick Choi
|
||||
Diego Fernandez
|
||||
dignifiedquire
|
||||
Dimage Sapelkin
|
||||
dmaclach
|
||||
Dmitry Kiselyov
|
||||
domagoj412
|
||||
Dominator008
|
||||
Domizio Demichelis
|
||||
Doug Blank
|
||||
Doug Wikle
|
||||
Drew Bratcher
|
||||
Drew Hintz
|
||||
Drew Khoury
|
||||
Drini Cami
|
||||
Dror BG
|
||||
Duncan Lilley
|
||||
duralog
|
||||
dwelle
|
||||
eborden
|
||||
edoroshenko
|
||||
edsharp
|
||||
ekhaled
|
||||
Elisée
|
||||
elpnt
|
||||
Emmanuel Schanzer
|
||||
Enam Mijbah Noor
|
||||
Eric Allam
|
||||
Eric Bogard
|
||||
Erik Demaine
|
||||
Erik Welander
|
||||
eustas
|
||||
Evan Minsk
|
||||
Fabien Dubosson
|
||||
Fabien O'Carroll
|
||||
Fabio Zendhi Nagao
|
||||
Faiza Alsaied
|
||||
Fauntleroy
|
||||
fbuchinger
|
||||
feizhang365
|
||||
Felipe Lalanne
|
||||
Felix Raab
|
||||
ficristo
|
||||
Filip Noetzel
|
||||
Filip Stollár
|
||||
Filype Pereira
|
||||
finalfantasia
|
||||
flack
|
||||
Florian Felten
|
||||
Forbes Lindesay
|
||||
ForbesLindesay
|
||||
Ford_Lawnmower
|
||||
Forrest Oliphant
|
||||
Franco Catena
|
||||
Frank Seifferth
|
||||
Frank Wiegand
|
||||
fraxx001
|
||||
Fredrik Borg
|
||||
FUJI Goro (gfx)
|
||||
Gabriel Gheorghian
|
||||
Gabriel Horner
|
||||
Gabriel Nahmias
|
||||
galambalazs
|
||||
Gary Sheng
|
||||
Gautam Mehta
|
||||
Gavin Douglas
|
||||
gekkoe
|
||||
Geordie Hall
|
||||
George Stephanis
|
||||
geowarin
|
||||
Gerard Braad
|
||||
Gergely Hegykozi
|
||||
Germain Chazot
|
||||
Giovanni Calò
|
||||
Glebov Boris
|
||||
Glenn Jorde
|
||||
Glenn Ruehle
|
||||
goldsmcb
|
||||
Golevka
|
||||
Google LLC
|
||||
Gordon Smith
|
||||
Grant Skinner
|
||||
greengiant
|
||||
Gregory Koberger
|
||||
Grzegorz Mazur
|
||||
Guang Li
|
||||
Guan Gui
|
||||
Guillaume Massé
|
||||
Guillaume Massé
|
||||
guraga
|
||||
Gustavo Rodrigues
|
||||
Hakan Tunc
|
||||
Hanno Fellmann
|
||||
Hans Engel
|
||||
Hanzhao Deng
|
||||
Harald Schilly
|
||||
Hardest
|
||||
Harshvardhan Gupta
|
||||
Hasan Delibaş
|
||||
Hasan Karahan
|
||||
Heanes
|
||||
Hector Oswaldo Caballero
|
||||
Hélio
|
||||
Hendrik Wallbaum
|
||||
Henrik Haugbølle
|
||||
Herculano Campos
|
||||
hidaiy
|
||||
Hiroyuki Makino
|
||||
hitsthings
|
||||
Hocdoc
|
||||
Hugues Malphettes
|
||||
Ian Beck
|
||||
Ian Davies
|
||||
Ian Dickinson
|
||||
Ian Rose
|
||||
Ian Wehrman
|
||||
Ian Wetherbee
|
||||
Ice White
|
||||
ICHIKAWA, Yuji
|
||||
idleberg
|
||||
Igor Petruk
|
||||
ilvalle
|
||||
Ilya Kharlamov
|
||||
Ingo Richter
|
||||
Irakli Gozalishvili
|
||||
Ivan Kurnosov
|
||||
Ivoah
|
||||
Jacob Lee
|
||||
Jaimin
|
||||
Jake Peyser
|
||||
Jakob Miland
|
||||
Jakub Vrana
|
||||
Jakub Vrána
|
||||
James Campos
|
||||
James Cockshull
|
||||
James Howard
|
||||
James Thorne
|
||||
Jamie Hill
|
||||
Jamie Morris
|
||||
Janice Leung
|
||||
Jan Jongboom
|
||||
jankeromnes
|
||||
Jan Keromnes
|
||||
Jan Odvarko
|
||||
Jan Schär
|
||||
Jan T. Sott
|
||||
Jared Dean
|
||||
Jared Forsyth
|
||||
Jared Jacobs
|
||||
Jason
|
||||
Jason Barnabe
|
||||
Jason Grout
|
||||
Jason Heeris
|
||||
Jason Johnston
|
||||
Jason San Jose
|
||||
Jason Siefken
|
||||
Jayaprabhakar
|
||||
Jaydeep Solanki
|
||||
Jean Boussier
|
||||
Jeff Blaisdell
|
||||
Jeff Hanke
|
||||
Jeff Jenkins
|
||||
jeffkenton
|
||||
Jeff Pickhardt
|
||||
jem (graphite)
|
||||
Jeremy Parmenter
|
||||
Jim
|
||||
Jim Avery
|
||||
jkaplon
|
||||
JobJob
|
||||
jochenberger
|
||||
Jochen Berger
|
||||
Joel Einbinder
|
||||
joelpinheiro
|
||||
joewalsh
|
||||
Johan Ask
|
||||
Johannes
|
||||
John Connor
|
||||
John-David Dalton
|
||||
John Engler
|
||||
John Lees-Miller
|
||||
John Ryan
|
||||
John Snelson
|
||||
John Van Der Loo
|
||||
Jon Ander Peñalba
|
||||
Jonas Döbertin
|
||||
Jonas Helfer
|
||||
Jonathan Dierksen
|
||||
Jonathan Hart
|
||||
Jonathan Malmaud
|
||||
Jon Gacnik
|
||||
jongalloway
|
||||
Jon Malmaud
|
||||
Jon Sangster
|
||||
Joo
|
||||
Joost-Wim Boekesteijn
|
||||
Joseph Pecoraro
|
||||
Josh Barnes
|
||||
Josh Cohen
|
||||
Josh Soref
|
||||
Joshua Newman
|
||||
Josh Watzman
|
||||
jots
|
||||
Joy Zhong
|
||||
jsoojeon
|
||||
ju1ius
|
||||
Juan Benavides Romero
|
||||
Jucovschi Constantin
|
||||
Juho Vuori
|
||||
Julien CROUZET
|
||||
Julien Rebetez
|
||||
Justin Andresen
|
||||
Justin Hileman
|
||||
jwallers@gmail.com
|
||||
kaniga
|
||||
karevn
|
||||
Karol
|
||||
Kayur Patel
|
||||
Kazuhito Hokamura
|
||||
kcwiakala
|
||||
Kees de Kooter
|
||||
Kenan Christian Dimas
|
||||
Ken Newman
|
||||
ken restivo
|
||||
Ken Rockot
|
||||
Kevin Earls
|
||||
Kevin Kwok
|
||||
Kevin Muret
|
||||
Kevin Sawicki
|
||||
Kevin Ushey
|
||||
Kier Darby
|
||||
Klaus Silveira
|
||||
Koh Zi Han, Cliff
|
||||
komakino
|
||||
Konstantin Lopuhin
|
||||
koops
|
||||
Kris Ciccarello
|
||||
ks-ifware
|
||||
kubelsmieci
|
||||
kvncp
|
||||
KwanEsq
|
||||
Kyle Kelley
|
||||
KyleMcNutt
|
||||
LaKing
|
||||
Lanfei
|
||||
Lanny
|
||||
laobubu
|
||||
Laszlo Vidacs
|
||||
leaf
|
||||
leaf corcoran
|
||||
Lemmon
|
||||
Leo Baschy
|
||||
Leonid Khachaturov
|
||||
Leon Sorokin
|
||||
Leonya Khachaturov
|
||||
Liam Newman
|
||||
Libo Cannici
|
||||
Lior Goldberg
|
||||
Lior Shub
|
||||
LloydMilligan
|
||||
LM
|
||||
lochel
|
||||
Lonnie Abelbeck
|
||||
Lorenzo Simionato
|
||||
Lorenzo Stoakes
|
||||
Louis Mauchet
|
||||
Luca Fabbri
|
||||
Luciano Longo
|
||||
Luciano Santana
|
||||
Lu Fangjian
|
||||
Luke Browning
|
||||
Luke Granger-Brown
|
||||
Luke Stagner
|
||||
lynschinzer
|
||||
M1cha
|
||||
Madhura Jayaratne
|
||||
Maksim Lin
|
||||
Maksym Taran
|
||||
Malay Majithia
|
||||
Manideep
|
||||
Manuel Rego Casasnovas
|
||||
Marat Dreizin
|
||||
Marcel Gerber
|
||||
Marcelo Camargo
|
||||
Marco Aurélio
|
||||
Marco Munizaga
|
||||
Marcus Bointon
|
||||
Marek Rudnicki
|
||||
Marijn Haverbeke
|
||||
Mário Gonçalves
|
||||
Mario Pietsch
|
||||
Mark Anderson
|
||||
Mark Dalgleish
|
||||
Mark Hamstra
|
||||
Mark Lentczner
|
||||
Marko Bonaci
|
||||
Mark Peace
|
||||
Markus Bordihn
|
||||
Markus Olsson
|
||||
Martin Balek
|
||||
Martín Gaitán
|
||||
Martin Hasoň
|
||||
Martin Hunt
|
||||
Martin Laine
|
||||
Martin Zagora
|
||||
Mason Malone
|
||||
Mateusz Paprocki
|
||||
Mathias Bynens
|
||||
mats cronqvist
|
||||
Matt Gaide
|
||||
Matthew Bauer
|
||||
Matthew Beale
|
||||
matthewhayes
|
||||
Matthew Rathbone
|
||||
Matthew Suozzo
|
||||
Matthias Bussonnier
|
||||
Matthias BUSSONNIER
|
||||
Mattia Astorino
|
||||
Matt MacPherson
|
||||
Matt McDonald
|
||||
Matt Pass
|
||||
Matt Sacks
|
||||
mauricio
|
||||
Maximilian Hils
|
||||
Maxim Kraev
|
||||
Max Kirsch
|
||||
Max Schaefer
|
||||
Max Wu
|
||||
Max Xiantu
|
||||
mbarkhau
|
||||
McBrainy
|
||||
mce2
|
||||
melpon
|
||||
meshuamam
|
||||
Metatheos
|
||||
Micah Dubinko
|
||||
Michael
|
||||
Michael Goderbauer
|
||||
Michael Grey
|
||||
Michael Kaminsky
|
||||
Michael Lehenbauer
|
||||
Michael Wadman
|
||||
Michael Walker
|
||||
Michael Zhou
|
||||
Michal Čihař
|
||||
Michal Dorner
|
||||
Michal Kapiczynski
|
||||
Mighty Guava
|
||||
Miguel Castillo
|
||||
mihailik
|
||||
Mika Andrianarijaona
|
||||
Mike
|
||||
Mike Bostock
|
||||
Mike Brevoort
|
||||
Mike Diaz
|
||||
Mike Ivanov
|
||||
Mike Kadin
|
||||
Mike Kobit
|
||||
Milan Szekely
|
||||
MinRK
|
||||
Miraculix87
|
||||
misfo
|
||||
mkaminsky11
|
||||
mloginov
|
||||
Moritz Schubotz (physikerwelt)
|
||||
Moritz Schwörer
|
||||
Moshe Wajnberg
|
||||
mps
|
||||
ms
|
||||
mtaran-google
|
||||
Mu-An ✌️ Chiou
|
||||
Mu-An Chiou
|
||||
mzabuawala
|
||||
Narciso Jaramillo
|
||||
Nathan Williams
|
||||
ndr
|
||||
Neil Anderson
|
||||
neon-dev
|
||||
nerbert
|
||||
NetworkNode
|
||||
nextrevision
|
||||
ngn
|
||||
nguillaumin
|
||||
Ng Zhi An
|
||||
Nicholas Bollweg
|
||||
Nicholas Bollweg (Nick)
|
||||
NickKolok
|
||||
Nick Kreeger
|
||||
Nick Small
|
||||
Nicolas Chevobbe
|
||||
Nicolas Kick
|
||||
Nicolò Ribaudo
|
||||
Niels van Groningen
|
||||
nightwing
|
||||
Nikita Beloglazov
|
||||
Nikita Vasilyev
|
||||
Nikolaj Kappler
|
||||
Nikolay Kostov
|
||||
nilp0inter
|
||||
Nils Knappmeier
|
||||
Nisarg Jhaveri
|
||||
nlwillia
|
||||
noragrossman
|
||||
Norman Rzepka
|
||||
Nouzbe
|
||||
Oleksandr Yakovenko
|
||||
Olivia Ytterbrink
|
||||
Opender Singh
|
||||
opl-
|
||||
Oreoluwa Onatemowo
|
||||
oscar.lofwenhamn
|
||||
Oskar Segersvärd
|
||||
ossdev
|
||||
overdodactyl
|
||||
pablo
|
||||
pabloferz
|
||||
Pablo Zubieta
|
||||
paddya
|
||||
Page
|
||||
paladox
|
||||
Panupong Pasupat
|
||||
paris
|
||||
Paris
|
||||
Paris Kasidiaris
|
||||
Patil Arpith
|
||||
Patrick Stoica
|
||||
Patrick Strawderman
|
||||
Paul Garvin
|
||||
Paul Ivanov
|
||||
Paul Masson
|
||||
Pavel
|
||||
Pavel Feldman
|
||||
Pavel Petržela
|
||||
Pavel Strashkin
|
||||
Paweł Bartkiewicz
|
||||
peteguhl
|
||||
peter
|
||||
Peter Flynn
|
||||
peterkroon
|
||||
Peter Kroon
|
||||
Philipp A
|
||||
Philipp Markovics
|
||||
Philip Stadermann
|
||||
Pi Delport
|
||||
Pierre Gerold
|
||||
Pieter Ouwerkerk
|
||||
Pontus Melke
|
||||
prasanthj
|
||||
Prasanth J
|
||||
Prayag Verma
|
||||
prendota
|
||||
Prendota
|
||||
Qiang Li
|
||||
Radek Piórkowski
|
||||
Rahul
|
||||
Rahul Anand
|
||||
ramwin1
|
||||
Randall Mason
|
||||
Randy Burden
|
||||
Randy Edmunds
|
||||
Randy Luecke
|
||||
Raphael Amorim
|
||||
Rasmus Erik Voel Jensen
|
||||
Rasmus Schultz
|
||||
raymondf
|
||||
Raymond Hill
|
||||
ray ratchup
|
||||
Ray Ratchup
|
||||
Remi Nyborg
|
||||
Renaud Durlin
|
||||
Reynold Xin
|
||||
Richard Denton
|
||||
Richard van der Meer
|
||||
Richard Z.H. Wang
|
||||
Rishi Goomar
|
||||
Robert Brignull
|
||||
Robert Crossfield
|
||||
Robert Martin
|
||||
Roberto Abdelkader Martínez Pérez
|
||||
robertop23
|
||||
Robert Plummer
|
||||
Roman Janusz
|
||||
Rrandom
|
||||
Rrrandom
|
||||
Ruslan Osmanov
|
||||
Ryan Pangrle
|
||||
Ryan Petrello
|
||||
Ryan Prior
|
||||
ryu-sato
|
||||
sabaca
|
||||
Sam Lee
|
||||
Sam Rawlins
|
||||
Samuel Ainsworth
|
||||
Sam Wilson
|
||||
sandeepshetty
|
||||
Sander AKA Redsandro
|
||||
Sander Verweij
|
||||
santec
|
||||
Sarah McAlear and Wenlin Zhang
|
||||
Sascha Peilicke
|
||||
Sasha Varlamov
|
||||
satamas
|
||||
satchmorun
|
||||
sathyamoorthi
|
||||
Saul Costa
|
||||
S. Chris Colbert
|
||||
SCLINIC\jdecker
|
||||
Scott Aikin
|
||||
Scott Feeney
|
||||
Scott Goodhew
|
||||
Seb35
|
||||
Sebastian Wilzbach
|
||||
Sebastian Zaha
|
||||
Seren D
|
||||
Sergey Goder
|
||||
Sergey Tselovalnikov
|
||||
Se-Won Kim
|
||||
Shane Liesegang
|
||||
shaund
|
||||
shaun gilchrist
|
||||
Shawn A
|
||||
Shea Bunge
|
||||
sheopory
|
||||
Shil S
|
||||
Shiv Deepak
|
||||
Shmuel Englard
|
||||
Shubham Jain
|
||||
Siamak Mokhtari
|
||||
silverwind
|
||||
Simon Edwards
|
||||
sinkuu
|
||||
snasa
|
||||
soliton4
|
||||
sonson
|
||||
Sorab Bisht
|
||||
spastorelli
|
||||
srajanpaliwal
|
||||
Stanislav Oaserele
|
||||
stan-z
|
||||
Stas Kobzar
|
||||
Stefan Borsje
|
||||
Steffen Beyer
|
||||
Steffen Bruchmann
|
||||
Steffen Kowalski
|
||||
Stephane Moore
|
||||
Stephen Lavelle
|
||||
Steve Champagne
|
||||
Steve Hoover
|
||||
Steve O'Hara
|
||||
stockiNail
|
||||
stoskov
|
||||
Stryder Crown
|
||||
Stu Kennedy
|
||||
Sungho Kim
|
||||
sverweij
|
||||
Taha Jahangir
|
||||
takamori
|
||||
Tako Schotanus
|
||||
Takuji Shimokawa
|
||||
Takuya Matsuyama
|
||||
Tarmil
|
||||
T. Brandon Ashley
|
||||
TDaglis
|
||||
Teja
|
||||
tel
|
||||
Tentone
|
||||
tfjgeorge
|
||||
Thaddee Tyl
|
||||
thanasis
|
||||
TheHowl
|
||||
themrmax
|
||||
think
|
||||
Thomas Brouard
|
||||
Thomas Dvornik
|
||||
Thomas Kluyver
|
||||
thomasmaclean
|
||||
Thomas Schmid
|
||||
Tim Alby
|
||||
Tim Baumann
|
||||
Timothy Farrell
|
||||
Timothy Gu
|
||||
Timothy Hatcher
|
||||
Tobias Bertelsen
|
||||
TobiasBg
|
||||
Todd Berman
|
||||
Todd Kennedy
|
||||
Tomas-A
|
||||
Tomas Varaneckas
|
||||
Tom Erik Støwer
|
||||
Tom Klancer
|
||||
Tom MacWright
|
||||
Tom McLaughlin
|
||||
Tony Jian
|
||||
tophf
|
||||
Torgeir Thoresen
|
||||
totalamd
|
||||
Travis Heppe
|
||||
Triangle717
|
||||
Tristan Tarrant
|
||||
TSUYUSATO Kitsune
|
||||
Tugrul Elmas
|
||||
twifkak
|
||||
Tyler Long
|
||||
Tyler Makaro
|
||||
Vadim Dyachenko
|
||||
Vadzim Ramanenka
|
||||
Vaibhav Sagar
|
||||
VapidWorx
|
||||
Vestimir Markov
|
||||
vf
|
||||
Victor Bocharsky
|
||||
Vincent Woo
|
||||
Volker Mische
|
||||
vtripolitakis
|
||||
wdouglashall
|
||||
Weiyan Shao
|
||||
wenli
|
||||
Wes Cossick
|
||||
Wesley Wiser
|
||||
Weston Ruter
|
||||
Will Binns-Smith
|
||||
Will Dean
|
||||
William Desportes
|
||||
William Jamieson
|
||||
William Stein
|
||||
Willy
|
||||
Wojtek Ptak
|
||||
wonderboyjon
|
||||
Wu Cheng-Han
|
||||
Xavier Mendez
|
||||
Yang Guo
|
||||
Yassin N. Hassan
|
||||
YNH Webdev
|
||||
yoongu
|
||||
Yunchi Luo
|
||||
Yuvi Panda
|
||||
Yvonnick Esnault
|
||||
Zac Anger
|
||||
Zachary Dremann
|
||||
Zeno Rocha
|
||||
Zhang Hao
|
||||
Ziv
|
||||
zoobestik
|
||||
zziuni
|
||||
魏鹏刚
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,23 +1,23 @@
|
|||
# How to contribute
|
||||
|
||||
- [Getting help](#getting-help-)
|
||||
- [Submitting bug reports](#submitting-bug-reports-)
|
||||
- [Contributing code](#contributing-code-)
|
||||
- [Getting help](#getting-help)
|
||||
- [Submitting bug reports](#submitting-bug-reports)
|
||||
- [Contributing code](#contributing-code)
|
||||
|
||||
## Getting help
|
||||
|
||||
Community discussion, questions, and informal bug reporting is done on the
|
||||
[CodeMirror Google group](http://groups.google.com/group/codemirror).
|
||||
[discuss.CodeMirror forum](http://discuss.codemirror.net).
|
||||
|
||||
## Submitting bug reports
|
||||
|
||||
The preferred way to report bugs is to use the
|
||||
[GitHub issue tracker](http://github.com/marijnh/CodeMirror/issues). Before
|
||||
[GitHub issue tracker](http://github.com/codemirror/CodeMirror/issues). Before
|
||||
reporting a bug, read these pointers.
|
||||
|
||||
**Note:** The issue tracker is for *bugs*, not requests for help. Questions
|
||||
should be asked on the
|
||||
[CodeMirror Google group](http://groups.google.com/group/codemirror) instead.
|
||||
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead.
|
||||
|
||||
### Reporting bugs effectively
|
||||
|
||||
|
|
@ -47,8 +47,12 @@ should be asked on the
|
|||
|
||||
## Contributing code
|
||||
|
||||
Note that we are not accepting any new addons or modes into the main
|
||||
distribution. If you've written such a module, please distribute it as
|
||||
a separate NPM package.
|
||||
|
||||
- Make sure you have a [GitHub Account](https://github.com/signup/free)
|
||||
- Fork [CodeMirror](https://github.com/marijnh/CodeMirror/)
|
||||
- Fork [CodeMirror](https://github.com/codemirror/CodeMirror/)
|
||||
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
|
||||
- Make your changes
|
||||
- If your changes are easy to test or likely to regress, add tests.
|
||||
|
|
@ -61,12 +65,24 @@ should be asked on the
|
|||
- Make sure all tests pass. Visit `test/index.html` in your browser to
|
||||
run them.
|
||||
- Submit a pull request
|
||||
([how to create a pull request](https://help.github.com/articles/fork-a-repo))
|
||||
([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
|
||||
Don't put more than one feature/fix in a single pull request.
|
||||
|
||||
By contributing code to CodeMirror you
|
||||
|
||||
- agree to license the contributed code under CodeMirror's [MIT
|
||||
license](https://codemirror.net/LICENSE).
|
||||
|
||||
- confirm that you have the right to contribute and license the code
|
||||
in question. (Either you hold all rights on the code, or the rights
|
||||
holder has explicitly granted the right to use it like this,
|
||||
through a compatible open source license or through a direct
|
||||
agreement with you.)
|
||||
|
||||
### Coding standards
|
||||
|
||||
- 2 spaces per indentation level, no tabs.
|
||||
- Include semicolons after statements.
|
||||
|
||||
- Note that the linter (`bin/lint`) which is run after each commit
|
||||
complains about unused variables and functions. Prefix their names
|
||||
with an underscore to muffle it.
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# CodeMirror
|
||||
|
||||
[](https://travis-ci.org/codemirror/CodeMirror)
|
||||
[](https://www.npmjs.org/package/codemirror)
|
||||
[](https://gitter.im/codemirror/CodeMirror)
|
||||
|
||||
CodeMirror is a versatile text editor implemented in JavaScript for
|
||||
the browser. It is specialized for editing code, and comes with over
|
||||
100 language modes and various addons that implement more advanced
|
||||
editing functionality. Every language comes with fully-featured code
|
||||
and syntax highlighting to help with reading and editing complex code.
|
||||
|
||||
A rich programming API and a CSS theming system are available for
|
||||
customizing CodeMirror to fit your application, and extending it with
|
||||
new functionality.
|
||||
|
||||
You can find more information (and the
|
||||
[manual](https://codemirror.net/doc/manual.html)) on the [project
|
||||
page](https://codemirror.net). For questions and discussion, use the
|
||||
[discussion forum](https://discuss.codemirror.net/).
|
||||
|
||||
See
|
||||
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
|
||||
for contributing guidelines.
|
||||
|
||||
The CodeMirror community aims to be welcoming to everybody. We use the
|
||||
[Contributor Covenant
|
||||
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
|
||||
conduct.
|
||||
|
||||
### Installation
|
||||
|
||||
Either get the [zip file](https://codemirror.net/codemirror.zip) with
|
||||
the latest version, or make sure you have [Node](https://nodejs.org/)
|
||||
installed and run:
|
||||
|
||||
npm install codemirror
|
||||
|
||||
**NOTE**: This is the source repository for the library, and not the
|
||||
distribution channel. Cloning it is not the recommended way to install
|
||||
the library, and will in fact not work unless you also run the build
|
||||
step.
|
||||
|
||||
### Quickstart
|
||||
|
||||
To build the project, make sure you have Node.js installed (at least version 6)
|
||||
and then `npm install`. To run, just open `index.html` in your
|
||||
browser (you don't need to run a webserver). Run the tests with `npm test`.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
|
|
@ -21,26 +21,45 @@
|
|||
}
|
||||
|
||||
CodeMirror.commands.toggleComment = function(cm) {
|
||||
var minLine = Infinity, ranges = cm.listSelections(), mode = null;
|
||||
cm.toggleComment();
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("toggleComment", function(options) {
|
||||
if (!options) options = noOptions;
|
||||
var cm = this;
|
||||
var minLine = Infinity, ranges = this.listSelections(), mode = null;
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var from = ranges[i].from(), to = ranges[i].to();
|
||||
if (from.line >= minLine) continue;
|
||||
if (to.line >= minLine) to = Pos(minLine, 0);
|
||||
minLine = from.line;
|
||||
if (mode == null) {
|
||||
if (cm.uncomment(from, to)) mode = "un";
|
||||
else { cm.lineComment(from, to); mode = "line"; }
|
||||
if (cm.uncomment(from, to, options)) mode = "un";
|
||||
else { cm.lineComment(from, to, options); mode = "line"; }
|
||||
} else if (mode == "un") {
|
||||
cm.uncomment(from, to);
|
||||
cm.uncomment(from, to, options);
|
||||
} else {
|
||||
cm.lineComment(from, to);
|
||||
cm.lineComment(from, to, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// Rough heuristic to try and detect lines that are part of multi-line string
|
||||
function probablyInsideString(cm, pos, line) {
|
||||
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
|
||||
}
|
||||
|
||||
function getMode(cm, pos) {
|
||||
var mode = cm.getMode()
|
||||
return mode.useInnerComments === false || !mode.innerMode ? mode : cm.getModeAt(pos)
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("lineComment", function(from, to, options) {
|
||||
if (!options) options = noOptions;
|
||||
var self = this, mode = self.getModeAt(from);
|
||||
var self = this, mode = getMode(self, from);
|
||||
var firstLine = self.getLine(from.line);
|
||||
if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
|
||||
|
||||
var commentString = options.lineComment || mode.lineComment;
|
||||
if (!commentString) {
|
||||
if (options.blockCommentStart || mode.blockCommentStart) {
|
||||
|
|
@ -49,15 +68,21 @@
|
|||
}
|
||||
return;
|
||||
}
|
||||
var firstLine = self.getLine(from.line);
|
||||
if (firstLine == null) return;
|
||||
|
||||
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
|
||||
var pad = options.padding == null ? " " : options.padding;
|
||||
var blankLines = options.commentBlankLines || from.line == to.line;
|
||||
|
||||
self.operation(function() {
|
||||
if (options.indent) {
|
||||
var baseString = firstLine.slice(0, firstNonWS(firstLine));
|
||||
var baseString = null;
|
||||
for (var i = from.line; i < end; ++i) {
|
||||
var line = self.getLine(i);
|
||||
var whitespace = line.slice(0, firstNonWS(line));
|
||||
if (baseString == null || baseString.length > whitespace.length) {
|
||||
baseString = whitespace;
|
||||
}
|
||||
}
|
||||
for (var i = from.line; i < end; ++i) {
|
||||
var line = self.getLine(i), cut = baseString.length;
|
||||
if (!blankLines && !nonWS.test(line)) continue;
|
||||
|
|
@ -75,7 +100,7 @@
|
|||
|
||||
CodeMirror.defineExtension("blockComment", function(from, to, options) {
|
||||
if (!options) options = noOptions;
|
||||
var self = this, mode = self.getModeAt(from);
|
||||
var self = this, mode = getMode(self, from);
|
||||
var startString = options.blockCommentStart || mode.blockCommentStart;
|
||||
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
||||
if (!startString || !endString) {
|
||||
|
|
@ -83,6 +108,7 @@
|
|||
self.lineComment(from, to, options);
|
||||
return;
|
||||
}
|
||||
if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
|
||||
|
||||
var end = Math.min(to.line, self.lastLine());
|
||||
if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
|
||||
|
|
@ -108,8 +134,8 @@
|
|||
|
||||
CodeMirror.defineExtension("uncomment", function(from, to, options) {
|
||||
if (!options) options = noOptions;
|
||||
var self = this, mode = self.getModeAt(from);
|
||||
var end = Math.min(to.line, self.lastLine()), start = Math.min(from.line, end);
|
||||
var self = this, mode = getMode(self, from);
|
||||
var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
|
||||
|
||||
// Try finding line comments
|
||||
var lineString = options.lineComment || mode.lineComment, lines = [];
|
||||
|
|
@ -120,7 +146,7 @@
|
|||
var line = self.getLine(i);
|
||||
var found = line.indexOf(lineString);
|
||||
if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
|
||||
if (found == -1 && (i != end || i == start) && nonWS.test(line)) break lineComment;
|
||||
if (found == -1 && nonWS.test(line)) break lineComment;
|
||||
if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
|
||||
lines.push(line);
|
||||
}
|
||||
|
|
@ -142,15 +168,15 @@
|
|||
var endString = options.blockCommentEnd || mode.blockCommentEnd;
|
||||
if (!startString || !endString) return false;
|
||||
var lead = options.blockCommentLead || mode.blockCommentLead;
|
||||
var startLine = self.getLine(start), endLine = end == start ? startLine : self.getLine(end);
|
||||
var open = startLine.indexOf(startString), close = endLine.lastIndexOf(endString);
|
||||
if (close == -1 && start != end) {
|
||||
endLine = self.getLine(--end);
|
||||
close = endLine.lastIndexOf(endString);
|
||||
}
|
||||
if (open == -1 || close == -1 ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
|
||||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
|
||||
var startLine = self.getLine(start), open = startLine.indexOf(startString)
|
||||
if (open == -1) return false
|
||||
var endLine = end == start ? startLine : self.getLine(end)
|
||||
var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
|
||||
var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
|
||||
if (close == -1 ||
|
||||
!/comment/.test(self.getTokenTypeAt(insideStart)) ||
|
||||
!/comment/.test(self.getTokenTypeAt(insideEnd)) ||
|
||||
self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
|
||||
return false;
|
||||
|
||||
// Avoid killing block comments completely outside the selection.
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var nonspace = /\S/g;
|
||||
var repeat = String.prototype.repeat || function (n) { return Array(n + 1).join(this); };
|
||||
function continueComment(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), mode, inserts = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head
|
||||
if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass;
|
||||
var modeHere = cm.getModeAt(pos)
|
||||
if (!mode) mode = modeHere;
|
||||
else if (mode != modeHere) return CodeMirror.Pass;
|
||||
|
||||
var insert = null, line, found;
|
||||
var blockStart = mode.blockCommentStart, lineCmt = mode.lineComment;
|
||||
if (blockStart && mode.blockCommentContinue) {
|
||||
line = cm.getLine(pos.line);
|
||||
var end = line.lastIndexOf(mode.blockCommentEnd, pos.ch - mode.blockCommentEnd.length);
|
||||
// 1. if this block comment ended
|
||||
// 2. if this is actually inside a line comment
|
||||
if (end != -1 && end == pos.ch - mode.blockCommentEnd.length ||
|
||||
lineCmt && (found = line.lastIndexOf(lineCmt, pos.ch - 1)) > -1 &&
|
||||
/\bcomment\b/.test(cm.getTokenTypeAt({line: pos.line, ch: found + 1}))) {
|
||||
// ...then don't continue it
|
||||
} else if (pos.ch >= blockStart.length &&
|
||||
(found = line.lastIndexOf(blockStart, pos.ch - blockStart.length)) > -1 &&
|
||||
found > end) {
|
||||
// reuse the existing leading spaces/tabs/mixed
|
||||
// or build the correct indent using CM's tab/indent options
|
||||
if (nonspaceAfter(0, line) >= found) {
|
||||
insert = line.slice(0, found);
|
||||
} else {
|
||||
var tabSize = cm.options.tabSize, numTabs;
|
||||
found = CodeMirror.countColumn(line, found, tabSize);
|
||||
insert = !cm.options.indentWithTabs ? repeat.call(" ", found) :
|
||||
repeat.call("\t", (numTabs = Math.floor(found / tabSize))) +
|
||||
repeat.call(" ", found - tabSize * numTabs);
|
||||
}
|
||||
} else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 &&
|
||||
found <= pos.ch &&
|
||||
found <= nonspaceAfter(0, line)) {
|
||||
insert = line.slice(0, found);
|
||||
}
|
||||
if (insert != null) insert += mode.blockCommentContinue
|
||||
}
|
||||
if (insert == null && lineCmt && continueLineCommentEnabled(cm)) {
|
||||
if (line == null) line = cm.getLine(pos.line);
|
||||
found = line.indexOf(lineCmt);
|
||||
// cursor at pos 0, line comment also at pos 0 => shift it down, don't continue
|
||||
if (!pos.ch && !found) insert = "";
|
||||
// continue only if the line starts with an optional space + line comment
|
||||
else if (found > -1 && nonspaceAfter(0, line) >= found) {
|
||||
// don't continue if there's only space(s) after cursor or the end of the line
|
||||
insert = nonspaceAfter(pos.ch, line) > -1;
|
||||
// but always continue if the next line starts with a line comment too
|
||||
if (!insert) {
|
||||
var next = cm.getLine(pos.line + 1) || '',
|
||||
nextFound = next.indexOf(lineCmt);
|
||||
insert = nextFound > -1 && nonspaceAfter(0, next) >= nextFound || null;
|
||||
}
|
||||
if (insert) {
|
||||
insert = line.slice(0, found) + lineCmt +
|
||||
line.slice(found + lineCmt.length).match(/^\s*/)[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (insert == null) return CodeMirror.Pass;
|
||||
inserts[i] = "\n" + insert;
|
||||
}
|
||||
|
||||
cm.operation(function() {
|
||||
for (var i = ranges.length - 1; i >= 0; i--)
|
||||
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
|
||||
});
|
||||
}
|
||||
|
||||
function nonspaceAfter(ch, str) {
|
||||
nonspace.lastIndex = ch;
|
||||
var m = nonspace.exec(str);
|
||||
return m ? m.index : -1;
|
||||
}
|
||||
|
||||
function continueLineCommentEnabled(cm) {
|
||||
var opt = cm.getOption("continueComments");
|
||||
if (opt && typeof opt == "object")
|
||||
return opt.continueLineComment !== false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
|
||||
if (prev && prev != CodeMirror.Init)
|
||||
cm.removeKeyMap("continueComment");
|
||||
if (val) {
|
||||
var key = "Enter";
|
||||
if (typeof val == "string")
|
||||
key = val;
|
||||
else if (typeof val == "object" && val.key)
|
||||
key = val.key;
|
||||
var map = {name: "continueComment"};
|
||||
map[key] = continueComment;
|
||||
cm.addKeyMap(map);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
.CodeMirror-dialog {
|
||||
position: absolute;
|
||||
left: 0; right: 0;
|
||||
background: white;
|
||||
background: inherit;
|
||||
z-index: 15;
|
||||
padding: .1em .8em;
|
||||
overflow: hidden;
|
||||
color: #333;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog-top {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
// Open simple dialogs on top of an editor. Relies on dialog.css.
|
||||
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
} else { // Assuming it's a detached DOM element.
|
||||
dialog.appendChild(template);
|
||||
}
|
||||
CodeMirror.addClass(wrap, 'dialog-opened');
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +48,7 @@
|
|||
} else {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
me.focus();
|
||||
|
||||
|
|
@ -56,7 +58,14 @@
|
|||
|
||||
var inp = dialog.getElementsByTagName("input")[0], button;
|
||||
if (inp) {
|
||||
if (options.value) inp.value = options.value;
|
||||
inp.focus();
|
||||
|
||||
if (options.value) {
|
||||
inp.value = options.value;
|
||||
if (options.selectValueOnOpen !== false) {
|
||||
inp.select();
|
||||
}
|
||||
}
|
||||
|
||||
if (options.onInput)
|
||||
CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);});
|
||||
|
|
@ -70,12 +79,10 @@
|
|||
CodeMirror.e_stop(e);
|
||||
close();
|
||||
}
|
||||
if (e.keyCode == 13) callback(inp.value);
|
||||
if (e.keyCode == 13) callback(inp.value, e);
|
||||
});
|
||||
|
||||
if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
|
||||
|
||||
inp.focus();
|
||||
} else if (button = dialog.getElementsByTagName("button")[0]) {
|
||||
CodeMirror.on(button, "click", function() {
|
||||
close();
|
||||
|
|
@ -97,6 +104,7 @@
|
|||
function close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
me.focus();
|
||||
}
|
||||
|
|
@ -136,6 +144,7 @@
|
|||
if (closed) return;
|
||||
closed = true;
|
||||
clearTimeout(doneTimer);
|
||||
CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"))
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod)
|
||||
else // Plain browser env
|
||||
mod(CodeMirror)
|
||||
})(function(CodeMirror) {
|
||||
"use strict"
|
||||
|
||||
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
|
||||
if (cm.state.autoRefresh) {
|
||||
stopListening(cm, cm.state.autoRefresh)
|
||||
cm.state.autoRefresh = null
|
||||
}
|
||||
if (val && cm.display.wrapper.offsetHeight == 0)
|
||||
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
|
||||
})
|
||||
|
||||
function startListening(cm, state) {
|
||||
function check() {
|
||||
if (cm.display.wrapper.offsetHeight) {
|
||||
stopListening(cm, state)
|
||||
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
|
||||
cm.refresh()
|
||||
} else {
|
||||
state.timeout = setTimeout(check, state.delay)
|
||||
}
|
||||
}
|
||||
state.timeout = setTimeout(check, state.delay)
|
||||
state.hurry = function() {
|
||||
clearTimeout(state.timeout)
|
||||
state.timeout = setTimeout(check, 50)
|
||||
}
|
||||
CodeMirror.on(window, "mouseup", state.hurry)
|
||||
CodeMirror.on(window, "keyup", state.hurry)
|
||||
}
|
||||
|
||||
function stopListening(_cm, state) {
|
||||
clearTimeout(state.timeout)
|
||||
CodeMirror.off(window, "mouseup", state.hurry)
|
||||
CodeMirror.off(window, "keyup", state.hurry)
|
||||
}
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function (CodeMirror) {
|
||||
CodeMirror.defineExtension("addPanel", function (node, options) {
|
||||
options = options || {};
|
||||
|
||||
if (!this.state.panels) initPanels(this);
|
||||
|
||||
var info = this.state.panels;
|
||||
var wrapper = info.wrapper;
|
||||
var cmWrapper = this.getWrapperElement();
|
||||
var replace = options.replace instanceof Panel && !options.replace.cleared;
|
||||
|
||||
if (options.after instanceof Panel && !options.after.cleared) {
|
||||
wrapper.insertBefore(node, options.before.node.nextSibling);
|
||||
} else if (options.before instanceof Panel && !options.before.cleared) {
|
||||
wrapper.insertBefore(node, options.before.node);
|
||||
} else if (replace) {
|
||||
wrapper.insertBefore(node, options.replace.node);
|
||||
options.replace.clear(true);
|
||||
} else if (options.position == "bottom") {
|
||||
wrapper.appendChild(node);
|
||||
} else if (options.position == "before-bottom") {
|
||||
wrapper.insertBefore(node, cmWrapper.nextSibling);
|
||||
} else if (options.position == "after-top") {
|
||||
wrapper.insertBefore(node, cmWrapper);
|
||||
} else {
|
||||
wrapper.insertBefore(node, wrapper.firstChild);
|
||||
}
|
||||
|
||||
var height = (options && options.height) || node.offsetHeight;
|
||||
|
||||
var panel = new Panel(this, node, options, height);
|
||||
info.panels.push(panel);
|
||||
|
||||
this.setSize();
|
||||
if (options.stable && isAtTop(this, node))
|
||||
this.scrollTo(null, this.getScrollInfo().top + height);
|
||||
|
||||
return panel;
|
||||
});
|
||||
|
||||
function Panel(cm, node, options, height) {
|
||||
this.cm = cm;
|
||||
this.node = node;
|
||||
this.options = options;
|
||||
this.height = height;
|
||||
this.cleared = false;
|
||||
}
|
||||
|
||||
/* when skipRemove is true, clear() was called from addPanel().
|
||||
* Thus removePanels() should not be called (issue 5518) */
|
||||
Panel.prototype.clear = function (skipRemove) {
|
||||
if (this.cleared) return;
|
||||
this.cleared = true;
|
||||
var info = this.cm.state.panels;
|
||||
info.panels.splice(info.panels.indexOf(this), 1);
|
||||
this.cm.setSize();
|
||||
if (this.options.stable && isAtTop(this.cm, this.node))
|
||||
this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height)
|
||||
info.wrapper.removeChild(this.node);
|
||||
if (info.panels.length == 0 && !skipRemove) removePanels(this.cm);
|
||||
};
|
||||
|
||||
Panel.prototype.changed = function () {
|
||||
this.height = this.node.getBoundingClientRect().height;
|
||||
this.cm.setSize();
|
||||
};
|
||||
|
||||
function initPanels(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
|
||||
var height = parseInt(style.height);
|
||||
var info = cm.state.panels = {
|
||||
setHeight: wrap.style.height,
|
||||
panels: [],
|
||||
wrapper: document.createElement("div")
|
||||
};
|
||||
wrap.parentNode.insertBefore(info.wrapper, wrap);
|
||||
var hasFocus = cm.hasFocus();
|
||||
info.wrapper.appendChild(wrap);
|
||||
if (hasFocus) cm.focus();
|
||||
|
||||
cm._setSize = cm.setSize;
|
||||
if (height != null) cm.setSize = function (width, newHeight) {
|
||||
if (!newHeight) newHeight = info.wrapper.offsetHeight;
|
||||
info.setHeight = newHeight;
|
||||
if (typeof newHeight != "number") {
|
||||
var px = /^(\d+\.?\d*)px$/.exec(newHeight);
|
||||
if (px) {
|
||||
newHeight = Number(px[1]);
|
||||
} else {
|
||||
info.wrapper.style.height = newHeight;
|
||||
newHeight = info.wrapper.offsetHeight;
|
||||
}
|
||||
}
|
||||
var editorheight = newHeight - info.panels
|
||||
.map(function (p) { return p.node.getBoundingClientRect().height; })
|
||||
.reduce(function (a, b) { return a + b; }, 0);
|
||||
cm._setSize(width, editorheight);
|
||||
height = newHeight;
|
||||
};
|
||||
}
|
||||
|
||||
function removePanels(cm) {
|
||||
var info = cm.state.panels;
|
||||
cm.state.panels = null;
|
||||
|
||||
var wrap = cm.getWrapperElement();
|
||||
info.wrapper.parentNode.replaceChild(wrap, info.wrapper);
|
||||
wrap.style.height = info.setHeight;
|
||||
cm.setSize = cm._setSize;
|
||||
cm.setSize();
|
||||
}
|
||||
|
||||
function isAtTop(cm, dom) {
|
||||
for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling)
|
||||
if (sibling == cm.getWrapperElement()) return true
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
|
|
@ -14,10 +14,12 @@
|
|||
if (val && !prev) {
|
||||
cm.on("blur", onBlur);
|
||||
cm.on("change", onChange);
|
||||
cm.on("swapDoc", onChange);
|
||||
onChange(cm);
|
||||
} else if (!val && prev) {
|
||||
cm.off("blur", onBlur);
|
||||
cm.off("change", onChange);
|
||||
cm.off("swapDoc", onChange);
|
||||
clearPlaceholder(cm);
|
||||
var wrapper = cm.getWrapperElement();
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
||||
|
|
@ -36,8 +38,11 @@
|
|||
clearPlaceholder(cm);
|
||||
var elt = cm.state.placeholder = document.createElement("pre");
|
||||
elt.style.cssText = "height: 0; overflow: visible";
|
||||
elt.className = "CodeMirror-placeholder";
|
||||
elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
|
||||
elt.style.direction = cm.getOption("direction");
|
||||
elt.className = "CodeMirror-placeholder CodeMirror-line-like";
|
||||
var placeHolder = cm.getOption("placeholder")
|
||||
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
|
||||
elt.appendChild(placeHolder)
|
||||
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
|
|
@ -11,34 +11,30 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("rulers", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
clearRulers(cm);
|
||||
cm.off("refresh", refreshRulers);
|
||||
CodeMirror.defineOption("rulers", false, function(cm, val) {
|
||||
if (cm.state.rulerDiv) {
|
||||
cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv)
|
||||
cm.state.rulerDiv = null
|
||||
cm.off("refresh", drawRulers)
|
||||
}
|
||||
if (val && val.length) {
|
||||
setRulers(cm);
|
||||
cm.on("refresh", refreshRulers);
|
||||
cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace)
|
||||
cm.state.rulerDiv.className = "CodeMirror-rulers"
|
||||
drawRulers(cm)
|
||||
cm.on("refresh", drawRulers)
|
||||
}
|
||||
});
|
||||
|
||||
function clearRulers(cm) {
|
||||
for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
|
||||
var node = cm.display.lineSpace.childNodes[i];
|
||||
if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
function setRulers(cm) {
|
||||
function drawRulers(cm) {
|
||||
cm.state.rulerDiv.textContent = ""
|
||||
var val = cm.getOption("rulers");
|
||||
var cw = cm.defaultCharWidth();
|
||||
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
|
||||
var minH = cm.display.scroller.offsetHeight + 30;
|
||||
cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
var elt = document.createElement("div");
|
||||
elt.className = "CodeMirror-ruler";
|
||||
var col, cls = null, conf = val[i];
|
||||
var col, conf = val[i];
|
||||
if (typeof conf == "number") {
|
||||
col = conf;
|
||||
} else {
|
||||
|
|
@ -47,18 +43,9 @@
|
|||
if (conf.color) elt.style.borderColor = conf.color;
|
||||
if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
|
||||
if (conf.width) elt.style.borderLeftWidth = conf.width;
|
||||
cls = val[i].className;
|
||||
}
|
||||
elt.style.left = (left + col * cw) + "px";
|
||||
elt.style.top = "-50px";
|
||||
elt.style.bottom = "-20px";
|
||||
elt.style.minHeight = minH + "px";
|
||||
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
|
||||
cm.state.rulerDiv.appendChild(elt)
|
||||
}
|
||||
}
|
||||
|
||||
function refreshRulers(cm) {
|
||||
clearRulers(cm);
|
||||
setRulers(cm);
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
var defaults = {
|
||||
pairs: "()[]{}''\"\"",
|
||||
closeBefore: ")]}'\":;>",
|
||||
triples: "",
|
||||
explode: "[]{}"
|
||||
};
|
||||
|
||||
var Pos = CodeMirror.Pos;
|
||||
|
||||
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
|
||||
if (old && old != CodeMirror.Init) {
|
||||
cm.removeKeyMap(keyMap);
|
||||
cm.state.closeBrackets = null;
|
||||
}
|
||||
if (val) {
|
||||
ensureBound(getOption(val, "pairs"))
|
||||
cm.state.closeBrackets = val;
|
||||
cm.addKeyMap(keyMap);
|
||||
}
|
||||
});
|
||||
|
||||
function getOption(conf, name) {
|
||||
if (name == "pairs" && typeof conf == "string") return conf;
|
||||
if (typeof conf == "object" && conf[name] != null) return conf[name];
|
||||
return defaults[name];
|
||||
}
|
||||
|
||||
var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
|
||||
function ensureBound(chars) {
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
var ch = chars.charAt(i), key = "'" + ch + "'"
|
||||
if (!keyMap[key]) keyMap[key] = handler(ch)
|
||||
}
|
||||
}
|
||||
ensureBound(defaults.pairs + "`")
|
||||
|
||||
function handler(ch) {
|
||||
return function(cm) { return handleChar(cm, ch); };
|
||||
}
|
||||
|
||||
function getConfig(cm) {
|
||||
var deflt = cm.state.closeBrackets;
|
||||
if (!deflt || deflt.override) return deflt;
|
||||
var mode = cm.getModeAt(cm.getCursor());
|
||||
return mode.closeBrackets || deflt;
|
||||
}
|
||||
|
||||
function handleBackspace(cm) {
|
||||
var conf = getConfig(cm);
|
||||
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var pairs = getOption(conf, "pairs");
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var cur = ranges[i].head;
|
||||
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
|
||||
}
|
||||
}
|
||||
|
||||
function handleEnter(cm) {
|
||||
var conf = getConfig(cm);
|
||||
var explode = conf && getOption(conf, "explode");
|
||||
if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var around = charsAround(cm, ranges[i].head);
|
||||
if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
|
||||
}
|
||||
cm.operation(function() {
|
||||
var linesep = cm.lineSeparator() || "\n";
|
||||
cm.replaceSelection(linesep + linesep, null);
|
||||
cm.execCommand("goCharLeft");
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var line = ranges[i].head.line;
|
||||
cm.indentLine(line, null, true);
|
||||
cm.indentLine(line + 1, null, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function contractSelection(sel) {
|
||||
var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
|
||||
return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
|
||||
head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
|
||||
}
|
||||
|
||||
function handleChar(cm, ch) {
|
||||
var conf = getConfig(cm);
|
||||
if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
|
||||
var pairs = getOption(conf, "pairs");
|
||||
var pos = pairs.indexOf(ch);
|
||||
if (pos == -1) return CodeMirror.Pass;
|
||||
|
||||
var closeBefore = getOption(conf,"closeBefore");
|
||||
|
||||
var triples = getOption(conf, "triples");
|
||||
|
||||
var identical = pairs.charAt(pos + 1) == ch;
|
||||
var ranges = cm.listSelections();
|
||||
var opening = pos % 2 == 0;
|
||||
|
||||
var type;
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i], cur = range.head, curType;
|
||||
var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
|
||||
if (opening && !range.empty()) {
|
||||
curType = "surround";
|
||||
} else if ((identical || !opening) && next == ch) {
|
||||
if (identical && stringStartsAfter(cm, cur))
|
||||
curType = "both";
|
||||
else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
|
||||
curType = "skipThree";
|
||||
else
|
||||
curType = "skip";
|
||||
} else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
|
||||
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) {
|
||||
if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass;
|
||||
curType = "addFour";
|
||||
} else if (identical) {
|
||||
var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
|
||||
if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
|
||||
else return CodeMirror.Pass;
|
||||
} else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) {
|
||||
curType = "both";
|
||||
} else {
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
if (!type) type = curType;
|
||||
else if (type != curType) return CodeMirror.Pass;
|
||||
}
|
||||
|
||||
var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
|
||||
var right = pos % 2 ? ch : pairs.charAt(pos + 1);
|
||||
cm.operation(function() {
|
||||
if (type == "skip") {
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "skipThree") {
|
||||
for (var i = 0; i < 3; i++)
|
||||
cm.execCommand("goCharRight");
|
||||
} else if (type == "surround") {
|
||||
var sels = cm.getSelections();
|
||||
for (var i = 0; i < sels.length; i++)
|
||||
sels[i] = left + sels[i] + right;
|
||||
cm.replaceSelections(sels, "around");
|
||||
sels = cm.listSelections().slice();
|
||||
for (var i = 0; i < sels.length; i++)
|
||||
sels[i] = contractSelection(sels[i]);
|
||||
cm.setSelections(sels);
|
||||
} else if (type == "both") {
|
||||
cm.replaceSelection(left + right, null);
|
||||
cm.triggerElectric(left + right);
|
||||
cm.execCommand("goCharLeft");
|
||||
} else if (type == "addFour") {
|
||||
cm.replaceSelection(left + left + left + left, "before");
|
||||
cm.execCommand("goCharRight");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function charsAround(cm, pos) {
|
||||
var str = cm.getRange(Pos(pos.line, pos.ch - 1),
|
||||
Pos(pos.line, pos.ch + 1));
|
||||
return str.length == 2 ? str : null;
|
||||
}
|
||||
|
||||
function stringStartsAfter(cm, pos) {
|
||||
var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
|
||||
return /\bstring/.test(token.type) && token.start == pos.ch &&
|
||||
(pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos)))
|
||||
}
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
/**
|
||||
* Tag-closer extension for CodeMirror.
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
* An array of tag names that should, when opened, cause a
|
||||
* blank line to be added inside the tag, and the blank line and
|
||||
* closing line to be indented.
|
||||
* `emptyTags` (default is none)
|
||||
* An array of XML tag names that should be autoclosed with '/>'.
|
||||
*
|
||||
* See demos/closetag.html for a usage example.
|
||||
*/
|
||||
|
|
@ -53,82 +55,102 @@
|
|||
function autoCloseGT(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
var opt = cm.getOption("autoCloseTags");
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
||||
if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;
|
||||
var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state)
|
||||
var tagName = tagInfo && tagInfo.name
|
||||
if (!tagName) return CodeMirror.Pass
|
||||
|
||||
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
|
||||
var html = inner.mode.configuration == "html";
|
||||
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
|
||||
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
|
||||
|
||||
var tagName = state.tagName;
|
||||
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
|
||||
var lowerTagName = tagName.toLowerCase();
|
||||
// Don't process the '>' at the end of an end-tag or self-closing tag
|
||||
if (!tagName ||
|
||||
tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
|
||||
tok.type == "tag" && state.type == "closeTag" ||
|
||||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
|
||||
tok.type == "tag" && tagInfo.close ||
|
||||
tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like <someTagName />
|
||||
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
|
||||
closingTagExists(cm, tagName, pos, state, true))
|
||||
closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true))
|
||||
return CodeMirror.Pass;
|
||||
|
||||
var emptyTags = typeof opt == "object" && opt.emptyTags;
|
||||
if (emptyTags && indexOf(emptyTags, tagName) > -1) {
|
||||
replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) };
|
||||
continue;
|
||||
}
|
||||
|
||||
var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
|
||||
replacements[i] = {indent: indent,
|
||||
text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
|
||||
newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
|
||||
}
|
||||
|
||||
var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose);
|
||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||
var info = replacements[i];
|
||||
cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
|
||||
var sel = cm.listSelections().slice(0);
|
||||
sel[i] = {head: info.newPos, anchor: info.newPos};
|
||||
cm.setSelections(sel);
|
||||
if (info.indent) {
|
||||
if (!dontIndentOnAutoClose && info.indent) {
|
||||
cm.indentLine(info.newPos.line, null, true);
|
||||
cm.indentLine(info.newPos.line + 1, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function autoCloseSlash(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
function autoCloseCurrent(cm, typingSlash) {
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
var head = typingSlash ? "/" : "</";
|
||||
var opt = cm.getOption("autoCloseTags");
|
||||
var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnSlash);
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (!ranges[i].empty()) return CodeMirror.Pass;
|
||||
var pos = ranges[i].head, tok = cm.getTokenAt(pos);
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
||||
if (tok.type == "string" || tok.string.charAt(0) != "<" ||
|
||||
tok.start != pos.ch - 1)
|
||||
if (typingSlash && (tok.type == "string" || tok.string.charAt(0) != "<" ||
|
||||
tok.start != pos.ch - 1))
|
||||
return CodeMirror.Pass;
|
||||
// Kludge to get around the fact that we are not in XML mode
|
||||
// when completing in JS/CSS snippet in htmlmixed mode. Does not
|
||||
// work for other XML embedded languages (there is no general
|
||||
// way to go from a mixed mode to its current XML state).
|
||||
if (inner.mode.name != "xml") {
|
||||
if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
|
||||
replacements[i] = "/script>";
|
||||
else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
|
||||
replacements[i] = "/style>";
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
var replacement, mixed = inner.mode.name != "xml" && cm.getMode().name == "htmlmixed"
|
||||
if (mixed && inner.mode.name == "javascript") {
|
||||
replacement = head + "script";
|
||||
} else if (mixed && inner.mode.name == "css") {
|
||||
replacement = head + "style";
|
||||
} else {
|
||||
if (!state.context || !state.context.tagName ||
|
||||
closingTagExists(cm, state.context.tagName, pos, state))
|
||||
var context = inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state)
|
||||
if (!context || (context.length && closingTagExists(cm, context, context[context.length - 1], pos)))
|
||||
return CodeMirror.Pass;
|
||||
replacements[i] = "/" + state.context.tagName + ">";
|
||||
replacement = head + context[context.length - 1]
|
||||
}
|
||||
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
|
||||
replacements[i] = replacement;
|
||||
}
|
||||
cm.replaceSelections(replacements);
|
||||
ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++)
|
||||
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
|
||||
cm.indentLine(ranges[i].head.line);
|
||||
if (!dontIndentOnAutoClose) {
|
||||
for (var i = 0; i < ranges.length; i++)
|
||||
if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
|
||||
cm.indentLine(ranges[i].head.line);
|
||||
}
|
||||
}
|
||||
|
||||
function autoCloseSlash(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
return autoCloseCurrent(cm, true);
|
||||
}
|
||||
|
||||
CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
|
||||
|
||||
function indexOf(collection, elt) {
|
||||
if (collection.indexOf) return collection.indexOf(elt);
|
||||
for (var i = 0, e = collection.length; i < e; ++i)
|
||||
|
|
@ -138,16 +160,19 @@
|
|||
|
||||
// If xml-fold is loaded, we use its functionality to try and verify
|
||||
// whether a given tag is actually unclosed.
|
||||
function closingTagExists(cm, tagName, pos, state, newTag) {
|
||||
function closingTagExists(cm, context, tagName, pos, newTag) {
|
||||
if (!CodeMirror.scanForClosingTag) return false;
|
||||
var end = Math.min(cm.lastLine() + 1, pos.line + 500);
|
||||
var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
||||
if (!nextClose || nextClose.tag != tagName) return false;
|
||||
var cx = state.context;
|
||||
// If the immediate wrapping context contains onCx instances of
|
||||
// the same tag, a closing tag only exists if there are at least
|
||||
// that many closing tags of that type following.
|
||||
for (var onCx = newTag ? 1 : 0; cx && cx.tagName == tagName; cx = cx.prev) ++onCx;
|
||||
var onCx = newTag ? 1 : 0
|
||||
for (var i = context.length - 1; i >= 0; i--) {
|
||||
if (context[i] == tagName) ++onCx
|
||||
else break
|
||||
}
|
||||
pos = nextClose.to;
|
||||
for (var i = 1; i < onCx; i++) {
|
||||
var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
unorderedListRE = /[*+-]\s/;
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head;
|
||||
|
||||
// If we're not in Markdown mode, fall back to normal newlineAndIndent
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), eolState);
|
||||
if (inner.mode.name !== "markdown") {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
} else {
|
||||
eolState = inner.state;
|
||||
}
|
||||
|
||||
var inList = eolState.list !== false;
|
||||
var inQuote = eolState.quote !== 0;
|
||||
|
||||
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
||||
var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch));
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
if (emptyListRE.test(line)) {
|
||||
var endOfQuote = inQuote && />\s*$/.test(line)
|
||||
var endOfList = !/>\s*$/.test(line)
|
||||
if (endOfQuote || endOfList) cm.replaceRange("", {
|
||||
line: pos.line, ch: 0
|
||||
}, {
|
||||
line: pos.line, ch: pos.ch + 1
|
||||
});
|
||||
replacements[i] = "\n";
|
||||
} else {
|
||||
var indent = match[1], after = match[5];
|
||||
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
|
||||
var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " ");
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
|
||||
if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
|
||||
// Auto-updating Markdown list numbers when a new item is added to the
|
||||
// middle of a list
|
||||
function incrementRemainingMarkdownListNumbers(cm, pos) {
|
||||
var startLine = pos.line, lookAhead = 0, skipCount = 0;
|
||||
var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1];
|
||||
|
||||
do {
|
||||
lookAhead += 1;
|
||||
var nextLineNumber = startLine + lookAhead;
|
||||
var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine);
|
||||
|
||||
if (nextItem) {
|
||||
var nextIndent = nextItem[1];
|
||||
var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount);
|
||||
var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber;
|
||||
|
||||
if (startIndent === nextIndent && !isNaN(nextNumber)) {
|
||||
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
|
||||
if (newNumber > nextNumber) itemNumber = newNumber + 1;
|
||||
cm.replaceRange(
|
||||
nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
|
||||
{
|
||||
line: nextLineNumber, ch: 0
|
||||
}, {
|
||||
line: nextLineNumber, ch: nextLine.length
|
||||
});
|
||||
} else {
|
||||
if (startIndent.length > nextIndent.length) return;
|
||||
// This doesn't run if the next line immediatley indents, as it is
|
||||
// not clear of the users intention (new indented item or same level)
|
||||
if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return;
|
||||
skipCount += 1;
|
||||
}
|
||||
}
|
||||
} while (nextItem);
|
||||
}
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue