Merge branch 'master' into webpack-frontend

This commit is contained in:
Yukai Huang
2016-10-11 18:39:15 +08:00
527 changed files with 2584 additions and 601 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 684 B

View File

@@ -1,6 +1,66 @@
Release Notes
===
<i class="fa fa-tag"></i> 0.4.5 `latte` <i class="fa fa-clock-o"></i> 2016-10-11 01:22
---
### Features
+ Add more environment variables for server configuration
+ Add setup script for getting started
+ Add support of deleting note
+ Add support of shortcut keys which can add and remove symbol surround text
+ Add support of shortcut keys for changing mode
+ Add support of i18n (English, Chinese, French, German, Japanese, Spanish, Portuguese, Greek, Italian, Turkish, Russian, Dutch, Croatian, Polish, Ukrainian)
+ Add support of note info API
+ Add support of disqus via yaml-metadata
### Enhancements
* Optimize png images by using zopflipng
* Update CodeMirror to 5.19.0 and rename jade to pug
* Update to add cache to history and improve its performance
* Update default indent to use spaces instead of tabs
* Improve syntax highlighting performance
* Update to make client handle syncing error better, use delay to avoid wrong document revision
* Update to allow CORS as API on revision actions
* Update to support showing owner on the infobar
* Update to prevent duplicate client push in queue to lower down server loading
* Reduce update view debounce time to make preview refresh quicker
* Update help modal cheatsheet font styles to make it more clear on spaces
* Update to add revision saving policy
* Update to support tiddlywiki and mediawiki syntax highlighting in editor
* Update to support save mode to url and vise versa
* Update edit and publish icon and change toggle icon for UX
* Improve authorship markers update performance
* Update slide mode to show extra info and support url actions
* Change the last change user saving strategy
* Update to support data uri in src attribute of image tag
* Improve index layout and UX with UI adjustments
* Update XSS policy to allow iframe and link with custom protocol
* Update markdown styles to follow github latest layout styles
* Update slide mode, now respect all meta settings and update default styles
* Update to make ToC menu always accessible without scrolling
* Update to make doc only update while filesystem content not match db content
### Fixes
* Fix README and features document format and grammar issues
* Fix some potential memory leaks bugs
* Fix history storage might not fallback correctly
* Fix to make mathjax expression display in editor correctly (not italic)
* Fix note title might have unstriped html tags
* Fix client reconnect should resend last operation
* Fix a bug when setting both maxAge and expires may cause user can't signin
* Fix text complete extra tags for blockquote and referrals
* Fix bug that when window close will make ajax fail and cause cookies set to wrong state
* Fix markdown render might fall into regex infinite loop
* Fix syntax error caused by element contain special characters
* Fix reference error caused by some scripts loading order
* Fix ToC id naming to avoid possible overlap with user ToC
* Fix header nav bar rwd detect element should use div tag or it might glitch the layout
* Fix textcomplete of extra tags for blockquote not match space character in the between
* Fix text-shadow for text antialiased might cause IE or Edge text cutoff
### Removes
- Cancel updating history on page unload
<i class="fa fa-tag"></i> 0.4.4 `mocha` <i class="fa fa-clock-o"></i> 2016-08-02 17:10
---
### Features

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -1,20 +1,18 @@
var config = require('./config');
var domain = config.domain; // domain name
var urlpath = config.urlpath; // sub url path, like: www.example.com/<urlpath>
var debug = config.debug;
var GOOGLE_API_KEY = config.GOOGLE_API_KEY;
var GOOGLE_CLIENT_ID = config.GOOGLE_CLIENT_ID;
var DROPBOX_APP_KEY = config.DROPBOX_APP_KEY;
//common
var domain = ''; // domain name
var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
//settings
var debug = false;
var GOOGLE_API_KEY = '';
var GOOGLE_CLIENT_ID = '';
var DROPBOX_APP_KEY = '';
var port = window.location.port;
var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : '');
var noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1];
var noteurl = serverurl + '/' + noteid;
var version = '0.4.4';
var version = '0.4.5';
var checkAuth = false;
var profile = null;

View File

@@ -0,0 +1,19 @@
//config
var domain = ''; // domain name
var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
//settings
var debug = false;
var GOOGLE_API_KEY = '';
var GOOGLE_CLIENT_ID = '';
var DROPBOX_APP_KEY = '';
module.exports = {
domain: domain,
urlpath: urlpath,
debug: debug,
GOOGLE_API_KEY: GOOGLE_API_KEY,
GOOGLE_CLIENT_ID: GOOGLE_CLIENT_ID,
DROPBOX_APP_KEY: DROPBOX_APP_KEY
};

View File

@@ -35,7 +35,11 @@ var options = {
</div>\
</div>\
</a>\
</li>'
</li>',
page: 18,
plugins: [
ListPagination({})
]
};
var historyList = new List('history', options);
@@ -183,19 +187,32 @@ function parseHistoryCallback(list, notehistory) {
pinned = false;
item._values.pinned = false;
}
getHistory(function (notehistory) {
for(var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == id) {
notehistory[i].pinned = pinned;
break;
}
}
saveHistory(notehistory);
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
});
checkIfAuth(function () {
postHistoryToServer(id, {
pinned: pinned
}, function (err, result) {
if (!err) {
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
}
});
}, function () {
getHistory(function (notehistory) {
for(var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == id) {
notehistory[i].pinned = pinned;
break;
}
}
saveHistory(notehistory);
if (pinned)
$this.addClass('active');
else
$this.removeClass('active');
});
})
});
buildTagsFilter(filtertags);
}
@@ -216,23 +233,40 @@ var clearHistory = false;
var deleteId = null;
function deleteHistory() {
if (clearHistory) {
saveHistory([]);
historyList.clear();
checkHistoryList();
deleteId = null;
} else {
if (!deleteId) return;
getHistory(function (notehistory) {
var newnotehistory = removeHistory(deleteId, notehistory);
saveHistory(newnotehistory);
historyList.remove('id', deleteId);
checkIfAuth(function () {
deleteServerHistory(deleteId, function (err, result) {
if (!err) {
if (clearHistory) {
historyList.clear();
checkHistoryList();
} else {
historyList.remove('id', deleteId);
checkHistoryList();
}
}
$('.delete-modal').modal('hide');
deleteId = null;
clearHistory = false;
});
}, function () {
if (clearHistory) {
saveHistory([]);
historyList.clear();
checkHistoryList();
deleteId = null;
});
}
$('.delete-modal').modal('hide');
clearHistory = false;
} else {
if (!deleteId) return;
getHistory(function (notehistory) {
var newnotehistory = removeHistory(deleteId, notehistory);
saveHistory(newnotehistory);
historyList.remove('id', deleteId);
checkHistoryList();
deleteId = null;
});
}
$('.delete-modal').modal('hide');
clearHistory = false;
});
}
$(".ui-delete-modal-confirm").click(function () {

View File

@@ -12,6 +12,7 @@ var lastchangeui = {
user: $(".ui-lastchangeuser"),
nouser: $(".ui-no-lastchangeuser")
}
var ownerui = $(".ui-owner");
function updateLastChange() {
if (!lastchangeui) return;
@@ -46,6 +47,23 @@ function updateLastChangeUser() {
}
}
var owner = null;
var ownerprofile = null;
function updateOwner() {
if (ownerui) {
if (owner && ownerprofile && owner !== lastchangeuser) {
var icon = ownerui.children('i');
icon.attr('title', ownerprofile.name).tooltip('fixTitle');
var styleString = 'background-image:url(' + ownerprofile.photo + ')';
if (ownerprofile.photo && icon.attr('style') !== styleString)
icon.attr('style', styleString);
ownerui.show();
} else {
ownerui.hide();
}
}
}
//get title
function getTitle(view) {
var title = "";
@@ -426,6 +444,33 @@ function finishView(view) {
height: '400px'
});
});
//syntax highlighting
view.find("pre.raw").removeClass("raw")
.each(function (key, value) {
var langDiv = $(value).find('code.hljs');
if (langDiv.length > 0) {
var reallang = langDiv[0].className.replace('hljs', '').trim();
var codeDiv = $(value).find('.code');
var code = "";
if (codeDiv.length > 0) code = codeDiv.html();
else code = langDiv.html();
code = md.utils.unescapeAll(code);
if (reallang == "tiddlywiki" || reallang == "mediawiki") {
var result = {
value: Prism.highlight(code, Prism.languages.wiki)
};
} else {
var languages = hljs.listLanguages();
if (languages.indexOf(reallang) == -1) {
var result = hljs.highlightAuto(code);
} else {
var result = hljs.highlight(reallang, code);
}
}
if (codeDiv.length > 0) codeDiv.html(result.value);
else langDiv.html(result.value);
}
});
//render title
document.title = renderTitle(view);
}
@@ -766,19 +811,9 @@ function highlightRender(code, lang) {
} else if (lang == 'mermaid') {
return '<div class="mermaid raw">' + code + '</div>';
}
var reallang = lang.replace(/\=$|\=\d+$|\=\+$/, '');
if (reallang == "tiddlywiki" || reallang == "mediawiki") {
var result = {
value: Prism.highlight(code, Prism.languages.wiki)
};
} else {
var languages = hljs.listLanguages();
if (languages.indexOf(reallang) == -1) {
var result = hljs.highlightAuto(code);
} else {
var result = hljs.highlight(reallang, code);
}
}
var result = {
value: code
};
var showlinenumbers = /\=$|\=\d+$|\=\+$/.test(lang);
if (showlinenumbers) {
var startnumber = 1;
@@ -878,7 +913,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
return highlighted + '\n';
}
return '<pre><code' + self.renderAttrs(token) + '>'
return '<pre class="raw"><code' + self.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
};
@@ -1050,5 +1085,6 @@ module.exports = {
renderFilename: renderFilename,
generateToc: generateToc,
smoothHashScroll: smoothHashScroll,
scrollToHash: scrollToHash
scrollToHash: scrollToHash,
owner: owner
};

