From 4b0ca55eb79e963523eb6c8197825e9e8ae904e2 Mon Sep 17 00:00:00 2001
From: Wu Cheng-Han
Date: Mon, 4 May 2015 15:53:29 +0800
Subject: First commit, version 0.2.7
---
public/vendor/codemirror/mode/gfm/gfm.js | 123 ++++++++++++++++
public/vendor/codemirror/mode/gfm/index.html | 93 ++++++++++++
public/vendor/codemirror/mode/gfm/test.js | 213 +++++++++++++++++++++++++++
3 files changed, 429 insertions(+)
create mode 100755 public/vendor/codemirror/mode/gfm/gfm.js
create mode 100755 public/vendor/codemirror/mode/gfm/index.html
create mode 100755 public/vendor/codemirror/mode/gfm/test.js
(limited to 'public/vendor/codemirror/mode/gfm')
diff --git a/public/vendor/codemirror/mode/gfm/gfm.js b/public/vendor/codemirror/mode/gfm/gfm.js
new file mode 100755
index 00000000..80a8e2c8
--- /dev/null
+++ b/public/vendor/codemirror/mode/gfm/gfm.js
@@ -0,0 +1,123 @@
+// 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("../markdown/markdown"), require("../../addon/mode/overlay"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineMode("gfm", function(config, modeConfig) {
+ var codeDepth = 0;
+ function blankLine(state) {
+ state.code = false;
+ return null;
+ }
+ var gfmOverlay = {
+ startState: function() {
+ return {
+ code: false,
+ codeBlock: false,
+ ateSpace: false
+ };
+ },
+ copyState: function(s) {
+ return {
+ code: s.code,
+ codeBlock: s.codeBlock,
+ ateSpace: s.ateSpace
+ };
+ },
+ token: function(stream, state) {
+ state.combineTokens = null;
+
+ // Hack to prevent formatting override inside code blocks (block and inline)
+ if (state.codeBlock) {
+ if (stream.match(/^```/)) {
+ state.codeBlock = false;
+ return null;
+ }
+ stream.skipToEnd();
+ return null;
+ }
+ if (stream.sol()) {
+ state.code = false;
+ }
+ if (stream.sol() && stream.match(/^```/)) {
+ stream.skipToEnd();
+ state.codeBlock = true;
+ return null;
+ }
+ // If this block is changed, it may need to be updated in Markdown mode
+ if (stream.peek() === '`') {
+ stream.next();
+ var before = stream.pos;
+ stream.eatWhile('`');
+ var difference = 1 + stream.pos - before;
+ if (!state.code) {
+ codeDepth = difference;
+ state.code = true;
+ } else {
+ if (difference === codeDepth) { // Must be exact
+ state.code = false;
+ }
+ }
+ return null;
+ } else if (state.code) {
+ stream.next();
+ return null;
+ }
+ // Check if space. If so, links can be formatted later on
+ if (stream.eatSpace()) {
+ state.ateSpace = true;
+ return null;
+ }
+ if (stream.sol() || state.ateSpace) {
+ state.ateSpace = false;
+ if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
+ // User/Project@SHA
+ // User@SHA
+ // SHA
+ state.combineTokens = true;
+ return "link";
+ } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
+ // User/Project#Num
+ // User#Num
+ // #Num
+ state.combineTokens = true;
+ return "link";
+ }
+ }
+ if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i) &&
+ stream.string.slice(stream.start - 2, stream.start) != "](") {
+ // URLs
+ // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
+ // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
+ state.combineTokens = true;
+ return "link";
+ }
+ stream.next();
+ return null;
+ },
+ blankLine: blankLine
+ };
+
+ var markdownConfig = {
+ underscoresBreakWords: false,
+ taskLists: true,
+ fencedCodeBlocks: true,
+ strikethrough: true
+ };
+ for (var attr in modeConfig) {
+ markdownConfig[attr] = modeConfig[attr];
+ }
+ markdownConfig.name = "markdown";
+ CodeMirror.defineMIME("gfmBase", markdownConfig);
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
+}, "markdown");
+
+});
diff --git a/public/vendor/codemirror/mode/gfm/index.html b/public/vendor/codemirror/mode/gfm/index.html
new file mode 100755
index 00000000..7e38c52d
--- /dev/null
+++ b/public/vendor/codemirror/mode/gfm/index.html
@@ -0,0 +1,93 @@
+
+
+
CodeMirror: GFM mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+GFM mode
+
+
+
+
+ Optionally depends on other modes for properly highlighted code blocks.
+
+ Parsing/Highlighting Tests: normal, verbose.
+
+
diff --git a/public/vendor/codemirror/mode/gfm/test.js b/public/vendor/codemirror/mode/gfm/test.js
new file mode 100755
index 00000000..c2bc38fd
--- /dev/null
+++ b/public/vendor/codemirror/mode/gfm/test.js
@@ -0,0 +1,213 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function() {
+ var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+ var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "gfm", highlightFormatting: true});
+ function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
+
+ FT("codeBackticks",
+ "[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
+
+ FT("doubleBackticks",
+ "[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
+
+ FT("codeBlock",
+ "[comment&formatting&formatting-code-block ```css]",
+ "[tag foo]",
+ "[comment&formatting&formatting-code-block ```]");
+
+ FT("taskList",
+ "[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
+ "[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
+
+ FT("formatting_strikethrough",
+ "[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]");
+
+ FT("formatting_strikethrough",
+ "foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]");
+
+ MT("emInWordAsterisk",
+ "foo[em *bar*]hello");
+
+ MT("emInWordUnderscore",
+ "foo_bar_hello");
+
+ MT("emStrongUnderscore",
+ "[strong __][em&strong _foo__][em _] bar");
+
+ MT("fencedCodeBlocks",
+ "[comment ```]",
+ "[comment foo]",
+ "",
+ "[comment ```]",
+ "bar");
+
+ MT("fencedCodeBlockModeSwitching",
+ "[comment ```javascript]",
+ "[variable foo]",
+ "",
+ "[comment ```]",
+ "bar");
+
+ MT("taskListAsterisk",
+ "[variable-2 * []] foo]", // Invalid; must have space or x between []
+ "[variable-2 * [ ]]bar]", // Invalid; must have space after ]
+ "[variable-2 * [x]]hello]", // Invalid; must have space after ]
+ "[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
+ " [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
+
+ MT("taskListPlus",
+ "[variable-2 + []] foo]", // Invalid; must have space or x between []
+ "[variable-2 + [ ]]bar]", // Invalid; must have space after ]
+ "[variable-2 + [x]]hello]", // Invalid; must have space after ]
+ "[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
+ " [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
+
+ MT("taskListDash",
+ "[variable-2 - []] foo]", // Invalid; must have space or x between []
+ "[variable-2 - [ ]]bar]", // Invalid; must have space after ]
+ "[variable-2 - [x]]hello]", // Invalid; must have space after ]
+ "[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
+ " [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
+
+ MT("taskListNumber",
+ "[variable-2 1. []] foo]", // Invalid; must have space or x between []
+ "[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
+ "[variable-2 3. [x]]hello]", // Invalid; must have space after ]
+ "[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
+ " [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
+
+ MT("SHA",
+ "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
+
+ MT("SHAEmphasis",
+ "[em *foo ][em&link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
+ MT("shortSHA",
+ "foo [link be6a8cc] bar");
+
+ MT("tooShortSHA",
+ "foo be6a8c bar");
+
+ MT("longSHA",
+ "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
+
+ MT("badSHA",
+ "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
+
+ MT("userSHA",
+ "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
+
+ MT("userSHAEmphasis",
+ "[em *foo ][em&link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
+ MT("userProjectSHA",
+ "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
+
+ MT("userProjectSHAEmphasis",
+ "[em *foo ][em&link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2][em *]");
+
+ MT("num",
+ "foo [link #1] bar");
+
+ MT("numEmphasis",
+ "[em *foo ][em&link #1][em *]");
+
+ MT("badNum",
+ "foo #1bar hello");
+
+ MT("userNum",
+ "foo [link bar#1] hello");
+
+ MT("userNumEmphasis",
+ "[em *foo ][em&link bar#1][em *]");
+
+ MT("userProjectNum",
+ "foo [link bar/hello#1] world");
+
+ MT("userProjectNumEmphasis",
+ "[em *foo ][em&link bar/hello#1][em *]");
+
+ MT("vanillaLink",
+ "foo [link http://www.example.com/] bar");
+
+ MT("vanillaLinkPunctuation",
+ "foo [link http://www.example.com/]. bar");
+
+ MT("vanillaLinkExtension",
+ "foo [link http://www.example.com/index.html] bar");
+
+ MT("vanillaLinkEmphasis",
+ "foo [em *][em&link http://www.example.com/index.html][em *] bar");
+
+ MT("notALink",
+ "[comment ```css]",
+ "[tag foo] {[property color]:[keyword black];}",
+ "[comment ```][link http://www.example.com/]");
+
+ MT("notALink",
+ "[comment ``foo `bar` http://www.example.com/``] hello");
+
+ MT("notALink",
+ "[comment `foo]",
+ "[link http://www.example.com/]",
+ "[comment `foo]",
+ "",
+ "[link http://www.example.com/]");
+
+ MT("headerCodeBlockGithub",
+ "[header&header-1 # heading]",
+ "",
+ "[comment ```]",
+ "[comment code]",
+ "[comment ```]",
+ "",
+ "Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
+ "Issue: [link #1]",
+ "Link: [link http://www.example.com/]");
+
+ MT("strikethrough",
+ "[strikethrough ~~foo~~]");
+
+ MT("strikethroughWithStartingSpace",
+ "~~ foo~~");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo~~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar~~]hello");
+
+ MT("strikethroughOneLetter",
+ "[strikethrough ~~a~~]");
+
+ MT("strikethroughWrapped",
+ "[strikethrough ~~foo]",
+ "[strikethrough foo~~]");
+
+ MT("strikethroughParagraph",
+ "[strikethrough ~~foo]",
+ "",
+ "foo[strikethrough ~~bar]");
+
+ MT("strikethroughEm",
+ "[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]");
+
+ MT("strikethroughEm",
+ "[em *][em&strikethrough ~~foo~~][em *]");
+
+ MT("strikethroughStrong",
+ "[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]");
+
+ MT("strikethroughStrong",
+ "[strong **][strong&strikethrough ~~foo~~][strong **]");
+
+})();
--
cgit v1.2.3