fix #1533 syntax highlighting of markdown links
This commit is contained in:
parent
a4a30b6665
commit
ca1c27aa65
3 changed files with 33 additions and 9 deletions
|
|
@ -14,7 +14,7 @@ test: only space between #s is not a valid header
|
|||
# #
|
||||
|
||||
# test links [Cloud9 IDE](http://www.c9.io/) #
|
||||
* [demo](http://ajaxorg.github.com/ace/)
|
||||
* [demo](http://ajaxorg.github.com/ace/) [+](escape(\) ) [+](a "title") [+](a "space" )
|
||||
* usually *work* fine (_em_)
|
||||
in lists
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,26 @@
|
|||
["text","]("],
|
||||
["markup.underline","http://ajaxorg.github.com/ace/"],
|
||||
["text",")"],
|
||||
["list"," "]
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","escape(\\) "],
|
||||
["text",")"],
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","a"],
|
||||
["string"," \"title\""],
|
||||
["text",")"],
|
||||
["list"," "],
|
||||
["text","["],
|
||||
["string","+"],
|
||||
["text","]("],
|
||||
["markup.underline","a"],
|
||||
["string"," \"space\" "],
|
||||
["text",")"]
|
||||
],[
|
||||
"listblock",
|
||||
["markup.list","* "],
|
||||
|
|
|
|||
|
|
@ -32,12 +32,17 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
|
||||
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
|
||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
||||
|
||||
var escaped = function(ch) {
|
||||
return "(?:[^" + lang.escapeRegExp(ch) + "\\\\]|\\\\.)*";
|
||||
}
|
||||
|
||||
function github_embed(tag, prefix) {
|
||||
return { // Github style block
|
||||
token : "support.function",
|
||||
|
|
@ -104,15 +109,15 @@ var MarkdownHighlightRules = function() {
|
|||
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
|
||||
}, { // link by reference
|
||||
token : ["text", "string", "text", "constant", "text"],
|
||||
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
|
||||
regex : "(\\[)(" + escaped("]") + ")(\\]\s*\\[)("+ escaped("]") + ")(\\])"
|
||||
}, { // link by url
|
||||
token : ["text", "string", "text", "markup.underline", "string", "text"],
|
||||
regex : "(\\[)"+
|
||||
"(\\[[^\\]]*\\]|[^\\[\\]]*)"+
|
||||
"(\\]\\([ \\t]*)"+
|
||||
"(<?(?:(?:[^\\(]*?\\([^\\)]*?\\)\\S*?)|(?:.*?))>?)"+
|
||||
"((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+
|
||||
"(\\))"
|
||||
regex : "(\\[)(" + // [
|
||||
escaped("]") + // link text
|
||||
")(\\]\\()"+ // ](
|
||||
'((?:[^\\)\\s\\\\]|\\\\.|\\s(?=[^"]))*)' + // href
|
||||
'(\\s*"' + escaped('"') + '"\\s*)?' + // "title"
|
||||
"(\\))" // )
|
||||
}, { // strong ** __
|
||||
token : "string",
|
||||
regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue