mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
add gfm with modified regex & improve link text handling
This commit is contained in:
@@ -65,7 +65,16 @@
|
|||||||
const className = el.className.split(' ')
|
const className = el.className.split(' ')
|
||||||
|
|
||||||
if (className.indexOf('cm-url') !== -1) {
|
if (className.indexOf('cm-url') !== -1) {
|
||||||
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(el.textContent)
|
// multiple cm-url because of search term
|
||||||
|
const cmUrlSpans = Array.from(
|
||||||
|
el.parentNode.getElementsByClassName('cm-url')
|
||||||
|
)
|
||||||
|
const textContent =
|
||||||
|
cmUrlSpans.length > 1
|
||||||
|
? cmUrlSpans.map(span => span.textContent).join('')
|
||||||
|
: el.textContent
|
||||||
|
|
||||||
|
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(textContent)
|
||||||
const url = match[1] || match[2] || match[3]
|
const url = match[1] || match[2] || match[3]
|
||||||
|
|
||||||
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
|
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
|
||||||
@@ -134,7 +143,16 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawHref = e.target.innerText.trim().slice(1, -1) // get link text from markdown text
|
// Create URL spans array used for special case "search term is hitting a link".
|
||||||
|
const cmUrlSpans = Array.from(
|
||||||
|
e.target.parentNode.getElementsByClassName('cm-url')
|
||||||
|
)
|
||||||
|
|
||||||
|
const innerText =
|
||||||
|
cmUrlSpans.length > 1
|
||||||
|
? cmUrlSpans.map(span => span.textContent).join('')
|
||||||
|
: e.target.innerText
|
||||||
|
const rawHref = innerText.trim().slice(1, -1) // get link text from markdown text
|
||||||
|
|
||||||
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
||||||
|
|
||||||
|
|||||||
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
@@ -1,10 +1,20 @@
|
|||||||
(function(mod) {
|
;(function(mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == 'object' && typeof module == 'object')
|
||||||
mod(require("../codemirror/lib/codemirror"), require("../codemirror/mode/gfm/gfm"), require("../codemirror/mode/yaml-frontmatter/yaml-frontmatter"))
|
// CommonJS
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
mod(
|
||||||
define(["../codemirror/lib/codemirror", "../codemirror/mode/gfm/gfm", "../codemirror/mode/yaml-frontmatter/yaml-frontmatter"], mod)
|
require('../codemirror/lib/codemirror'),
|
||||||
else // Plain browser env
|
require('../codemirror/mode/gfm/gfm'),
|
||||||
mod(CodeMirror)
|
require('../codemirror/mode/yaml-frontmatter/yaml-frontmatter')
|
||||||
|
)
|
||||||
|
else if (typeof define == 'function' && define.amd)
|
||||||
|
// AMD
|
||||||
|
define([
|
||||||
|
'../codemirror/lib/codemirror',
|
||||||
|
'../codemirror/mode/gfm/gfm',
|
||||||
|
'../codemirror/mode/yaml-frontmatter/yaml-frontmatter'
|
||||||
|
], mod)
|
||||||
|
// Plain browser env
|
||||||
|
else mod(CodeMirror)
|
||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
@@ -45,189 +55,208 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.defineMode('bfm', function (config, baseConfig) {
|
CodeMirror.defineMode(
|
||||||
baseConfig.name = 'yaml-frontmatter'
|
'bfm',
|
||||||
const baseMode = CodeMirror.getMode(config, baseConfig)
|
function(config, baseConfig) {
|
||||||
|
baseConfig.name = 'yaml-frontmatter'
|
||||||
|
const baseMode = CodeMirror.getMode(config, baseConfig)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startState: function() {
|
startState: function() {
|
||||||
return {
|
return {
|
||||||
baseState: CodeMirror.startState(baseMode),
|
baseState: CodeMirror.startState(baseMode),
|
||||||
|
|
||||||
basePos: 0,
|
basePos: 0,
|
||||||
baseCur: null,
|
baseCur: null,
|
||||||
overlayPos: 0,
|
overlayPos: 0,
|
||||||
overlayCur: null,
|
overlayCur: null,
|
||||||
streamSeen: null,
|
streamSeen: null,
|
||||||
|
|
||||||
fencedEndRE: null,
|
fencedEndRE: null,
|
||||||
|
|
||||||
inTable: false,
|
inTable: false,
|
||||||
rowIndex: 0
|
rowIndex: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
copyState: function(s) {
|
copyState: function(s) {
|
||||||
return {
|
return {
|
||||||
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
||||||
|
|
||||||
basePos: s.basePos,
|
basePos: s.basePos,
|
||||||
baseCur: null,
|
baseCur: null,
|
||||||
overlayPos: s.overlayPos,
|
overlayPos: s.overlayPos,
|
||||||
overlayCur: null,
|
overlayCur: null,
|
||||||
|
|
||||||
fencedMode: s.fencedMode,
|
fencedMode: s.fencedMode,
|
||||||
fencedState: s.fencedMode ? CodeMirror.copyState(s.fencedMode, s.fencedState) : null,
|
fencedState: s.fencedMode
|
||||||
|
? CodeMirror.copyState(s.fencedMode, s.fencedState)
|
||||||
|
: null,
|
||||||
|
|
||||||
fencedEndRE: s.fencedEndRE,
|
fencedEndRE: s.fencedEndRE,
|
||||||
|
|
||||||
inTable: s.inTable,
|
inTable: s.inTable,
|
||||||
rowIndex: s.rowIndex
|
rowIndex: s.rowIndex
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
token: function(stream, state) {
|
token: function(stream, state) {
|
||||||
const initialPos = stream.pos
|
const initialPos = stream.pos
|
||||||
|
|
||||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||||
state.fencedEndRE = null
|
state.fencedEndRE = null
|
||||||
state.fencedMode = null
|
state.fencedMode = null
|
||||||
state.fencedState = null
|
state.fencedState = null
|
||||||
|
|
||||||
stream.pos = initialPos
|
stream.pos = initialPos
|
||||||
}
|
} else {
|
||||||
else {
|
if (state.fencedMode) {
|
||||||
if (state.fencedMode) {
|
return state.fencedMode.token(stream, state.fencedState)
|
||||||
return state.fencedMode.token(stream, state.fencedState)
|
}
|
||||||
|
|
||||||
|
const match = stream.match(fencedCodeRE, true)
|
||||||
|
if (match) {
|
||||||
|
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||||
|
|
||||||
|
state.fencedMode = getMode(
|
||||||
|
match[2],
|
||||||
|
match[3],
|
||||||
|
config,
|
||||||
|
stream.lineOracle.doc.cm
|
||||||
|
)
|
||||||
|
if (state.fencedMode) {
|
||||||
|
state.fencedState = CodeMirror.startState(state.fencedMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.pos = initialPos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
stream != state.streamSeen ||
|
||||||
|
Math.min(state.basePos, state.overlayPos) < stream.start
|
||||||
|
) {
|
||||||
|
state.streamSeen = stream
|
||||||
|
state.basePos = state.overlayPos = stream.start
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream.start == state.basePos) {
|
||||||
|
state.baseCur = baseMode.token(stream, state.baseState)
|
||||||
|
state.basePos = stream.pos
|
||||||
|
}
|
||||||
|
if (stream.start == state.overlayPos) {
|
||||||
|
stream.pos = stream.start
|
||||||
|
state.overlayCur = this.overlayToken(stream, state)
|
||||||
|
state.overlayPos = stream.pos
|
||||||
|
}
|
||||||
|
stream.pos = Math.min(state.basePos, state.overlayPos)
|
||||||
|
|
||||||
|
if (state.overlayCur == null) {
|
||||||
|
return state.baseCur
|
||||||
|
} else if (state.baseCur != null && state.combineTokens) {
|
||||||
|
return state.baseCur + ' ' + state.overlayCur
|
||||||
|
} else {
|
||||||
|
return state.overlayCur
|
||||||
|
}
|
||||||
|
},
|
||||||
|
overlayToken: function(stream, state) {
|
||||||
|
state.combineTokens = false
|
||||||
|
|
||||||
|
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||||
|
state.fencedEndRE = null
|
||||||
|
state.localMode = null
|
||||||
|
state.localState = null
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.localMode) {
|
||||||
|
return state.localMode.token(stream, state.localState) || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = stream.match(fencedCodeRE, true)
|
const match = stream.match(fencedCodeRE, true)
|
||||||
if (match) {
|
if (match) {
|
||||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||||
|
|
||||||
state.fencedMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
state.localMode = getMode(
|
||||||
if (state.fencedMode) {
|
match[2],
|
||||||
state.fencedState = CodeMirror.startState(state.fencedMode)
|
match[3],
|
||||||
|
config,
|
||||||
|
stream.lineOracle.doc.cm
|
||||||
|
)
|
||||||
|
if (state.localMode) {
|
||||||
|
state.localState = CodeMirror.startState(state.localMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.pos = initialPos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream != state.streamSeen || Math.min(state.basePos, state.overlayPos) < stream.start) {
|
|
||||||
state.streamSeen = stream
|
|
||||||
state.basePos = state.overlayPos = stream.start
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream.start == state.basePos) {
|
|
||||||
state.baseCur = baseMode.token(stream, state.baseState)
|
|
||||||
state.basePos = stream.pos
|
|
||||||
}
|
|
||||||
if (stream.start == state.overlayPos) {
|
|
||||||
stream.pos = stream.start
|
|
||||||
state.overlayCur = this.overlayToken(stream, state)
|
|
||||||
state.overlayPos = stream.pos
|
|
||||||
}
|
|
||||||
stream.pos = Math.min(state.basePos, state.overlayPos)
|
|
||||||
|
|
||||||
if (state.overlayCur == null) {
|
|
||||||
return state.baseCur
|
|
||||||
}
|
|
||||||
else if (state.baseCur != null && state.combineTokens) {
|
|
||||||
return state.baseCur + ' ' + state.overlayCur
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return state.overlayCur
|
|
||||||
}
|
|
||||||
},
|
|
||||||
overlayToken: function(stream, state) {
|
|
||||||
state.combineTokens = false
|
|
||||||
|
|
||||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
|
||||||
state.fencedEndRE = null
|
|
||||||
state.localMode = null
|
|
||||||
state.localState = null
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.localMode) {
|
|
||||||
return state.localMode.token(stream, state.localState) || ''
|
|
||||||
}
|
|
||||||
|
|
||||||
const match = stream.match(fencedCodeRE, true)
|
|
||||||
if (match) {
|
|
||||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
|
||||||
|
|
||||||
state.localMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
|
||||||
if (state.localMode) {
|
|
||||||
state.localState = CodeMirror.startState(state.localMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
state.combineTokens = true
|
|
||||||
|
|
||||||
if (state.inTable) {
|
|
||||||
if (stream.match(/^\|/)) {
|
|
||||||
++state.rowIndex
|
|
||||||
|
|
||||||
stream.skipToEnd()
|
|
||||||
|
|
||||||
if (state.rowIndex === 1) {
|
|
||||||
return 'table table-separator'
|
|
||||||
} else if (state.rowIndex % 2 === 0) {
|
|
||||||
return 'table table-row table-row-even'
|
|
||||||
} else {
|
|
||||||
return 'table table-row table-row-odd'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state.inTable = false
|
|
||||||
|
|
||||||
stream.skipToEnd()
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
} else if (stream.match(/^\|/)) {
|
|
||||||
state.inTable = true
|
state.combineTokens = true
|
||||||
state.rowIndex = 0
|
|
||||||
|
if (state.inTable) {
|
||||||
|
if (stream.match(/^\|/)) {
|
||||||
|
++state.rowIndex
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
|
||||||
|
if (state.rowIndex === 1) {
|
||||||
|
return 'table table-separator'
|
||||||
|
} else if (state.rowIndex % 2 === 0) {
|
||||||
|
return 'table table-row table-row-even'
|
||||||
|
} else {
|
||||||
|
return 'table table-row table-row-odd'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.inTable = false
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
} else if (stream.match(/^\|/)) {
|
||||||
|
state.inTable = true
|
||||||
|
state.rowIndex = 0
|
||||||
|
|
||||||
|
stream.skipToEnd()
|
||||||
|
return 'table table-header'
|
||||||
|
}
|
||||||
|
|
||||||
stream.skipToEnd()
|
stream.skipToEnd()
|
||||||
return 'table table-header'
|
return null
|
||||||
}
|
},
|
||||||
|
electricChars: baseMode.electricChars,
|
||||||
stream.skipToEnd()
|
innerMode: function(state) {
|
||||||
return null
|
if (state.fencedMode) {
|
||||||
},
|
return {
|
||||||
electricChars: baseMode.electricChars,
|
mode: state.fencedMode,
|
||||||
innerMode: function(state) {
|
state: state.fencedState
|
||||||
if (state.fencedMode) {
|
}
|
||||||
return {
|
} else {
|
||||||
mode: state.fencedMode,
|
return {
|
||||||
state: state.fencedState
|
mode: baseMode,
|
||||||
|
state: state.baseState
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
return {
|
blankLine: function(state) {
|
||||||
mode: baseMode,
|
state.inTable = false
|
||||||
state: state.baseState
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
blankLine: function(state) {
|
|
||||||
state.inTable = false
|
|
||||||
|
|
||||||
if (state.fencedMode) {
|
if (state.fencedMode) {
|
||||||
return state.fencedMode.blankLine && state.fencedMode.blankLine(state.fencedState)
|
return (
|
||||||
} else {
|
state.fencedMode.blankLine &&
|
||||||
return baseMode.blankLine(state.baseState)
|
state.fencedMode.blankLine(state.fencedState)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return baseMode.blankLine(state.baseState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}, 'yaml-frontmatter')
|
'yaml-frontmatter'
|
||||||
|
)
|
||||||
|
|
||||||
CodeMirror.defineMIME('text/x-bfm', 'bfm')
|
CodeMirror.defineMIME('text/x-bfm', 'bfm')
|
||||||
|
|
||||||
CodeMirror.modeInfo.push({
|
CodeMirror.modeInfo.push({
|
||||||
name: "Boost Flavored Markdown",
|
name: 'Boost Flavored Markdown',
|
||||||
mime: "text/x-bfm",
|
mime: 'text/x-bfm',
|
||||||
mode: "bfm"
|
mode: 'bfm'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||||
|
|
||||||
|
;(function(mod) {
|
||||||
|
if (typeof exports == 'object' && typeof module == 'object')
|
||||||
|
// CommonJS
|
||||||
|
mod(
|
||||||
|
require('../codemirror/lib/codemirror'),
|
||||||
|
require('../codemirror/mode/markdown/markdown'),
|
||||||
|
require('../codemirror/addon/mode/overlay')
|
||||||
|
)
|
||||||
|
else if (typeof define == 'function' && define.amd)
|
||||||
|
// AMD
|
||||||
|
define([
|
||||||
|
'../codemirror/lib/codemirror',
|
||||||
|
'../codemirror/mode/markdown/markdown',
|
||||||
|
'../codemirror/addon/mode/overlay'
|
||||||
|
], mod)
|
||||||
|
// Plain browser env
|
||||||
|
else mod(CodeMirror)
|
||||||
|
})(function(CodeMirror) {
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
||||||
|
|
||||||
|
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 (modeConfig.gitHubSpice !== false) {
|
||||||
|
if (
|
||||||
|
stream.match(
|
||||||
|
/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[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(urlRE) &&
|
||||||
|
stream.string.slice(stream.start - 2, stream.start) != '](' &&
|
||||||
|
(stream.start == 0 ||
|
||||||
|
/\W/.test(stream.string.charAt(stream.start - 1)))
|
||||||
|
) {
|
||||||
|
// 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
|
||||||
|
// And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
|
||||||
|
state.combineTokens = true
|
||||||
|
return 'link'
|
||||||
|
}
|
||||||
|
stream.next()
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
blankLine: blankLine
|
||||||
|
}
|
||||||
|
|
||||||
|
var markdownConfig = {
|
||||||
|
taskLists: true,
|
||||||
|
strikethrough: true,
|
||||||
|
emoji: true
|
||||||
|
}
|
||||||
|
for (var attr in modeConfig) {
|
||||||
|
markdownConfig[attr] = modeConfig[attr]
|
||||||
|
}
|
||||||
|
markdownConfig.name = 'markdown'
|
||||||
|
return CodeMirror.overlayMode(
|
||||||
|
CodeMirror.getMode(config, markdownConfig),
|
||||||
|
gfmOverlay
|
||||||
|
)
|
||||||
|
},
|
||||||
|
'markdown'
|
||||||
|
)
|
||||||
|
|
||||||
|
CodeMirror.defineMIME('text/x-gfm', 'gfm')
|
||||||
|
})
|
||||||
@@ -108,12 +108,12 @@
|
|||||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
|
||||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||||
|
|
||||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||||
|
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||||
|
|
||||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||||
|
|||||||
@@ -104,12 +104,12 @@
|
|||||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
|
||||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||||
|
|
||||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||||
|
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||||
|
|
||||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user