View File

@@ -58,7 +58,7 @@ function saveHistoryToStorage(notehistory) {
if (store.enabled)
store.set('notehistory', JSON.stringify(notehistory));
else
saveHistoryToStorage(notehistory);
saveHistoryToCookie(notehistory);
}
function saveHistoryToCookie(notehistory) {
@@ -107,8 +107,8 @@ function clearDuplicatedHistory(notehistory) {
var id = notehistory[i].id.replace(/\=+$/, '');
var newId = newnotehistory[j].id.replace(/\=+$/, '');
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
var time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a');
var newTime = moment(newnotehistory[j].time, 'MMMM Do YYYY, h:mm:ss a');
var time = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
var newTime = (typeof newnotehistory[i].time === 'number' ? moment(newnotehistory[i].time) : moment(newnotehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
if(time >= newTime) {
newnotehistory[j] = notehistory[i];
}
@@ -150,7 +150,8 @@ function removeHistory(id, notehistory) {
function writeHistory(view) {
checkIfAuth(
function () {
writeHistoryToServer(view);
// no need to do this anymore, this will count from server-side
// writeHistoryToServer(view);
},
function () {
writeHistoryToStorage(view);
@@ -176,8 +177,8 @@ function writeHistoryToServer(view) {
var newnotehistory = generateHistory(view, notehistory);
saveHistoryToServer(newnotehistory);
})
.fail(function () {
writeHistoryToStorage(view);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@@ -257,7 +258,7 @@ function renderHistory(view) {
return {
id: id,
text: title,
time: moment().format('MMMM Do YYYY, h:mm:ss a'),
time: moment().valueOf(),
tags: tags
};
}
@@ -297,8 +298,8 @@ function getServerHistory(callback) {
callback(data.history);
}
})
.fail(function () {
getStorageHistory(callback);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@@ -338,8 +339,8 @@ function parseServerToHistory(list, callback) {
parseToHistory(list, data.history, callback);
}
})
.fail(function () {
parseStorageToHistory(list, callback);
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
});
}
@@ -368,9 +369,10 @@ function parseToHistory(list, notehistory, callback) {
else if (notehistory && notehistory.length > 0) {
for (var i = 0; i < notehistory.length; i++) {
//parse time to timestamp and fromNow
notehistory[i].timestamp = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').valueOf();
notehistory[i].fromNow = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').fromNow();
notehistory[i].time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a').format('llll');
var timestamp = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a'));
notehistory[i].timestamp = timestamp.valueOf();
notehistory[i].fromNow = timestamp.fromNow();
notehistory[i].time = timestamp.format('llll');
if (notehistory[i].id && list.get('id', notehistory[i].id).length == 0)
list.add(notehistory[i]);
}
@@ -378,6 +380,31 @@ function parseToHistory(list, notehistory, callback) {
callback(list, notehistory);
}
function postHistoryToServer(noteId, data, callback) {
$.post(serverurl + '/history/' + noteId, data)
.done(function (result) {
return callback(null, result);
})
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
return callback(error, null);
});
}
function deleteServerHistory(noteId, callback) {
$.ajax({
url: serverurl + '/history' + (noteId ? '/' + noteId : ""),
type: 'DELETE'
})
.done(function (result) {
return callback(null, result);
})
.fail(function (xhr, status, error) {
console.error(xhr.responseText);
return callback(error, null);
});
}
module.exports = {
writeHistory: writeHistory,
parseHistory: parseHistory,
@@ -385,5 +412,7 @@ module.exports = {
getHistory: getHistory,
saveHistory: saveHistory,
removeHistory: removeHistory,
parseStorageToHistory: parseStorageToHistory
parseStorageToHistory: parseStorageToHistory,
postHistoryToServer: postHistoryToServer,
deleteServerHistory: deleteServerHistory
}

View File

@@ -62,6 +62,7 @@ var renderTOC = extra.renderTOC;
var renderTitle = extra.renderTitle;
var renderFilename = extra.renderFilename;
var scrollToHash = extra.scrollToHash;
var owner = extra.owner;
var historyModule = require('./history');
var writeHistory = historyModule.writeHistory;
@@ -72,6 +73,7 @@ var preventXSS = renderer.preventXSS;
var defaultTextHeight = 20;
var viewportMargin = 20;
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
var defaultEditorMode = 'gfm';
var defaultExtraKeys = {
"F10": function (cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
@@ -214,7 +216,7 @@ var cursorMenuThrottle = 50;
var cursorActivityDebounce = 50;
var cursorAnimatePeriod = 100;
var supportContainers = ['success', 'info', 'warning', 'danger'];
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki'];
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
var supportHeaders = [
{
@@ -430,8 +432,8 @@ window.fileTypes = {
var textit = document.getElementById("textit");
if (!textit) throw new Error("There was no textit area!");
window.editor = CodeMirror.fromTextArea(textit, {
mode: 'gfm',
backdrop: 'gfm',
mode: defaultEditorMode,
backdrop: defaultEditorMode,
keyMap: "sublime",
viewportMargin: viewportMargin,
styleActiveLine: true,
@@ -440,7 +442,6 @@ window.editor = CodeMirror.fromTextArea(textit, {
showCursorWhenSelecting: true,
highlightSelectionMatches: true,
indentUnit: 4,
indentWithTabs: true,
continueComments: "Enter",
theme: "one-dark",
inputStyle: "textarea",
@@ -675,7 +676,7 @@ function setSpellcheck() {
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
mode = 'spell-checker';
} else {
mode = 'gfm';
mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@@ -685,10 +686,10 @@ function setSpellcheck() {
var spellcheckToggle = statusSpellcheck.find('.ui-spellcheck-toggle');
spellcheckToggle.click(function () {
var mode = editor.getOption('mode');
if (mode == "gfm") {
if (mode == defaultEditorMode) {
mode = "spell-checker";
} else {
mode = "gfm";
mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@@ -700,7 +701,7 @@ function setSpellcheck() {
});
function checkSpellcheck() {
var mode = editor.getOption('mode');
if (mode == "gfm") {
if (mode == defaultEditorMode) {
spellcheckToggle.removeClass('active');
} else {
spellcheckToggle.addClass('active');
@@ -748,7 +749,18 @@ function updateStatusBar() {
statusCursor.text(cursorText);
var fileText = ' — ' + editor.lineCount() + ' Lines';
statusFile.text(fileText);
statusLength.text('Length ' + editor.getValue().length);
var docLength = editor.getValue().length;
statusLength.text('Length ' + docLength);
if (docLength > (docmaxlength * 0.95)) {
statusLength.css('color', 'red');
statusLength.attr('title', 'Your almost reach note max length limit.');
} else if (docLength > (docmaxlength * 0.8)) {
statusLength.css('color', 'orange');
statusLength.attr('title', 'You nearly fill the note, consider to make more pieces.');
} else {
statusLength.css('color', 'white');
statusLength.attr('title', 'You could write up to ' + docmaxlength + ' characters in this note.');
}
}
//ui vars
@@ -800,7 +812,8 @@ var ui = {
editable: $(".ui-permission-editable"),
locked: $(".ui-permission-locked"),
private: $(".ui-permission-private")
}
},
delete: $(".ui-delete-note")
},
toc: {
toc: $('.ui-toc'),
@@ -989,7 +1002,7 @@ $(window).resize(function () {
});
//when page unload
$(window).on('unload', function () {
updateHistoryInner();
//updateHistoryInner();
});
$(window).on('error', function () {
//setNeedRefresh();
@@ -1817,7 +1830,7 @@ function initRevisionViewer() {
if (revisionViewer) return;
var revisionViewerTextArea = document.getElementById("revisionViewer");
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
mode: 'gfm',
mode: defaultEditorMode,
viewportMargin: viewportMargin,
lineNumbers: true,
lineWrapping: true,
@@ -2175,6 +2188,13 @@ ui.infobar.permission.locked.click(function () {
ui.infobar.permission.private.click(function () {
emitPermission("private");
});
// delete note
ui.infobar.delete.click(function () {
$('.delete-modal').modal('show');
});
$('.ui-delete-modal-confirm').click(function () {
socket.emit('delete');
});
function emitPermission(_permission) {
if (_permission != permission) {
@@ -2263,24 +2283,30 @@ socket.on('info', function (data) {
console.error(data);
switch (data.code) {
case 403:
location.href = "./403";
location.href = serverurl + "/403";
break;
case 404:
location.href = "./404";
location.href = serverurl + "/404";
break;
case 500:
location.href = "./500";
location.href = serverurl + "/500";
break;
}
});
socket.on('error', function (data) {
console.error(data);
if (data.message && data.message.indexOf('AUTH failed') === 0)
location.href = "./403";
location.href = serverurl + "/403";
});
socket.on('delete', function () {
deleteServerHistory(noteid, function (err, data) {
if (!err) location.href = serverurl;
});
});
var retryOnDisconnect = false;
var retryTimer = null;
socket.on('maintenance', function () {
cmClient.revision = -1;
retryOnDisconnect = true;
});
socket.on('disconnect', function (data) {
@@ -2310,8 +2336,6 @@ socket.on('connect', function (data) {
personalInfo['id'] = socket.id;
showStatus(statusType.connected);
socket.emit('version');
if (socket.id.indexOf('/') == -1)
socket.id = socket.nsp + '#' + socket.id;
});
socket.on('version', function (data) {
if (version != data.version) {
@@ -2328,7 +2352,7 @@ var authorship = [];
var authorshipMarks = {};
var authorMarks = {}; // temp variable
var addTextMarkers = []; // temp variable
function updateLastInfo(data) {
function updateInfo(data) {
//console.log(data);
if (data.hasOwnProperty('createtime') && createtime !== data.createtime) {
createtime = data.createtime;
@@ -2338,10 +2362,16 @@ function updateLastInfo(data) {
lastchangetime = data.updatetime;
updateLastChange();
}
if (data.hasOwnProperty('owner') && owner !== data.owner) {
owner = data.owner;
ownerprofile = data.ownerprofile;
updateOwner();
}
if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) {
lastchangeuser = data.lastchangeuser;
lastchangeuserprofile = data.lastchangeuserprofile;
updateLastChangeUser();
updateOwner();
}
if (data.hasOwnProperty('authors') && authors !== data.authors) {
authors = data.authors;
@@ -2391,7 +2421,7 @@ var addStyleRule = (function () {
}());
function updateAuthorshipInner() {
// ignore when ot not synced yet
if (Object.keys(cmClient.state).length > 0) return;
if (cmClient && Object.keys(cmClient.state).length > 0) return;
authorMarks = {};
for (var i = 0; i < authorship.length; i++) {
var atom = authorship[i];
@@ -2556,14 +2586,12 @@ socket.on('check', function (data) {
data = LZString.decompressFromUTF16(data);
data = JSON.parse(data);
//console.log(data);
updateLastInfo(data);
updateInfo(data);
});
socket.on('permission', function (data) {
updatePermission(data.permission);
});
var docmaxlength = null;
var otk = null;
var owner = null;
var permission = null;
socket.on('refresh', function (data) {
data = LZString.decompressFromUTF16(data);
@@ -2571,10 +2599,8 @@ socket.on('refresh', function (data) {
//console.log(data);
docmaxlength = data.docmaxlength;
editor.setOption("maxLength", docmaxlength);
otk = data.otk;
owner = data.owner;
updateInfo(data);
updatePermission(data.permission);
updateLastInfo(data);
if (!loaded) {
// auto change mode if no content detected
var nocontent = editor.getValue().length <= 0;
@@ -2617,16 +2643,14 @@ socket.on('doc', function (obj) {
obj = LZString.decompressFromUTF16(obj);
obj = JSON.parse(obj);
var body = obj.str;
var bodyMismatch = (editor.getValue() != body);
var bodyMismatch = editor.getValue() !== body;
var setDoc = !cmClient || (cmClient && cmClient.revision === -1) || obj.force;
saveInfo();
if (bodyMismatch) {
if (cmClient)
cmClient.editorAdapter.ignoreNextChange = true;
if (body)
editor.setValue(body);
else
editor.setValue("");
if (setDoc && bodyMismatch) {
if (cmClient) cmClient.editorAdapter.ignoreNextChange = true;
if (body) editor.setValue(body);
else editor.setValue("");
}
if (!loaded) {
@@ -2635,12 +2659,8 @@ socket.on('doc', function (obj) {
ui.content.fadeIn();
} else {
//if current doc is equal to the doc before disconnect
if (bodyMismatch)
editor.clearHistory();
else {
if (lastInfo.history)
editor.setHistory(lastInfo.history);
}
if (setDoc && bodyMismatch) editor.clearHistory();
else if (lastInfo.history) editor.setHistory(lastInfo.history);
lastInfo.history = null;
}
@@ -2649,7 +2669,7 @@ socket.on('doc', function (obj) {
obj.revision, obj.clients,
new SocketIOAdapter(socket), new CodeMirrorAdapter(editor)
);
} else {
} else if (setDoc) {
if (bodyMismatch) {
cmClient.undoManager.undoStack.length = 0;
cmClient.undoManager.redoStack.length = 0;
@@ -2660,7 +2680,7 @@ socket.on('doc', function (obj) {
cmClient.initializeClients(obj.clients);
}
if (bodyMismatch) {
if (setDoc && bodyMismatch) {
isDirty = true;
updateView();
}

View File

@@ -78,7 +78,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
if (tokens[idx].map && tokens[idx].level === 0) {
var startline = tokens[idx].map[0] + 1;
var endline = tokens[idx].map[1];
return '<pre class="part" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
return '<pre class="part raw" data-startline="' + startline + '" data-endline="' + endline + '"><code' + self.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
}

View File

@@ -1,45 +0,0 @@
//parse Youtube
result.find(".youtube").each(function (key, value) {
if (!$(value).attr('videoid')) return;
setSizebyAttr(this, this);
var icon = '<i class="icon fa fa-youtube-play fa-5x"></i>';
$(this).append(icon);
var videoid = $(value).attr('videoid');
var thumbnail_src = '//img.youtube.com/vi/' + videoid + '/hqdefault.jpg';
$(value).css('background-image', 'url(' + thumbnail_src + ')');
$(this).click(function () {
imgPlayiframe(this, '//www.youtube.com/embed/');
});
});
//parse vimeo
result.find(".vimeo").each(function (key, value) {
if (!$(value).attr('videoid')) return;
setSizebyAttr(this, this);
var icon = '<i class="icon fa fa-vimeo-square fa-5x"></i>';
$(this).append(icon);
var videoid = $(value).attr('videoid');
$.ajax({
type: 'GET',
url: 'http://vimeo.com/api/v2/video/' + videoid + '.json',
jsonp: 'callback',
dataType: 'jsonp',
success: function (data) {
var thumbnail_src = data[0].thumbnail_large;
$(value).css('background-image', 'url(' + thumbnail_src + ')');
}
});
$(this).click(function () {
imgPlayiframe(this, '//player.vimeo.com/video/');
});
});
//todo list
var lis = result[0].getElementsByTagName('li');
for (var i = 0; i < lis.length; i++) {
var html = lis[i].innerHTML;
if (/^\s*\[[x ]\]\s*/.test(html)) {
lis[i].innerHTML = html.replace(/^\s*\[ \]\s*/, '<input type="checkbox" class="task-list-item-checkbox" disabled>')
.replace(/^\s*\[x\]\s*/, '<input type="checkbox" class="task-list-item-checkbox" checked disabled>');
lis[i].setAttribute('class', 'task-list-item');
}
}

View File

@@ -103,6 +103,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;
@@ -140,7 +141,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);
}
@@ -162,13 +163,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);
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);
if (close == -1 && start != end) {
endLine = self.getLine(--end);
close = endLine.lastIndexOf(endString);
close = endLine.indexOf(endString);
}
if (open == -1 || close == -1 ||
if (close == -1 ||
!/comment/.test(self.getTokenTypeAt(Pos(start, open + 1))) ||
!/comment/.test(self.getTokenTypeAt(Pos(end, close + 1))))
return false;

View File

@@ -21,8 +21,8 @@
function Iter(cm, line, ch, range) {
this.line = line; this.ch = ch;
this.cm = cm; this.text = cm.getLine(line);
this.min = range ? range.from : cm.firstLine();
this.max = range ? range.to - 1 : cm.lastLine();
this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
}
function tagAt(iter, ch) {

View File

@@ -97,6 +97,15 @@
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
function forAllProps(obj, callback) {
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
for (var name in obj) callback(name)
} else {
for (var o = obj; o; o = Object.getPrototypeOf(o))
Object.getOwnPropertyNames(o).forEach(callback)
}
}
function getCompletions(token, context, keywords, options) {
var found = [], start = token.string, global = options && options.globalScope || window;
function maybeAdd(str) {
@@ -106,7 +115,7 @@
if (typeof obj == "string") forEach(stringProps, maybeAdd);
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
for (var name in obj) maybeAdd(name);
forAllProps(obj, maybeAdd)
}
if (context && context.length) {

View File

@@ -45,6 +45,7 @@
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
this.overlay = this.timeout = null;
this.matchesonscroll = null;
this.active = false;
}
CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
@@ -53,16 +54,34 @@
clearTimeout(cm.state.matchHighlighter.timeout);
cm.state.matchHighlighter = null;
cm.off("cursorActivity", cursorActivity);
cm.off("focus", onFocus)
}
if (val) {
cm.state.matchHighlighter = new State(val);
highlightMatches(cm);
var state = cm.state.matchHighlighter = new State(val);
if (cm.hasFocus()) {
state.active = true
highlightMatches(cm)
} else {
cm.on("focus", onFocus)
}
cm.on("cursorActivity", cursorActivity);
}
});
function cursorActivity(cm) {
var state = cm.state.matchHighlighter;
if (state.active || cm.hasFocus()) scheduleHighlight(cm, state)
}
function onFocus(cm) {
var state = cm.state.matchHighlighter
if (!state.active) {
state.active = true
scheduleHighlight(cm, state)
}
}
function scheduleHighlight(cm, state) {
clearTimeout(state.timeout);
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
}

View File

@@ -136,8 +136,11 @@
})
};
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
if (cmd == "findNext" || cmd == "findPrev") {
var keyName = CodeMirror.keyName(event)
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
if (cmd == "findNext" || cmd == "findPrev" ||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
CodeMirror.e_stop(event);
startSearch(cm, getSearchState(cm), query);
cm.execCommand(cmd);
@@ -146,7 +149,7 @@
searchNext(query, event);
}
});
if (immediate) {
if (immediate && q) {
startSearch(cm, state, q);
findNext(cm, rev);
}

File diff suppressed because one or more lines are too long

View File

@@ -30,7 +30,7 @@ addon/fold/foldgutter.js \
addon/fold/markdown-fold.js \
addon/fold/xml-fold.js \
mode/xml/xml.js \
mode/markdown/markdown.js \
mode/markdown/markdown_math.js \
mode/gfm/gfm.js \
mode/javascript/javascript.js \
mode/css/css.js \
@@ -45,7 +45,7 @@ mode/php/php.js \
mode/sql/sql.js \
mode/coffeescript/coffeescript.js \
mode/yaml/yaml.js \
mode/jade/jade.js \
mode/pug/pug.js \
mode/lua/lua.js \
mode/cmake/cmake.js \
mode/nginx/nginx.js \

View File

@@ -780,8 +780,12 @@
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
if (keysAreChars) {
var here = cm.getCursor();
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
var selections = cm.listSelections();
for (var i = 0; i < selections.length; i++) {
var here = selections[i].head;
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
}
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
}
clearInputState(cm);
return match.command;
@@ -818,7 +822,7 @@
// TODO: Look into using CodeMirror's multi-key handling.
// Return no-op since we are caching the key. Counts as handled, but
// don't want act on it just yet.
return function() {};
return function() { return true; };
} else {
return function() {
return cm.operation(function() {
@@ -4874,6 +4878,10 @@
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|| changeObj.origin === undefined /* only in testing */) {
var text = changeObj.text.join('\n');
if (lastChange.maybeReset) {
lastChange.changes = [];
lastChange.maybeReset = false;
}
lastChange.changes.push(text);
}
// Change objects may be chained with next.
@@ -4896,7 +4904,7 @@
lastChange.expectCursorActivityForChange = false;
} else {
// Cursor moved outside the context of an edit. Reset the change.
lastChange.changes = [];
lastChange.maybeReset = true;
}
} else if (!cm.curOp.isVimOp) {
handleExternalSelection(cm, vim);
@@ -4960,6 +4968,10 @@
var keyName = CodeMirror.keyName(e);
if (!keyName) { return; }
function onKeyFound() {
if (lastChange.maybeReset) {
lastChange.changes = [];
lastChange.maybeReset = false;
}
lastChange.changes.push(new InsertModeKey(keyName));
return true;
}

View File

@@ -592,8 +592,12 @@
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
var gutterW = display.gutters.offsetWidth, left = comp + "px";
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
if (cm.options.fixedGutter && view[i].gutter)
view[i].gutter.style.left = left;
if (cm.options.fixedGutter) {
if (view[i].gutter)
view[i].gutter.style.left = left;
if (view[i].gutterBackground)
view[i].gutterBackground.style.left = left;
}
var align = view[i].alignable;
if (align) for (var j = 0; j < align.length; j++)
align[j].style.left = left;
@@ -1149,7 +1153,7 @@
}
function handlePaste(e, cm) {
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
var pasted = e.clipboardData && e.clipboardData.getData("Text");
if (pasted) {
e.preventDefault();
if (!cm.isReadOnly() && !cm.options.disableInput)
@@ -1193,10 +1197,10 @@
return {text: text, ranges: ranges};
}
function disableBrowserMagic(field) {
function disableBrowserMagic(field, spellcheck) {
field.setAttribute("autocorrect", "off");
field.setAttribute("autocapitalize", "off");
field.setAttribute("spellcheck", "false");
field.setAttribute("spellcheck", !!spellcheck);
}
// TEXTAREA INPUT STYLE
@@ -1576,10 +1580,14 @@
init: function(display) {
var input = this, cm = input.cm;
var div = input.div = display.lineDiv;
disableBrowserMagic(div);
disableBrowserMagic(div, cm.options.spellcheck);
on(div, "paste", function(e) {
if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
// IE doesn't fire input events, so we schedule a read for the pasted content in this way
if (ie_version <= 11) setTimeout(operation(cm, function() {
if (!input.pollContent()) regChange(cm);
}), 20)
})
on(div, "compositionstart", function(e) {
@@ -1639,23 +1647,27 @@
});
}
}
// iOS exposes the clipboard API, but seems to discard content inserted into it
if (e.clipboardData && !ios) {
e.preventDefault();
if (e.clipboardData) {
e.clipboardData.clearData();
e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
} else {
// Old-fashioned briefly-focus-a-textarea hack
var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n");
var hadFocus = document.activeElement;
selectInput(te);
setTimeout(function() {
cm.display.lineSpace.removeChild(kludge);
hadFocus.focus();
}, 50);
var content = lastCopied.text.join("\n")
// iOS exposes the clipboard API, but seems to discard content inserted into it
e.clipboardData.setData("Text", content);
if (e.clipboardData.getData("Text") == content) {
e.preventDefault();
return
}
}
// Old-fashioned briefly-focus-a-textarea hack
var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n");
var hadFocus = document.activeElement;
selectInput(te);
setTimeout(function() {
cm.display.lineSpace.removeChild(kludge);
hadFocus.focus();
if (hadFocus == div) input.showPrimarySelection()
}, 50);
}
on(div, "copy", onCopyCut);
on(div, "cut", onCopyCut);
@@ -1963,7 +1975,7 @@
if (found)
return badPos(Pos(found.line, found.ch + dist), bad);
else
dist += after.textContent.length;
dist += before.textContent.length;
}
}
@@ -3533,8 +3545,8 @@
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
on(inp, "keydown", operation(cm, onKeyDown));
on(inp, "keypress", operation(cm, onKeyPress));
on(inp, "focus", bind(onFocus, cm));
on(inp, "blur", bind(onBlur, cm));
on(inp, "focus", function (e) { onFocus(cm, e); });
on(inp, "blur", function (e) { onBlur(cm, e); });
}
function dragDropChanged(cm, value, old) {
@@ -4262,12 +4274,12 @@
}, 100);
}
function onFocus(cm) {
function onFocus(cm, e) {
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
if (cm.options.readOnly == "nocursor") return;
if (!cm.state.focused) {
signal(cm, "focus", cm);
signal(cm, "focus", cm, e);
cm.state.focused = true;
addClass(cm.display.wrapper, "CodeMirror-focused");
// This test prevents this from firing when a context
@@ -4281,11 +4293,11 @@
}
restartBlink(cm);
}
function onBlur(cm) {
function onBlur(cm, e) {
if (cm.state.delayingBlurEvent) return;
if (cm.state.focused) {
signal(cm, "blur", cm);
signal(cm, "blur", cm, e);
cm.state.focused = false;
rmClass(cm.display.wrapper, "CodeMirror-focused");
}
@@ -4907,7 +4919,8 @@
var doc = cm.doc, x = pos.left, y;
if (unit == "page") {
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
} else if (unit == "line") {
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
}
@@ -4960,7 +4973,10 @@
addOverlay: methodOp(function(spec, options) {
var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
if (mode.startState) throw new Error("Overlays may not be stateful.");
this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
insertSorted(this.state.overlays,
{mode: mode, modeSpec: spec, opaque: options && options.opaque,
priority: (options && options.priority) || 0},
function(overlay) { return overlay.priority })
this.state.modeGen++;
regChange(this);
}),
@@ -5432,6 +5448,9 @@
option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
}, true);
option("spellcheck", false, function(cm, val) {
cm.getInputField().spellcheck = val
}, true);
option("rtlMoveVisually", !windows);
option("wholeLineUpdateBefore", true);
@@ -5541,6 +5560,8 @@
spec.name = found.name;
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
return CodeMirror.resolveMode("application/xml");
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
return CodeMirror.resolveMode("application/json");
}
if (typeof spec == "string") return {name: spec};
else return spec || {name: "null"};
@@ -6852,7 +6873,7 @@
}
if (!flattenSpans || curStyle != style) {
while (curStart < stream.start) {
curStart = Math.min(stream.start, curStart + 50000);
curStart = Math.min(stream.start, curStart + 5000);
f(curStart, curStyle);
}
curStyle = style;
@@ -6860,8 +6881,10 @@
stream.start = stream.pos;
}
while (curStart < stream.pos) {
// Webkit seems to refuse to render text nodes longer than 57444 characters
var pos = Math.min(stream.pos, curStart + 50000);
// Webkit seems to refuse to render text nodes longer than 57444
// characters, and returns inaccurate measurements in nodes
// starting around 5000 chars.
var pos = Math.min(stream.pos, curStart + 5000);
f(pos, curStyle);
curStart = pos;
}
@@ -7970,7 +7993,7 @@
}
// Register a change in the history. Merges changes that are within
// a single operation, ore are close together with an origin that
// a single operation, or are close together with an origin that
// allows merging (starting with "+") into a single event.
function addChangeToHistory(doc, change, selAfter, opId) {
if(change.origin == "ignoreHistory") return;
@@ -8374,6 +8397,12 @@
return out;
}
function insertSorted(array, value, score) {
var pos = 0, priority = score(value)
while (pos < array.length && score(array[pos]) <= priority) pos++
array.splice(pos, 0, value)
}
function nothing() {}
function createObj(base, props) {
@@ -8942,7 +8971,7 @@
// THE END
CodeMirror.version = "5.17.1";
CodeMirror.version = "5.19.0";
return CodeMirror;
});

View File

@@ -62,7 +62,7 @@
var curPunc;
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
var operatorChars = /[*+\-<>=&|~%^]/;
return {

View File

@@ -433,15 +433,16 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
}
function maybe_drop_post(s) {
if (!s.length) return s
var last = s.length-1;
if (s[last].type === "dot") {
return [];
}
if (s[last].type === "fun" && s[last-1].token === "fun") {
if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") {
return s.slice(0,last-1);
}
switch (s[s.length-1].token) {
switch (s[last].token) {
case "}": return d(s,{g:["{"]});
case "]": return d(s,{i:["["]});
case ")": return d(s,{i:["("]});

View File

@@ -46,7 +46,7 @@
function getAttrValue(text, attr) {
var match = text.match(getAttrRegexp(attr))
return match ? match[2] : ""
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
}
function getTagRegexp(tagName, anchored) {

View File

@@ -76,7 +76,6 @@ option.</p>
<li><a href="http/index.html">HTTP</a></li>
<li><a href="idl/index.html">IDL</a></li>
<li><a href="clike/index.html">Java</a></li>
<li><a href="jade/index.html">Jade</a></li>
<li><a href="javascript/index.html">JavaScript</a> (<a href="jsx/index.html">JSX</a>)</li>
<li><a href="jinja2/index.html">Jinja2</a></li>
<li><a href="julia/index.html">Julia</a></li>
@@ -107,6 +106,7 @@ option.</p>
<li><a href="powershell/index.html">PowerShell</a></li>
<li><a href="properties/index.html">Properties files</a></li>
<li><a href="protobuf/index.html">ProtoBuf</a></li>
<li><a href="pug/index.html">Pug</a></li>
<li><a href="puppet/index.html">Puppet</a></li>
<li><a href="python/index.html">Python</a></li>
<li><a href="q/index.html">Q</a></li>

View File

@@ -1,8 +1,6 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// TODO actually recognize syntax of TypeScript constructs
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
@@ -56,6 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
"namespace": C,
"module": kw("module"),
"enum": kw("module"),
"type": kw("type"),
// scope modifiers
"public": kw("modifier"),
@@ -345,19 +344,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function statement(type, value) {
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
if (type == "{") return cont(pushlex("}"), block, poplex);
if (type == ";") return cont();
if (type == "if") {
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
cx.state.cc.pop()();
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
}
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
if (type == "variable") return cont(pushlex("stat"), maybelabel);
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
block, poplex, poplex);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
@@ -367,6 +366,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
if (type == "async") return cont(statement)
return pass(pushlex("stat"), expression, expect(";"), poplex);
}
@@ -376,6 +376,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function expressionNoComma(type) {
return expressionInner(type, true);
}
function parenExpr(type) {
if (type != "(") return pass()
return cont(pushlex(")"), expression, expect(")"), poplex)
}
function expressionInner(type, noComma) {
if (cx.state.fatArrowAt == cx.stream.start) {
var body = noComma ? arrowBodyNoComma : arrowBody;
@@ -463,8 +467,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type, value) {
if (type == "async") return cont(objprop);
if (type == "variable" || cx.style == "keyword") {
if (type == "async") {
cx.marked = "property";
return cont(objprop);
} else if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);
return cont(afterprop);
@@ -479,6 +485,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return cont(expression, expect("]"), afterprop);
} else if (type == "spread") {
return cont(expression);
} else if (type == ":") {
return pass(afterprop)
}
}
function getterSetter(type) {
@@ -517,14 +525,34 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "}") return cont();
return pass(statement, block);
}
function maybetype(type) {
if (isTS && type == ":") return cont(typeexpr);
function maybetype(type, value) {
if (isTS) {
if (type == ":") return cont(typeexpr);
if (value == "?") return cont(maybetype);
}
}
function maybedefault(_, value) {
if (value == "=") return cont(expressionNoComma);
}
function typeexpr(type) {
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
if (type == "{") return cont(commasep(typeprop, "}"))
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
}
function maybeReturnType(type) {
if (type == "=>") return cont(typeexpr)
}
function typeprop(type) {
if (type == "variable" || cx.style == "keyword") {
cx.marked = "property"
return cont(typeprop)
} else if (type == ":") {
return cont(typeexpr)
}
}
function typearg(type) {
if (type == "variable") return cont(typearg)
else if (type == ":") return cont(typeexpr)
}
function afterType(type, value) {
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
@@ -593,18 +621,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "variable") {register(value); return cont(classNameAfter);}
}
function classNameAfter(type, value) {
if (value == "extends") return cont(expression, classNameAfter);
if (value == "extends") return cont(isTS ? typeexpr : expression, classNameAfter);
if (type == "{") return cont(pushlex("}"), classBody, poplex);
}
function classBody(type, value) {
if (type == "variable" || cx.style == "keyword") {
if (value == "static") {
if ((value == "static" || value == "get" || value == "set" ||
(isTS && (value == "public" || value == "private" || value == "protected"))) &&
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
cx.marked = "keyword";
return cont(classBody);
}
cx.marked = "property";
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
return cont(functiondef, classBody);
return cont(isTS ? classfield : functiondef, classBody);
}
if (value == "*") {
cx.marked = "keyword";
@@ -613,10 +642,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == ";") return cont(classBody);
if (type == "}") return cont();
}
function classGetterSetter(type) {
if (type != "variable") return pass();
cx.marked = "property";
return cont();
function classfield(type) {
if (type == ":") return cont(typeexpr)
return pass(functiondef)
}
function afterExport(_type, value) {
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
@@ -685,14 +713,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
indent: function(state, textAfter) {
if (state.tokenize == tokenComment) return CodeMirror.Pass;
if (state.tokenize != tokenBase) return 0;
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
// Kludge to prevent 'maybelse' from blocking lexical scope pops
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i];
if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse) break;
}
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
while ((lexical.type == "stat" || lexical.type == "form") &&
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
lexical = lexical.prev;
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
lexical = lexical.prev;
var type = lexical.type, closing = firstChar == type;

View File

@@ -31,7 +31,7 @@
MT("class",
"[keyword class] [def Point] [keyword extends] [variable SuperThing] {",
" [property get] [property prop]() { [keyword return] [number 24]; }",
" [keyword 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];",
@@ -140,6 +140,19 @@
" [number 1];",
"[number 2];");
MT("indent_semicolonless_if",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
"}")
MT("indent_semicolonless_if_with_statement",
"[keyword function] [def foo]() {",
" [keyword if] ([variable x])",
" [variable foo]()",
" [variable bar]()",
"}")
MT("multilinestring",
"[keyword var] [def x] [operator =] [string 'foo\\]",
"[string bar'];");
@@ -167,6 +180,23 @@
" }",
"}");
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
function TS(name) {
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
}
TS("extend_type",
"[keyword class] [def Foo] [keyword extends] [variable-3 Some][operator <][variable-3 Type][operator >] {}")
TS("arrow_type",
"[keyword let] [def x]: ([variable arg]: [variable-3 Type]) [operator =>] [variable-3 ReturnType]")
TS("typescript_class",
"[keyword class] [def Foo] {",
" [keyword public] [keyword static] [property main]() {}",
" [keyword private] [property _foo]: [variable-3 string];",
"}")
var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},
{name: "javascript", jsonld: true}

View File

@@ -84,6 +84,6 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
<p>JSX Mode for <a href="http://facebook.github.io/react">React</a>'s
JavaScript syntax extension.</p>
<p><strong>MIME types defined:</strong> <code>text/jsx</code>.</p>
<p><strong>MIME types defined:</strong> <code>text/jsx</code>, <code>text/typescript-jsx</code>.</p>
</article>

View File

@@ -144,4 +144,5 @@
}, "xml", "javascript")
CodeMirror.defineMIME("text/jsx", "jsx")
CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
});

View File

@@ -50,7 +50,7 @@
startState: function(){
return {
next: 'start',
lastToken: null
lastToken: {style: null, indent: 0, content: ""}
};
},
token: function(stream, state){

View File

@@ -0,0 +1,864 @@
// 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("../meta"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
var htmlModeMissing = htmlMode.name == "null"
function getMode(name) {
if (CodeMirror.findModeByName) {
var found = CodeMirror.findModeByName(name);
if (found) name = found.mime || found.mimes[0];
}
var mode = CodeMirror.getMode(cmCfg, name);
return mode.name == "null" ? null : mode;
}
// 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;
// Use `fencedCodeBlocks` to configure fenced code blocks. false to
// disable, string to specify a precise regexp that the fence should
// match, and true to allow three or more backticks or tildes (as
// per CommonMark).
// Turn on task lists? ("- [ ] " and "- [x] ")
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
// Turn on strikethrough syntax
if (modeCfg.strikethrough === undefined)
modeCfg.strikethrough = false;
// Allow token types to be overridden by user-provided token types.
if (modeCfg.tokenTypeOverrides === undefined)
modeCfg.tokenTypeOverrides = {};
var tokenTypes = {
header: "header",
code: "comment",
math: "math",
quote: "quote",
list1: "variable-2",
list2: "variable-3",
list3: "keyword",
hr: "hr",
image: "image",
imageAltText: "image-alt-text",
imageMarker: "image-marker",
formatting: "formatting",
linkInline: "link",
linkEmail: "link",
linkText: "link",
linkHref: "string",
em: "em",
strong: "strong",
strikethrough: "strikethrough"
};
for (var tokenType in tokenTypes) {
if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
}
}
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
, ulRE = /^[*\-+]\s+/
, olRE = /^[0-9]+([.)])\s+/
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
, textRE = /^[^#!\[\]*_\\<>\$` "'(~]+/
, fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
")[ \\t]*([\\w+#\-]*)")
, fencedMathRE = new RegExp("^(\$\$)[ \\t]*([\\w+#\-]*)");
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);
}
function lineIsEmpty(line) {
return !line || !/\S/.test(line.string)
}
// Blocks
function blankLine(state) {
// Reset linkTitle state
state.linkTitle = false;
// Reset EM state
state.em = false;
// Reset STRONG state
state.strong = false;
// Reset strikethrough state
state.strikethrough = false;
// Reset state.quote
state.quote = 0;
// Reset state.indentedCode
state.indentedCode = false;
if (htmlModeMissing && state.f == htmlBlock) {
state.f = inlineNormal;
state.block = blockNormal;
}
// Reset state.trailingSpace
state.trailingSpace = 0;
state.trailingSpaceNewLine = false;
// Mark this line as blank
state.prevLine = state.thisLine
state.thisLine = null
return null;
}
function blockNormal(stream, state) {
var sol = stream.sol();
var prevLineIsList = state.list !== false,
prevLineIsIndentedCode = state.indentedCode;
state.indentedCode = false;
if (prevLineIsList) {
if (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.indentation > 0) {
state.list = null;
} else { // No longer a list
state.list = false;
}
}
var match = null;
if (state.indentationDiff >= 4) {
stream.skipToEnd();
if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
state.indentation -= 4;
state.indentedCode = true;
return tokenTypes.code;
} else {
return null;
}
} else if (stream.eatSpace()) {
return null;
} else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
state.header = match[1].length;
if (modeCfg.highlightFormatting) state.formatting = "header";
state.f = state.inline;
return getType(state);
} else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
!prevLineIsIndentedCode && (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.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)) {
state.hr = true;
return tokenTypes.hr;
} else if ((lineIsEmpty(state.prevLine) || 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 = stream.column() + stream.current().length;
state.list = true;
// While this list item's marker's indentation
// is less than the deepest list item's content's indentation,
// pop the deepest list item indentation off the stack.
while (state.listStack && stream.column() < state.listStack[state.listStack.length - 1]) {
state.listStack.pop();
}
// Add this list item's content's indentation to the stack
state.listStack.push(state.indentation);
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 && (match = stream.match(fencedCodeRE, true))) {
state.fencedChars = match[1]
// try switching mode
state.localMode = getMode(match[2]);
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = -1
return getType(state);
} else if (match = stream.match(fencedCodeRE, true)) {
state.fencedChars = match[1]
// try switching mode
state.localMode = getMode(match[2]);
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
state.f = state.block = local;
state.formatting = "math";
state.math = -1
return getType(state);
}
return switchInline(stream, state, state.inline);
}
function htmlBlock(stream, state) {
var style = htmlMode.token(stream, state.htmlState);
if (!htmlModeMissing) {
var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
(!inner.state.context && inner.state.tokenize.isInText)) ||
(state.md_inside && stream.current().indexOf(">") > -1)) {
state.f = inlineNormal;
state.block = blockNormal;
state.htmlState = null;
}
}
return style;
}
function local(stream, state) {
if (state.fencedChars && stream.match(state.fencedChars, false)) {
state.localMode = state.localState = null;
state.f = state.block = leavingLocal;
return null;
} else if (state.localMode) {
return state.localMode.token(stream, state.localState);
} else {
stream.skipToEnd();
if (state.math === -1) {
return tokenTypes.math;
}
return tokenTypes.code;
}
}
function leavingLocal(stream, state) {
stream.match(state.fencedChars);
state.block = blockNormal;
state.f = inlineNormal;
state.fencedChars = null;
if (state.math === -1) {
state.formatting = "math";
state.math = 1
var returnType = getType(state);
state.math = 0
return returnType;
}
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = 1
var returnType = getType(state);
state.code = 0
return returnType;
}
// Inline
function getType(state) {
var styles = [];
if (state.formatting) {
styles.push(tokenTypes.formatting);
if (typeof state.formatting === "string") state.formatting = [state.formatting];
for (var i = 0; i < state.formatting.length; i++) {
styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
if (state.formatting[i] === "header") {
styles.push(tokenTypes.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(tokenTypes.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(tokenTypes.linkHref, "url");
} else { // Only apply inline styles to non-url text
if (state.strong) { styles.push(tokenTypes.strong); }
if (state.em) { styles.push(tokenTypes.em); }
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); }
if (state.math) { styles.push(tokenTypes.math); }
if (state.image) { styles.push(tokenTypes.image); }
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
}
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
if (state.quote) {
styles.push(tokenTypes.quote);
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
styles.push(tokenTypes.quote + "-" + state.quote);
} else {
styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
}
}
if (state.list !== false) {
var listMod = (state.listStack.length - 1) % 3;
if (!listMod) {
styles.push(tokenTypes.list1);
} else if (listMod === 1) {
styles.push(tokenTypes.list2);
} else {
styles.push(tokenTypes.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();
// 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 tokenTypes.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";
stream.eatWhile('`');
var count = stream.current().length
if (state.code == 0) {
state.code = count
return getType(state)
} else if (count == state.code) { // Must be exact
var t = getType(state)
state.code = 0
return t
} else {
state.formatting = previousFormatting
return getType(state)
}
} else if (state.code) {
return getType(state);
}
// display math correctly
if (ch === '$') {
var previousFormatting = state.formatting;
state.formatting = "math";
stream.eatWhile('$');
var count = stream.current().length
if (state.math == 0) {
state.math = count
return getType(state)
} else if (count == state.math) { // Must be exact
var t = getType(state)
state.math = 0
return t
} else {
state.formatting = previousFormatting
return getType(state)
}
} else if (state.math) {
return getType(state);
}
if (ch === '\\') {
stream.next();
if (modeCfg.highlightFormatting) {
var type = getType(state);
var formattingEscape = tokenTypes.formatting + "-escape";
return type ? type + " " + formattingEscape : formattingEscape;
}
}
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
state.imageMarker = true;
state.image = true;
if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
}
if (ch === '[' && state.imageMarker) {
state.imageMarker = false;
state.imageAltText = true
if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
}
if (ch === ']' && state.imageAltText) {
if (modeCfg.highlightFormatting) state.formatting = "image";
var type = getType(state);
state.imageAltText = false;
state.image = false;
state.inline = state.f = linkHref;
return type;
}
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
state.linkText = true;
if (modeCfg.highlightFormatting) state.formatting = "link";
return getType(state);
}
if (ch === ']' && state.linkText && stream.match(/\(.*?\)| ?\[.*?\]/, false)) {
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 + tokenTypes.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 + tokenTypes.linkEmail;
}
if (ch === '<' && stream.match(/^(!--|\w)/, false)) {
var end = stream.string.indexOf(">", stream.pos);
if (end != -1) {
var atts = stream.string.substring(stream.start, end);
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 (modeCfg.strikethrough) {
if (ch === '~' && stream.eatWhile(ch)) {
if (state.strikethrough) {// Remove strikethrough
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
var t = getType(state);
state.strikethrough = false;
return t;
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
state.strikethrough = true;
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
return getType(state);
}
} else if (ch === ' ') {
if (stream.match(/^~~/, true)) { // Probably surrounded by space
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
return getType(state);
} else { // Not surrounded by spaces, back up pointer
stream.backUp(2);
}
}
}
}
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 + tokenTypes.linkInline;
}
stream.match(/^[^>]+/, true);
return tokenTypes.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 === "(" ? ")" : "]", 0);
if (modeCfg.highlightFormatting) state.formatting = "link-string";
state.linkHref = true;
return getType(state);
}
return 'error';
}
var linkRE = {
")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
"]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/
}
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;
}
stream.match(linkRE[endChar])
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 tokenTypes.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 tokenTypes.linkHref + " url";
}
var mode = {
startState: function() {
return {
f: blockNormal,
prevLine: null,
thisLine: null,
block: blockNormal,
htmlState: null,
indentation: 0,
inline: inlineNormal,
text: handleText,
formatting: false,
linkText: false,
linkHref: false,
linkTitle: false,
code: 0,
math: 0,
em: false,
strong: false,
header: 0,
hr: false,
taskList: false,
list: false,
listStack: [],
quote: 0,
trailingSpace: 0,
trailingSpaceNewLine: false,
strikethrough: false,
fencedChars: null
};
},
copyState: function(s) {
return {
f: s.f,
prevLine: s.prevLine,
thisLine: s.thisLine,
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,
code: s.code,
math: s.math,
em: s.em,
strong: s.strong,
strikethrough: s.strikethrough,
header: s.header,
hr: s.hr,
taskList: s.taskList,
list: s.list,
listStack: s.listStack.slice(0),
quote: s.quote,
indentedCode: s.indentedCode,
trailingSpace: s.trailingSpace,
trailingSpaceNewLine: s.trailingSpaceNewLine,
md_inside: s.md_inside,
fencedChars: s.fencedChars
};
},
token: function(stream, state) {
// Reset state.formatting
state.formatting = false;
if (stream != state.thisLine) {
var forceBlankLine = state.header || state.hr;
// Reset state.header and state.hr
state.header = 0;
state.hr = false;
if (stream.match(/^\s*$/, true) || forceBlankLine) {
blankLine(state);
if (!forceBlankLine) return null
state.prevLine = null
}
state.prevLine = state.thisLine
state.thisLine = stream
// Reset state.taskList
state.taskList = 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;
state.indentationDiff = Math.min(indentation - state.indentation, 4);
state.indentation = state.indentation + state.indentationDiff;
if (indentation > 0) return null;
}
return state.f(stream, state);
},
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");
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 86 B

View File

@@ -56,7 +56,7 @@
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"]},
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
{name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
@@ -66,7 +66,7 @@
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
{name: "HTTP", mime: "message/http", mode: "http"},
{name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],

View File

@@ -1,6 +1,6 @@
<!doctype html>
<title>CodeMirror: Jade Templating Mode</title>
<title>CodeMirror: Pug Templating Mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
@@ -10,7 +10,7 @@
<script src="../css/css.js"></script>
<script src="../xml/xml.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="jade.js"></script>
<script src="pug.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"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
@@ -22,17 +22,17 @@
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Jade Templating Mode</a>
<li><a class=active href="#">Pug Templating Mode</a>
</ul>
</div>
<article>
<h2>Jade Templating Mode</h2>
<h2>Pug Templating Mode</h2>
<form><textarea id="code" name="code">
doctype html
html
head
title= "Jade Templating CodeMirror Mode Example"
title= "Pug Templating CodeMirror Mode Example"
link(rel='stylesheet', href='/css/bootstrap.min.css')
link(rel='stylesheet', href='/css/index.css')
script(type='text/javascript', src='/js/jquery-1.9.1.min.js')
@@ -60,11 +60,11 @@ doctype html
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {name: "jade", alignCDATA: true},
mode: {name: "pug", alignCDATA: true},
lineNumbers: true
});
</script>
<h3>The Jade Templating Mode</h3>
<h3>The Pug Templating Mode</h3>
<p> Created by Forbes Lindesay. Managed as part of a Brackets extension at <a href="https://github.com/ForbesLindesay/jade-brackets">https://github.com/ForbesLindesay/jade-brackets</a>.</p>
<p><strong>MIME type defined:</strong> <code>text/x-jade</code>.</p>
<p><strong>MIME type defined:</strong> <code>text/x-pug</code>, <code>text/x-jade</code>.</p>
</article>

View File

@@ -11,7 +11,7 @@
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode('jade', function (config) {
CodeMirror.defineMode("pug", function (config) {
// token types
var KEYWORD = 'keyword';
var DOCTYPE = 'meta';
@@ -585,6 +585,7 @@ CodeMirror.defineMode('jade', function (config) {
};
}, 'javascript', 'css', 'htmlmixed');
CodeMirror.defineMIME('text/x-jade', 'jade');
CodeMirror.defineMIME('text/x-pug', 'pug');
CodeMirror.defineMIME('text/x-jade', 'pug');
});

View File

@@ -176,7 +176,7 @@ def pairwise_cython(double[:, ::1] X):
</script>
<h2>Configuration Options for Python mode:</h2>
<ul>
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
<li>version - 2/3 - The version of Python to recognize. Default is 3.</li>
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
<li>hangingIndent - int - If you want to write long arguments to a function starting on a new line, how much that line should be indented. Defaults to one normal indentation unit.</li>
</ul>

View File

@@ -55,7 +55,7 @@
if (parserConf.extra_builtins != undefined)
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
var py3 = parserConf.version && parseInt(parserConf.version, 10) == 3
var py3 = !(parserConf.version && Number(parserConf.version) < 3)
if (py3) {
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
var singleOperators = parserConf.singleOperators || /^[\+\-\*\/%&|\^~<>!@]/;
@@ -185,7 +185,7 @@
}
function tokenStringFactory(delimiter) {
while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
delimiter = delimiter.substr(1);
var singleline = delimiter.length == 1;

71
public/vendor/codemirror/mode/sas/sas.js vendored Executable file → Normal file
View File

@@ -137,12 +137,13 @@
stream.next();
return 'comment';
}
} else if (!state.continueString && (ch === '"' || ch === "'")) {
// Have we found a string?
state.continueString = ch; //save the matching quote in the state
return "string";
} else if (state.continueString !== null) {
if (stream.skipTo(state.continueString)) {
} else if ((ch === '"' || ch === "'") && !state.continueString) {
state.continueString = ch
return "string"
} else if (state.continueString) {
if (state.continueString == ch) {
state.continueString = null;
} else if (stream.skipTo(state.continueString)) {
// quote found on this line
stream.next();
state.continueString = null;
@@ -187,12 +188,12 @@
if (stream.peek() === '.') stream.skipTo(' ');
state.nextword = false;
return 'variable-2';
}
word = word.toLowerCase()
// Are we in a DATA Step?
if (state.inDataStep) {
if (word.toLowerCase() === 'run;' || stream.match(/run\s;/)) {
if (word === 'run;' || stream.match(/run\s;/)) {
state.inDataStep = false;
return 'builtin';
}
@@ -203,84 +204,84 @@
else return 'variable';
}
// do we have a DATA Step keyword
if (word && words.hasOwnProperty(word.toLowerCase()) &&
(words[word.toLowerCase()].state.indexOf("inDataStep") !== -1 ||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
if (word && words.hasOwnProperty(word) &&
(words[word].state.indexOf("inDataStep") !== -1 ||
words[word].state.indexOf("ALL") !== -1)) {
//backup to the start of the word
if (stream.start < stream.pos)
stream.backUp(stream.pos - stream.start);
//advance the length of the word and return
for (var i = 0; i < word.length; ++i) stream.next();
return words[word.toLowerCase()].style;
return words[word].style;
}
}
// Are we in an Proc statement?
if (state.inProc) {
if (word.toLowerCase() === 'run;' || word.toLowerCase() === 'quit;') {
if (word === 'run;' || word === 'quit;') {
state.inProc = false;
return 'builtin';
}
// do we have a proc keyword
if (word && words.hasOwnProperty(word.toLowerCase()) &&
(words[word.toLowerCase()].state.indexOf("inProc") !== -1 ||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
if (word && words.hasOwnProperty(word) &&
(words[word].state.indexOf("inProc") !== -1 ||
words[word].state.indexOf("ALL") !== -1)) {
stream.match(/[\w]+/);
return words[word].style;
}
}
// Are we in a Macro statement?
if (state.inMacro) {
if (word.toLowerCase() === '%mend') {
if (word === '%mend') {
if (stream.peek() === ';') stream.next();
state.inMacro = false;
return 'builtin';
}
if (word && words.hasOwnProperty(word.toLowerCase()) &&
(words[word.toLowerCase()].state.indexOf("inMacro") !== -1 ||
words[word.toLowerCase()].state.indexOf("ALL") !== -1)) {
if (word && words.hasOwnProperty(word) &&
(words[word].state.indexOf("inMacro") !== -1 ||
words[word].state.indexOf("ALL") !== -1)) {
stream.match(/[\w]+/);
return words[word.toLowerCase()].style;
return words[word].style;
}
return 'atom';
}
// Do we have Keywords specific words?
if (word && words.hasOwnProperty(word.toLowerCase())) {
if (word && words.hasOwnProperty(word)) {
// Negates the initial next()
stream.backUp(1);
// Actually move the stream
stream.match(/[\w]+/);
if (word.toLowerCase() === 'data' && /=/.test(stream.peek()) === false) {
if (word === 'data' && /=/.test(stream.peek()) === false) {
state.inDataStep = true;
state.nextword = true;
return 'builtin';
}
if (word.toLowerCase() === 'proc') {
if (word === 'proc') {
state.inProc = true;
state.nextword = true;
return 'builtin';
}
if (word.toLowerCase() === '%macro') {
if (word === '%macro') {
state.inMacro = true;
state.nextword = true;
return 'builtin';
}
if (/title[1-9]/i.test(word)) return 'def';
if (/title[1-9]/.test(word)) return 'def';
if (word.toLowerCase() === 'footnote') {
if (word === 'footnote') {
stream.eat(/[1-9]/);
return 'def';
}
// Returns their value as state in the prior define methods
if (state.inDataStep === true && words[word.toLowerCase()].state.indexOf("inDataStep") !== -1)
return words[word.toLowerCase()].style;
if (state.inProc === true && words[word.toLowerCase()].state.indexOf("inProc") !== -1)
return words[word.toLowerCase()].style;
if (state.inMacro === true && words[word.toLowerCase()].state.indexOf("inMacro") !== -1)
return words[word.toLowerCase()].style;
if (words[word.toLowerCase()].state.indexOf("ALL") !== -1)
return words[word.toLowerCase()].style;
if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1)
return words[word].style;
if (state.inProc === true && words[word].state.indexOf("inProc") !== -1)
return words[word].style;
if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1)
return words[word].style;
if (words[word].state.indexOf("ALL") !== -1)
return words[word].style;
return null;
}
// Unrecognized syntax

View File

@@ -14,7 +14,7 @@
<script src="../css/css.js"></script>
<script src="../coffeescript/coffeescript.js"></script>
<script src="../sass/sass.js"></script>
<script src="../jade/jade.js"></script>
<script src="../pug/pug.js"></script>
<script src="../handlebars/handlebars.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>

View File

@@ -12,7 +12,7 @@
require("../css/css"),
require("../sass/sass"),
require("../stylus/stylus"),
require("../jade/jade"),
require("../pug/pug"),
require("../handlebars/handlebars"));
} else if (typeof define === "function" && define.amd) { // AMD
define(["../../lib/codemirror",
@@ -23,7 +23,7 @@
"../css/css",
"../sass/sass",
"../stylus/stylus",
"../jade/jade",
"../pug/pug",
"../handlebars/handlebars"], mod);
} else { // Plain browser env
mod(CodeMirror);
@@ -42,9 +42,9 @@
],
template: [
["lang", /^vue-template$/i, "vue"],
["lang", /^jade$/i, "jade"],
["lang", /^pug$/i, "pug"],
["lang", /^handlebars$/i, "handlebars"],
["type", /^(text\/)?(x-)?jade$/i, "jade"],
["type", /^(text\/)?(x-)?pug$/i, "pug"],
["type", /^text\/x-handlebars-template$/i, "handlebars"],
[null, null, "vue-template"]
]
@@ -63,7 +63,7 @@
CodeMirror.defineMode("vue", function (config) {
return CodeMirror.getMode(config, {name: "htmlmixed", tags: tagLanguages});
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "jade", "handlebars");
}, "htmlmixed", "xml", "javascript", "coffeescript", "css", "sass", "stylus", "pug", "handlebars");
CodeMirror.defineMIME("script/x-vue", "vue");
});

View File

@@ -1,94 +1,85 @@
/*
Name: Panda Syntax
Author: Siamak Mokhtari (http://github.com/siamak/)
CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
*/
.cm-s-panda-syntax {
/*font-family: 'Operator Mono', 'Source Sans Pro', Helvetica, Arial, sans-serif;*/
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
background: #292A2B;
color: #E6E6E6;
line-height: 1.5;
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
}
.cm-s-panda-syntax .CodeMirror-cursor { border-color: #ff2c6d; }
.cm-s-panda-syntax .CodeMirror-activeline-background {
background: #404954;
background: rgba(99, 123, 156, 0.1);
}
.cm-s-panda-syntax .CodeMirror-selected {
background: #FFF;
}
.cm-s-panda-syntax .cm-comment {
font-style: italic;
color: #676B79;
}
.cm-s-panda-syntax .cm-string,
.cm-s-panda-syntax .cm-string-2 {
.cm-s-panda-syntax .cm-operator {
color: #f3f3f3;
}
.cm-s-panda-syntax .cm-string {
color: #19F9D8;
}
.cm-s-panda-syntax .cm-string-2 {
color: #FFB86C;
}
.cm-s-panda-syntax .cm-tag {
color: #ff2c6d;
}
.cm-s-panda-syntax .cm-meta {
color: #b084eb;
}
.cm-s-panda-syntax .cm-number {
color: #FFB86C;
}
.cm-s-panda-syntax .cm-atom {
color: #FFB86C;
color: #ff2c6d;
}
.cm-s-panda-syntax .cm-keyword {
color: #FF75B5;
}
.cm-s-panda-syntax .cm-keyword-2 {
color: #FF75B5;
}
.cm-s-panda-syntax .cm-keyword-3 {
color: #B084EB;
}
.cm-s-panda-syntax .cm-variable {
color: #FF9AC1;
color: #ffb86c;
}
.cm-s-panda-syntax .cm-variable-2 {
color: #e6e6e6;
color: #ff9ac1;
}
.cm-s-panda-syntax .cm-variable-3 {
color: #82B1FF;
color: #ff9ac1;
}
.cm-s-panda-syntax .cm-def {
/*font-style: italic;*/
color: #e6e6e6;
}
.cm-s-panda-syntax .cm-def-2 {
font-style: italic;
color: #ffcc95;
}
.cm-s-panda-syntax .cm-property {
color: #6FC1FF;
color: #f3f3f3;
}
.cm-s-panda-syntax .cm-unit {
color: #ffb86c;
}
.cm-s-panda-syntax .cm-matchingbracket,
.CodeMirror .CodeMirror-matchingbracket {
color: #E6E6E6 !important;
border-bottom: 1px dotted #19f9d8;
padding-bottom: 2px;
.cm-s-panda-syntax .cm-attribute {
color: #ffb86c;
}
.cm-s-panda-syntax .CodeMirror-gutters {
background: #292A2B;
color: #757575;
border: none;
.cm-s-panda-syntax .CodeMirror-matchingbracket {
border-bottom: 1px dotted #19F9D8;
padding-bottom: 2px;
color: #e6e6e6;
}
.cm-s-panda-syntax .CodeMirror-guttermarker, .cm-s-panda-syntax .CodeMirror-guttermarker-subtle, .cm-s-panda-syntax .CodeMirror-linenumber {
color: #757575;
.CodeMirror-gutters {
background: #292a2b;
border-right-color: rgba(255, 255, 255, 0.1);
}
.cm-s-panda-syntax .CodeMirror-linenumber {
padding-right: 10px;
.CodeMirror-linenumber {
color: #e6e6e6;
opacity: 0.6;
}
.cm-s-panda-syntax .CodeMirror-cursor {
border-left: 1px solid #757575;
}
/*.cm-s-panda-syntax div.CodeMirror-selected { background: rgba(255, 255, 255, 0.5); }*/
.cm-s-panda-syntax.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.25); }
.cm-s-panda-syntax .CodeMirror-line::selection, .cm-s-panda-syntax .CodeMirror-line > span::selection, .cm-s-panda-syntax .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-panda-syntax .CodeMirror-line::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-panda-syntax .CodeMirror-activeline-background { background: rgba(99, 123, 156, 0.125); }

View File

@@ -11,7 +11,6 @@
background: #2c2827;
color: #8F938F;
line-height: 1.5;
font-size: 14px;
}
.cm-s-pastel-on-dark div.CodeMirror-selected { background: rgba(221,240,255,0.2); }
.cm-s-pastel-on-dark .CodeMirror-line::selection, .cm-s-pastel-on-dark .CodeMirror-line > span::selection, .cm-s-pastel-on-dark .CodeMirror-line > span > span::selection { background: rgba(221,240,255,0.2); }

View File

@@ -155,8 +155,8 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
.cm-s-solarized .CodeMirror-cursor { border-left: 1px solid #819090; }
/* Fat cursor */
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #fdf6e3; }
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #fdf6e3; }
.cm-s-solarized.cm-s-light.cm-fat-cursor .CodeMirror-cursor { background: #77ee77; }
.cm-s-solarized.cm-s-light .cm-animate-fat-cursor { background-color: #77ee77; }
.cm-s-solarized.cm-s-dark.cm-fat-cursor .CodeMirror-cursor { background: #586e75; }
.cm-s-solarized.cm-s-dark .cm-animate-fat-cursor { background-color: #586e75; }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Some files were not shown because too many files have changed in this diff Show More