Remove unused vendor code and add fix related usages
This commit is contained in:
parent
276d500406
commit
92f2a4acf0
4 changed files with 2 additions and 3361 deletions
|
@ -903,7 +903,7 @@ md.use(require('markdown-it-mark'));
|
|||
md.use(require('markdown-it-ins'));
|
||||
md.use(require('markdown-it-sub'));
|
||||
md.use(require('markdown-it-sup'));
|
||||
md.use(require('../vendor/markdown-it-mathjax'));
|
||||
md.use(require('markdown-it-mathjax'));
|
||||
md.use(require('markdown-it-imsize'));
|
||||
|
||||
md.use(require('markdown-it-emoji'), {
|
||||
|
@ -980,7 +980,7 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
|
|||
};
|
||||
|
||||
/* Defined regex markdown it plugins */
|
||||
require('script!../vendor/markdown-it-regexp');
|
||||
var Plugin = require('markdown-it-regexp');
|
||||
|
||||
//youtube
|
||||
var youtubePlugin = new Plugin(
|
||||
|
|
3116
public/vendor/markdown-it-imsize.js
vendored
3116
public/vendor/markdown-it-imsize.js
vendored
File diff suppressed because it is too large
Load diff
126
public/vendor/markdown-it-mathjax.js
vendored
126
public/vendor/markdown-it-mathjax.js
vendored
|
@ -1,126 +0,0 @@
|
|||
// modified from https://github.com/classeur/markdown-it-mathjax
|
||||
|
||||
(function(root, factory) {
|
||||
if (typeof exports === 'object') {
|
||||
module.exports = factory()
|
||||
} else {
|
||||
root.markdownitMathjax = factory()
|
||||
}
|
||||
})(this, function() {
|
||||
function math(state, silent) {
|
||||
if (state.md.meta.mathjax === false) {
|
||||
return false
|
||||
}
|
||||
var startMathPos = state.pos
|
||||
if (state.src.charCodeAt(startMathPos) !== 0x5C /* \ */) {
|
||||
return false
|
||||
}
|
||||
var match = state.src.slice(++startMathPos).match(/^(?:\\\[|\\\(|begin\{([^}]*)\})/)
|
||||
if (!match) {
|
||||
return false
|
||||
}
|
||||
startMathPos += match[0].length
|
||||
var type, endMarker, includeMarkers
|
||||
if (match[0] === '\\[') {
|
||||
type = 'display_math'
|
||||
endMarker = '\\\\]'
|
||||
} else if (match[0] === '\\(') {
|
||||
type = 'inline_math'
|
||||
endMarker = '\\\\)'
|
||||
} else if (match[1]) {
|
||||
type = 'math'
|
||||
endMarker = '\\end{' + match[1] + '}'
|
||||
includeMarkers = true
|
||||
}
|
||||
var endMarkerPos = state.src.indexOf(endMarker, startMathPos)
|
||||
if (endMarkerPos === -1) {
|
||||
return false
|
||||
}
|
||||
var nextPos = endMarkerPos + endMarker.length
|
||||
if (!silent) {
|
||||
var token = state.push(type + '_open', 'span', 1);
|
||||
token.attrs = [ ['class', 'mathjax raw'] ];
|
||||
token = state.push(type, '', 0);
|
||||
token.content = includeMarkers ?
|
||||
state.src.slice(state.pos, nextPos) : state.src.slice(startMathPos, endMarkerPos)
|
||||
token = state.push(type + '_close', 'span', -1);
|
||||
}
|
||||
state.pos = nextPos
|
||||
return true
|
||||
}
|
||||
|
||||
function texMath(state, silent) {
|
||||
if (state.md.meta.mathjax === false) {
|
||||
return false
|
||||
}
|
||||
var startMathPos = state.pos
|
||||
if (state.src.charCodeAt(startMathPos) !== 0x24 /* $ */) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Parse tex math according to http://pandoc.org/README.html#math
|
||||
var endMarker = '$'
|
||||
var afterStartMarker = state.src.charCodeAt(++startMathPos)
|
||||
if (afterStartMarker === 0x24 /* $ */) {
|
||||
endMarker = '$$'
|
||||
if (state.src.charCodeAt(++startMathPos) === 0x24 /* $ */) {
|
||||
// 3 markers are too much
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
// Skip if opening $ is succeeded by a space character
|
||||
if (afterStartMarker === 0x20 /* space */ || afterStartMarker === 0x09 /* \t */ || afterStartMarker === 0x0a /* \n */) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
var endMarkerPos = state.src.indexOf(endMarker, startMathPos)
|
||||
if (endMarkerPos === -1) {
|
||||
return false
|
||||
}
|
||||
if (state.src.charCodeAt(endMarkerPos - 1) === 0x5C /* \ */) {
|
||||
return false
|
||||
}
|
||||
var nextPos = endMarkerPos + endMarker.length
|
||||
if (endMarker.length === 1) {
|
||||
// Skip if $ is preceded by a space character
|
||||
var beforeEndMarker = state.src.charCodeAt(endMarkerPos - 1)
|
||||
if (beforeEndMarker === 0x20 /* space */ || beforeEndMarker === 0x09 /* \t */ || beforeEndMarker === 0x0a /* \n */) {
|
||||
return false
|
||||
}
|
||||
// Skip if closing $ is succeeded by a digit (eg $5 $10 ...)
|
||||
var suffix = state.src.charCodeAt(nextPos)
|
||||
if (suffix >= 0x30 && suffix < 0x3A) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
var type = endMarker.length === 1 ? 'inline_math' : 'display_math';
|
||||
var token = state.push(type + '_open', 'span', 1)
|
||||
token.attrs = [ ['class', 'mathjax raw'] ]
|
||||
token = state.push(type, '', 0);
|
||||
token.content = state.src.slice(startMathPos, endMarkerPos);
|
||||
token = state.push(type + '_close', 'span', -1);
|
||||
}
|
||||
state.pos = nextPos
|
||||
return true
|
||||
}
|
||||
|
||||
function escapeHtml(html) {
|
||||
return html.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ')
|
||||
}
|
||||
|
||||
return function(md) {
|
||||
md.inline.ruler.before('escape', 'math', math)
|
||||
md.inline.ruler.push('texMath', texMath)
|
||||
md.renderer.rules.math = function(tokens, idx) {
|
||||
return escapeHtml(tokens[idx].content)
|
||||
}
|
||||
md.renderer.rules.inline_math = function(tokens, idx) {
|
||||
return '\\(' + escapeHtml(tokens[idx].content) + '\\)'
|
||||
}
|
||||
md.renderer.rules.display_math = function(tokens, idx) {
|
||||
return '\\[' + escapeHtml(tokens[idx].content) + '\\]'
|
||||
}
|
||||
}
|
||||
})
|
117
public/vendor/markdown-it-regexp.js
vendored
117
public/vendor/markdown-it-regexp.js
vendored
|
@ -1,117 +0,0 @@
|
|||
/*!
|
||||
* markdown-it-regexp
|
||||
* Copyright (c) 2014 Alex Kocharin
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var inherits = function(ctor, superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape special characters in the given string of html.
|
||||
*
|
||||
* Borrowed from escape-html component, MIT-licensed
|
||||
*/
|
||||
var stuff = {};
|
||||
stuff.escape = function(html) {
|
||||
return String(html)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
}
|
||||
|
||||
Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
|
||||
if (!isIE9()) {
|
||||
obj.__proto__ = proto;
|
||||
} else {
|
||||
/** IE9 fix - copy object methods from the protype to the new object **/
|
||||
for (var prop in proto) {
|
||||
obj[prop] = proto[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var isIE9 = function() {
|
||||
return navigator.appVersion.indexOf("MSIE") > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Counter for multi usage.
|
||||
*/
|
||||
var counter = 0
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*/
|
||||
|
||||
function Plugin(regexp, replacer) {
|
||||
// return value should be a callable function
|
||||
// with strictly defined options passed by markdown-it
|
||||
var self = function (md, options) {
|
||||
self.options = options
|
||||
self.init(md)
|
||||
}
|
||||
|
||||
// initialize plugin object
|
||||
Object.setPrototypeOf(self, Plugin.prototype)
|
||||
|
||||
// clone regexp with all the flags
|
||||
var flags = (regexp.global ? 'g' : '')
|
||||
+ (regexp.multiline ? 'm' : '')
|
||||
+ (regexp.ignoreCase ? 'i' : '')
|
||||
|
||||
self.regexp = RegExp('^' + regexp.source, flags)
|
||||
|
||||
// copy init options
|
||||
self.replacer = replacer
|
||||
|
||||
// this plugin can be inserted multiple times,
|
||||
// so we're generating unique name for it
|
||||
self.id = 'regexp-' + counter
|
||||
counter++
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
inherits(Plugin, Function)
|
||||
|
||||
// function that registers plugin with markdown-it
|
||||
Plugin.prototype.init = function (md) {
|
||||
md.inline.ruler.push(this.id, this.parse.bind(this))
|
||||
|
||||
md.renderer.rules[this.id] = this.render.bind(this)
|
||||
}
|
||||
|
||||
Plugin.prototype.parse = function (state, silent) {
|
||||
// slowwww... maybe use an advanced regexp engine for this
|
||||
var match = this.regexp.exec(state.src.slice(state.pos))
|
||||
if (!match) return false
|
||||
|
||||
// valid match found, now we need to advance cursor
|
||||
state.pos += match[0].length
|
||||
|
||||
// don't insert any tokens in silent mode
|
||||
if (silent) return true
|
||||
|
||||
var token = state.push(this.id, '', 0)
|
||||
token.meta = { match: match }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Plugin.prototype.render = function (tokens, id, options, env) {
|
||||
return this.replacer(tokens[id].meta.match, stuff)
|
||||
}
|
Loading…
Reference in a new issue