completed import of 3rd party dependencies
This commit is contained in:
parent
4f485753fe
commit
0304307b8d
28 changed files with 6500 additions and 0 deletions
2
3rd/js/bootstrap-datetimepicker.min.js
vendored
Normal file
2
3rd/js/bootstrap-datetimepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
3rd/js/bootstrap.min.js
vendored
Normal file
7
3rd/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
3rd/js/defiant.min.js
vendored
Normal file
7
3rd/js/defiant.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
3rd/js/jquery-3.2.1.min.js
vendored
Normal file
4
3rd/js/jquery-3.2.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
3rd/js/jquery.loadTemplate.min.js
vendored
Normal file
1
3rd/js/jquery.loadTemplate.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4463
3rd/js/moment.js
Normal file
4463
3rd/js/moment.js
Normal file
File diff suppressed because it is too large
Load diff
480
3rd/js/nprogress.js
Normal file
480
3rd/js/nprogress.js
Normal file
|
|
@ -0,0 +1,480 @@
|
|||
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
|
||||
* @license MIT */
|
||||
|
||||
;(function(root, factory) {
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
root.NProgress = factory();
|
||||
}
|
||||
|
||||
})(this, function() {
|
||||
var NProgress = {};
|
||||
|
||||
NProgress.version = '0.2.0';
|
||||
|
||||
var Settings = NProgress.settings = {
|
||||
minimum: 0.08,
|
||||
easing: 'linear',
|
||||
positionUsing: '',
|
||||
speed: 200,
|
||||
trickle: true,
|
||||
trickleSpeed: 200,
|
||||
showSpinner: true,
|
||||
barSelector: '[role="bar"]',
|
||||
spinnerSelector: '[role="spinner"]',
|
||||
parent: 'body',
|
||||
template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates configuration.
|
||||
*
|
||||
* NProgress.configure({
|
||||
* minimum: 0.1
|
||||
* });
|
||||
*/
|
||||
NProgress.configure = function(options) {
|
||||
var key, value;
|
||||
for (key in options) {
|
||||
value = options[key];
|
||||
if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Last number.
|
||||
*/
|
||||
|
||||
NProgress.status = null;
|
||||
|
||||
/**
|
||||
* Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
|
||||
*
|
||||
* NProgress.set(0.4);
|
||||
* NProgress.set(1.0);
|
||||
*/
|
||||
|
||||
NProgress.set = function(n) {
|
||||
var started = NProgress.isStarted();
|
||||
|
||||
n = clamp(n, Settings.minimum, 1);
|
||||
NProgress.status = (n === 1 ? null : n);
|
||||
|
||||
var progress = NProgress.render(!started),
|
||||
bar = progress.querySelector(Settings.barSelector),
|
||||
speed = Settings.speed,
|
||||
ease = Settings.easing;
|
||||
|
||||
progress.offsetWidth; /* Repaint */
|
||||
|
||||
queue(function(next) {
|
||||
// Set positionUsing if it hasn't already been set
|
||||
if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
|
||||
|
||||
// Add transition
|
||||
css(bar, barPositionCSS(n, speed, ease));
|
||||
|
||||
if (n === 1) {
|
||||
// Fade out
|
||||
css(progress, {
|
||||
transition: 'none',
|
||||
opacity: 1
|
||||
});
|
||||
progress.offsetWidth; /* Repaint */
|
||||
|
||||
setTimeout(function() {
|
||||
css(progress, {
|
||||
transition: 'all ' + speed + 'ms linear',
|
||||
opacity: 0
|
||||
});
|
||||
setTimeout(function() {
|
||||
NProgress.remove();
|
||||
next();
|
||||
}, speed);
|
||||
}, speed);
|
||||
} else {
|
||||
setTimeout(next, speed);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
NProgress.isStarted = function() {
|
||||
return typeof NProgress.status === 'number';
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the progress bar.
|
||||
* This is the same as setting the status to 0%, except that it doesn't go backwards.
|
||||
*
|
||||
* NProgress.start();
|
||||
*
|
||||
*/
|
||||
NProgress.start = function() {
|
||||
if (!NProgress.status) NProgress.set(0);
|
||||
|
||||
var work = function() {
|
||||
setTimeout(function() {
|
||||
if (!NProgress.status) return;
|
||||
NProgress.trickle();
|
||||
work();
|
||||
}, Settings.trickleSpeed);
|
||||
};
|
||||
|
||||
if (Settings.trickle) work();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the progress bar.
|
||||
* This is the *sort of* the same as setting the status to 100%, with the
|
||||
* difference being `done()` makes some placebo effect of some realistic motion.
|
||||
*
|
||||
* NProgress.done();
|
||||
*
|
||||
* If `true` is passed, it will show the progress bar even if its hidden.
|
||||
*
|
||||
* NProgress.done(true);
|
||||
*/
|
||||
|
||||
NProgress.done = function(force) {
|
||||
if (!force && !NProgress.status) return this;
|
||||
|
||||
return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Increments by a random amount.
|
||||
*/
|
||||
|
||||
NProgress.inc = function(amount) {
|
||||
var n = NProgress.status;
|
||||
|
||||
if (!n) {
|
||||
return NProgress.start();
|
||||
} else if(n > 1) {
|
||||
return;
|
||||
} else {
|
||||
if (typeof amount !== 'number') {
|
||||
if (n >= 0 && n < 0.2) { amount = 0.1; }
|
||||
else if (n >= 0.2 && n < 0.5) { amount = 0.04; }
|
||||
else if (n >= 0.5 && n < 0.8) { amount = 0.02; }
|
||||
else if (n >= 0.8 && n < 0.99) { amount = 0.005; }
|
||||
else { amount = 0; }
|
||||
}
|
||||
|
||||
n = clamp(n + amount, 0, 0.994);
|
||||
return NProgress.set(n);
|
||||
}
|
||||
};
|
||||
|
||||
NProgress.trickle = function() {
|
||||
return NProgress.inc();
|
||||
};
|
||||
|
||||
/**
|
||||
* Waits for all supplied jQuery promises and
|
||||
* increases the progress as the promises resolve.
|
||||
*
|
||||
* @param $promise jQUery Promise
|
||||
*/
|
||||
(function() {
|
||||
var initial = 0, current = 0;
|
||||
|
||||
NProgress.promise = function($promise) {
|
||||
if (!$promise || $promise.state() === "resolved") {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (current === 0) {
|
||||
NProgress.start();
|
||||
}
|
||||
|
||||
initial++;
|
||||
current++;
|
||||
|
||||
$promise.always(function() {
|
||||
current--;
|
||||
if (current === 0) {
|
||||
initial = 0;
|
||||
NProgress.done();
|
||||
} else {
|
||||
NProgress.set((initial - current) / initial);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) renders the progress bar markup based on the `template`
|
||||
* setting.
|
||||
*/
|
||||
|
||||
NProgress.render = function(fromStart) {
|
||||
if (NProgress.isRendered()) return document.getElementById('nprogress');
|
||||
|
||||
addClass(document.documentElement, 'nprogress-busy');
|
||||
|
||||
var progress = document.createElement('div');
|
||||
progress.id = 'nprogress';
|
||||
progress.innerHTML = Settings.template;
|
||||
|
||||
var bar = progress.querySelector(Settings.barSelector),
|
||||
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
|
||||
parent = document.querySelector(Settings.parent),
|
||||
spinner;
|
||||
|
||||
css(bar, {
|
||||
transition: 'all 0 linear',
|
||||
transform: 'translate3d(' + perc + '%,0,0)'
|
||||
});
|
||||
|
||||
if (!Settings.showSpinner) {
|
||||
spinner = progress.querySelector(Settings.spinnerSelector);
|
||||
spinner && removeElement(spinner);
|
||||
}
|
||||
|
||||
if (parent != document.body) {
|
||||
addClass(parent, 'nprogress-custom-parent');
|
||||
}
|
||||
|
||||
parent.appendChild(progress);
|
||||
return progress;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the element. Opposite of render().
|
||||
*/
|
||||
|
||||
NProgress.remove = function() {
|
||||
removeClass(document.documentElement, 'nprogress-busy');
|
||||
removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
|
||||
var progress = document.getElementById('nprogress');
|
||||
progress && removeElement(progress);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the progress bar is rendered.
|
||||
*/
|
||||
|
||||
NProgress.isRendered = function() {
|
||||
return !!document.getElementById('nprogress');
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine which positioning CSS rule to use.
|
||||
*/
|
||||
|
||||
NProgress.getPositioningCSS = function() {
|
||||
// Sniff on document.body.style
|
||||
var bodyStyle = document.body.style;
|
||||
|
||||
// Sniff prefixes
|
||||
var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
|
||||
('MozTransform' in bodyStyle) ? 'Moz' :
|
||||
('msTransform' in bodyStyle) ? 'ms' :
|
||||
('OTransform' in bodyStyle) ? 'O' : '';
|
||||
|
||||
if (vendorPrefix + 'Perspective' in bodyStyle) {
|
||||
// Modern browsers with 3D support, e.g. Webkit, IE10
|
||||
return 'translate3d';
|
||||
} else if (vendorPrefix + 'Transform' in bodyStyle) {
|
||||
// Browsers without 3D support, e.g. IE9
|
||||
return 'translate';
|
||||
} else {
|
||||
// Browsers without translate() support, e.g. IE7-8
|
||||
return 'margin';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
function clamp(n, min, max) {
|
||||
if (n < min) return min;
|
||||
if (n > max) return max;
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) converts a percentage (`0..1`) to a bar translateX
|
||||
* percentage (`-100%..0%`).
|
||||
*/
|
||||
|
||||
function toBarPerc(n) {
|
||||
return (-1 + n) * 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (Internal) returns the correct CSS for changing the bar's
|
||||
* position given an n percentage, and speed and ease from Settings
|
||||
*/
|
||||
|
||||
function barPositionCSS(n, speed, ease) {
|
||||
var barCSS;
|
||||
|
||||
if (Settings.positionUsing === 'translate3d') {
|
||||
barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
|
||||
} else if (Settings.positionUsing === 'translate') {
|
||||
barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
|
||||
} else {
|
||||
barCSS = { 'margin-left': toBarPerc(n)+'%' };
|
||||
}
|
||||
|
||||
barCSS.transition = 'all '+speed+'ms '+ease;
|
||||
|
||||
return barCSS;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Queues a function to be executed.
|
||||
*/
|
||||
|
||||
var queue = (function() {
|
||||
var pending = [];
|
||||
|
||||
function next() {
|
||||
var fn = pending.shift();
|
||||
if (fn) {
|
||||
fn(next);
|
||||
}
|
||||
}
|
||||
|
||||
return function(fn) {
|
||||
pending.push(fn);
|
||||
if (pending.length == 1) next();
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) Applies css properties to an element, similar to the jQuery
|
||||
* css method.
|
||||
*
|
||||
* While this helper does assist with vendor prefixed property names, it
|
||||
* does not perform any manipulation of values prior to setting styles.
|
||||
*/
|
||||
|
||||
var css = (function() {
|
||||
var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
|
||||
cssProps = {};
|
||||
|
||||
function camelCase(string) {
|
||||
return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
|
||||
return letter.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function getVendorProp(name) {
|
||||
var style = document.body.style;
|
||||
if (name in style) return name;
|
||||
|
||||
var i = cssPrefixes.length,
|
||||
capName = name.charAt(0).toUpperCase() + name.slice(1),
|
||||
vendorName;
|
||||
while (i--) {
|
||||
vendorName = cssPrefixes[i] + capName;
|
||||
if (vendorName in style) return vendorName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function getStyleProp(name) {
|
||||
name = camelCase(name);
|
||||
return cssProps[name] || (cssProps[name] = getVendorProp(name));
|
||||
}
|
||||
|
||||
function applyCss(element, prop, value) {
|
||||
prop = getStyleProp(prop);
|
||||
element.style[prop] = value;
|
||||
}
|
||||
|
||||
return function(element, properties) {
|
||||
var args = arguments,
|
||||
prop,
|
||||
value;
|
||||
|
||||
if (args.length == 2) {
|
||||
for (prop in properties) {
|
||||
value = properties[prop];
|
||||
if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
|
||||
}
|
||||
} else {
|
||||
applyCss(element, args[1], args[2]);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) Determines if an element or space separated list of class names contains a class name.
|
||||
*/
|
||||
|
||||
function hasClass(element, name) {
|
||||
var list = typeof element == 'string' ? element : classList(element);
|
||||
return list.indexOf(' ' + name + ' ') >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Adds a class to an element.
|
||||
*/
|
||||
|
||||
function addClass(element, name) {
|
||||
var oldList = classList(element),
|
||||
newList = oldList + name;
|
||||
|
||||
if (hasClass(oldList, name)) return;
|
||||
|
||||
// Trim the opening space.
|
||||
element.className = newList.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Removes a class from an element.
|
||||
*/
|
||||
|
||||
function removeClass(element, name) {
|
||||
var oldList = classList(element),
|
||||
newList;
|
||||
|
||||
if (!hasClass(element, name)) return;
|
||||
|
||||
// Replace the class name.
|
||||
newList = oldList.replace(' ' + name + ' ', ' ');
|
||||
|
||||
// Trim the opening and closing spaces.
|
||||
element.className = newList.substring(1, newList.length - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Gets a space separated list of the class names on the element.
|
||||
* The list is wrapped with a single space on each end to facilitate finding
|
||||
* matches within the list.
|
||||
*/
|
||||
|
||||
function classList(element) {
|
||||
return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Removes an element from the DOM.
|
||||
*/
|
||||
|
||||
function removeElement(element) {
|
||||
element && element.parentNode && element.parentNode.removeChild(element);
|
||||
}
|
||||
|
||||
return NProgress;
|
||||
});
|
||||
789
3rd/js/to-markdown.js
Normal file
789
3rd/js/to-markdown.js
Normal file
|
|
@ -0,0 +1,789 @@
|
|||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.toMarkdown = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
/*
|
||||
* to-markdown - an HTML to Markdown converter
|
||||
*
|
||||
* Copyright 2011+, Dom Christie
|
||||
* Licenced under the MIT licence
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
var toMarkdown
|
||||
var converters
|
||||
var mdConverters = require('./lib/md-converters')
|
||||
var gfmConverters = require('./lib/gfm-converters')
|
||||
var HtmlParser = require('./lib/html-parser')
|
||||
var collapse = require('collapse-whitespace')
|
||||
|
||||
/*
|
||||
* Utilities
|
||||
*/
|
||||
|
||||
var blocks = ['address', 'article', 'aside', 'audio', 'blockquote', 'body',
|
||||
'canvas', 'center', 'dd', 'dir', 'div', 'dl', 'dt', 'fieldset', 'figcaption',
|
||||
'figure', 'footer', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
||||
'header', 'hgroup', 'hr', 'html', 'isindex', 'li', 'main', 'menu', 'nav',
|
||||
'noframes', 'noscript', 'ol', 'output', 'p', 'pre', 'section', 'table',
|
||||
'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul'
|
||||
]
|
||||
|
||||
function isBlock (node) {
|
||||
return blocks.indexOf(node.nodeName.toLowerCase()) !== -1
|
||||
}
|
||||
|
||||
var voids = [
|
||||
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
|
||||
'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'
|
||||
]
|
||||
|
||||
function isVoid (node) {
|
||||
return voids.indexOf(node.nodeName.toLowerCase()) !== -1
|
||||
}
|
||||
|
||||
function htmlToDom (string) {
|
||||
var tree = new HtmlParser().parseFromString(string, 'text/html')
|
||||
collapse(tree.documentElement, isBlock)
|
||||
return tree
|
||||
}
|
||||
|
||||
/*
|
||||
* Flattens DOM tree into single array
|
||||
*/
|
||||
|
||||
function bfsOrder (node) {
|
||||
var inqueue = [node]
|
||||
var outqueue = []
|
||||
var elem
|
||||
var children
|
||||
var i
|
||||
|
||||
while (inqueue.length > 0) {
|
||||
elem = inqueue.shift()
|
||||
outqueue.push(elem)
|
||||
children = elem.childNodes
|
||||
for (i = 0; i < children.length; i++) {
|
||||
if (children[i].nodeType === 1) inqueue.push(children[i])
|
||||
}
|
||||
}
|
||||
outqueue.shift()
|
||||
return outqueue
|
||||
}
|
||||
|
||||
/*
|
||||
* Contructs a Markdown string of replacement text for a given node
|
||||
*/
|
||||
|
||||
function getContent (node) {
|
||||
var text = ''
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
if (node.childNodes[i].nodeType === 1) {
|
||||
text += node.childNodes[i]._replacement
|
||||
} else if (node.childNodes[i].nodeType === 3) {
|
||||
text += node.childNodes[i].data
|
||||
} else continue
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the HTML string of an element with its contents converted
|
||||
*/
|
||||
|
||||
function outer (node, content) {
|
||||
return node.cloneNode(false).outerHTML.replace('><', '>' + content + '<')
|
||||
}
|
||||
|
||||
function canConvert (node, filter) {
|
||||
if (typeof filter === 'string') {
|
||||
return filter === node.nodeName.toLowerCase()
|
||||
}
|
||||
if (Array.isArray(filter)) {
|
||||
return filter.indexOf(node.nodeName.toLowerCase()) !== -1
|
||||
} else if (typeof filter === 'function') {
|
||||
return filter.call(toMarkdown, node)
|
||||
} else {
|
||||
throw new TypeError('`filter` needs to be a string, array, or function')
|
||||
}
|
||||
}
|
||||
|
||||
function isFlankedByWhitespace (side, node) {
|
||||
var sibling
|
||||
var regExp
|
||||
var isFlanked
|
||||
|
||||
if (side === 'left') {
|
||||
sibling = node.previousSibling
|
||||
regExp = / $/
|
||||
} else {
|
||||
sibling = node.nextSibling
|
||||
regExp = /^ /
|
||||
}
|
||||
|
||||
if (sibling) {
|
||||
if (sibling.nodeType === 3) {
|
||||
isFlanked = regExp.test(sibling.nodeValue)
|
||||
} else if (sibling.nodeType === 1 && !isBlock(sibling)) {
|
||||
isFlanked = regExp.test(sibling.textContent)
|
||||
}
|
||||
}
|
||||
return isFlanked
|
||||
}
|
||||
|
||||
function flankingWhitespace (node, content) {
|
||||
var leading = ''
|
||||
var trailing = ''
|
||||
|
||||
if (!isBlock(node)) {
|
||||
var hasLeading = /^[ \r\n\t]/.test(content)
|
||||
var hasTrailing = /[ \r\n\t]$/.test(content)
|
||||
|
||||
if (hasLeading && !isFlankedByWhitespace('left', node)) {
|
||||
leading = ' '
|
||||
}
|
||||
if (hasTrailing && !isFlankedByWhitespace('right', node)) {
|
||||
trailing = ' '
|
||||
}
|
||||
}
|
||||
|
||||
return { leading: leading, trailing: trailing }
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds a Markdown converter, gets the replacement, and sets it on
|
||||
* `_replacement`
|
||||
*/
|
||||
|
||||
function process (node) {
|
||||
var replacement
|
||||
var content = getContent(node)
|
||||
|
||||
// Remove blank nodes
|
||||
if (!isVoid(node) && !/A|TH|TD/.test(node.nodeName) && /^\s*$/i.test(content)) {
|
||||
node._replacement = ''
|
||||
return
|
||||
}
|
||||
|
||||
for (var i = 0; i < converters.length; i++) {
|
||||
var converter = converters[i]
|
||||
|
||||
if (canConvert(node, converter.filter)) {
|
||||
if (typeof converter.replacement !== 'function') {
|
||||
throw new TypeError(
|
||||
'`replacement` needs to be a function that returns a string'
|
||||
)
|
||||
}
|
||||
|
||||
var whitespace = flankingWhitespace(node, content)
|
||||
|
||||
if (whitespace.leading || whitespace.trailing) {
|
||||
content = content.trim()
|
||||
}
|
||||
replacement = whitespace.leading +
|
||||
converter.replacement.call(toMarkdown, content, node) +
|
||||
whitespace.trailing
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
node._replacement = replacement
|
||||
}
|
||||
|
||||
toMarkdown = function (input, options) {
|
||||
options = options || {}
|
||||
|
||||
if (typeof input !== 'string') {
|
||||
throw new TypeError(input + ' is not a string')
|
||||
}
|
||||
|
||||
if (input === '') {
|
||||
return ''
|
||||
}
|
||||
|
||||
// Escape potential ol triggers
|
||||
input = input.replace(/(\d+)\. /g, '$1\\. ')
|
||||
|
||||
var clone = htmlToDom(input).body
|
||||
var nodes = bfsOrder(clone)
|
||||
var output
|
||||
|
||||
converters = mdConverters.slice(0)
|
||||
if (options.gfm) {
|
||||
converters = gfmConverters.concat(converters)
|
||||
}
|
||||
|
||||
if (options.converters) {
|
||||
converters = options.converters.concat(converters)
|
||||
}
|
||||
|
||||
// Process through nodes in reverse (so deepest child elements are first).
|
||||
for (var i = nodes.length - 1; i >= 0; i--) {
|
||||
process(nodes[i])
|
||||
}
|
||||
output = getContent(clone)
|
||||
|
||||
return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g, '')
|
||||
.replace(/\n\s+\n/g, '\n\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
}
|
||||
|
||||
toMarkdown.isBlock = isBlock
|
||||
toMarkdown.isVoid = isVoid
|
||||
toMarkdown.outer = outer
|
||||
|
||||
module.exports = toMarkdown
|
||||
|
||||
},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){
|
||||
'use strict'
|
||||
|
||||
function cell (content, node) {
|
||||
var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node)
|
||||
var prefix = ' '
|
||||
if (index === 0) prefix = '| '
|
||||
return prefix + content + ' |'
|
||||
}
|
||||
|
||||
var highlightRegEx = /highlight highlight-(\S+)/
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
filter: 'br',
|
||||
replacement: function () {
|
||||
return '\n'
|
||||
}
|
||||
},
|
||||
{
|
||||
filter: ['del', 's', 'strike'],
|
||||
replacement: function (content) {
|
||||
return '~~' + content + '~~'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.type === 'checkbox' && node.parentNode.nodeName === 'LI'
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
return (node.checked ? '[x]' : '[ ]') + ' '
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['th', 'td'],
|
||||
replacement: function (content, node) {
|
||||
return cell(content, node)
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'tr',
|
||||
replacement: function (content, node) {
|
||||
var borderCells = ''
|
||||
var alignMap = { left: ':--', right: '--:', center: ':-:' }
|
||||
|
||||
if (node.parentNode.nodeName === 'THEAD') {
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
var align = node.childNodes[i].attributes.align
|
||||
var border = '---'
|
||||
|
||||
if (align) border = alignMap[align.value] || border
|
||||
|
||||
borderCells += cell(border, node.childNodes[i])
|
||||
}
|
||||
}
|
||||
return '\n' + content + (borderCells ? '\n' + borderCells : '')
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'table',
|
||||
replacement: function (content) {
|
||||
return '\n\n' + content + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['thead', 'tbody', 'tfoot'],
|
||||
replacement: function (content) {
|
||||
return content
|
||||
}
|
||||
},
|
||||
|
||||
// Fenced code blocks
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'PRE' &&
|
||||
node.firstChild &&
|
||||
node.firstChild.nodeName === 'CODE'
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
return '\n\n```\n' + node.firstChild.textContent + '\n```\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
// Syntax-highlighted code blocks
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'PRE' &&
|
||||
node.parentNode.nodeName === 'DIV' &&
|
||||
highlightRegEx.test(node.parentNode.className)
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
var language = node.parentNode.className.match(highlightRegEx)[1]
|
||||
return '\n\n```' + language + '\n' + node.textContent + '\n```\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'DIV' &&
|
||||
highlightRegEx.test(node.className)
|
||||
},
|
||||
replacement: function (content) {
|
||||
return '\n\n' + content + '\n\n'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
},{}],3:[function(require,module,exports){
|
||||
/*
|
||||
* Set up window for Node.js
|
||||
*/
|
||||
|
||||
var _window = (typeof window !== 'undefined' ? window : this)
|
||||
|
||||
/*
|
||||
* Parsing HTML strings
|
||||
*/
|
||||
|
||||
function canParseHtmlNatively () {
|
||||
var Parser = _window.DOMParser
|
||||
var canParse = false
|
||||
|
||||
// Adapted from https://gist.github.com/1129031
|
||||
// Firefox/Opera/IE throw errors on unsupported types
|
||||
try {
|
||||
// WebKit returns null on unsupported types
|
||||
if (new Parser().parseFromString('', 'text/html')) {
|
||||
canParse = true
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return canParse
|
||||
}
|
||||
|
||||
function createHtmlParser () {
|
||||
var Parser = function () {}
|
||||
|
||||
// For Node.js environments
|
||||
if (typeof document === 'undefined') {
|
||||
var jsdom = require('jsdom')
|
||||
Parser.prototype.parseFromString = function (string) {
|
||||
return jsdom.jsdom(string, {
|
||||
features: {
|
||||
FetchExternalResources: [],
|
||||
ProcessExternalResources: false
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (!shouldUseActiveX()) {
|
||||
Parser.prototype.parseFromString = function (string) {
|
||||
var doc = document.implementation.createHTMLDocument('')
|
||||
doc.open()
|
||||
doc.write(string)
|
||||
doc.close()
|
||||
return doc
|
||||
}
|
||||
} else {
|
||||
Parser.prototype.parseFromString = function (string) {
|
||||
var doc = new window.ActiveXObject('htmlfile')
|
||||
doc.designMode = 'on' // disable on-page scripts
|
||||
doc.open()
|
||||
doc.write(string)
|
||||
doc.close()
|
||||
return doc
|
||||
}
|
||||
}
|
||||
}
|
||||
return Parser
|
||||
}
|
||||
|
||||
function shouldUseActiveX () {
|
||||
var useActiveX = false
|
||||
|
||||
try {
|
||||
document.implementation.createHTMLDocument('').open()
|
||||
} catch (e) {
|
||||
if (window.ActiveXObject) useActiveX = true
|
||||
}
|
||||
|
||||
return useActiveX
|
||||
}
|
||||
|
||||
module.exports = canParseHtmlNatively() ? _window.DOMParser : createHtmlParser()
|
||||
|
||||
},{"jsdom":6}],4:[function(require,module,exports){
|
||||
'use strict'
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
filter: 'p',
|
||||
replacement: function (content) {
|
||||
return '\n\n' + content + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'br',
|
||||
replacement: function () {
|
||||
return ' \n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
||||
replacement: function (content, node) {
|
||||
var hLevel = node.nodeName.charAt(1)
|
||||
var hPrefix = ''
|
||||
for (var i = 0; i < hLevel; i++) {
|
||||
hPrefix += '#'
|
||||
}
|
||||
return '\n\n' + hPrefix + ' ' + content + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'hr',
|
||||
replacement: function () {
|
||||
return '\n\n* * *\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['em', 'i'],
|
||||
replacement: function (content) {
|
||||
return '_' + content + '_'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['strong', 'b'],
|
||||
replacement: function (content) {
|
||||
return '**' + content + '**'
|
||||
}
|
||||
},
|
||||
|
||||
// Inline code
|
||||
{
|
||||
filter: function (node) {
|
||||
var hasSiblings = node.previousSibling || node.nextSibling
|
||||
var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings
|
||||
|
||||
return node.nodeName === 'CODE' && !isCodeBlock
|
||||
},
|
||||
replacement: function (content) {
|
||||
return '`' + content + '`'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'A' && node.getAttribute('href')
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
var titlePart = node.title ? ' "' + node.title + '"' : ''
|
||||
return '[' + content + '](' + node.getAttribute('href') + titlePart + ')'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'img',
|
||||
replacement: function (content, node) {
|
||||
var alt = node.alt || ''
|
||||
var src = node.getAttribute('src') || ''
|
||||
var title = node.title || ''
|
||||
var titlePart = title ? ' "' + title + '"' : ''
|
||||
return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : ''
|
||||
}
|
||||
},
|
||||
|
||||
// Code blocks
|
||||
{
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'PRE' && node.firstChild.nodeName === 'CODE'
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
return '\n\n ' + node.firstChild.textContent.replace(/\n/g, '\n ') + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'blockquote',
|
||||
replacement: function (content) {
|
||||
content = content.trim()
|
||||
content = content.replace(/\n{3,}/g, '\n\n')
|
||||
content = content.replace(/^/gm, '> ')
|
||||
return '\n\n' + content + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: 'li',
|
||||
replacement: function (content, node) {
|
||||
content = content.replace(/^\s+/, '').replace(/\n/gm, '\n ')
|
||||
var prefix = '* '
|
||||
var parent = node.parentNode
|
||||
var index = Array.prototype.indexOf.call(parent.children, node) + 1
|
||||
|
||||
prefix = /ol/i.test(parent.nodeName) ? index + '. ' : '* '
|
||||
return prefix + content
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: ['ul', 'ol'],
|
||||
replacement: function (content, node) {
|
||||
var strings = []
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
strings.push(node.childNodes[i]._replacement)
|
||||
}
|
||||
|
||||
if (/li/i.test(node.parentNode.nodeName)) {
|
||||
return '\n' + strings.join('\n')
|
||||
}
|
||||
return '\n\n' + strings.join('\n') + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
filter: function (node) {
|
||||
return this.isBlock(node)
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
return '\n\n' + this.outer(node, content) + '\n\n'
|
||||
}
|
||||
},
|
||||
|
||||
// Anything else!
|
||||
{
|
||||
filter: function () {
|
||||
return true
|
||||
},
|
||||
replacement: function (content, node) {
|
||||
return this.outer(node, content)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
},{}],5:[function(require,module,exports){
|
||||
/**
|
||||
* This file automatically generated from `build.js`.
|
||||
* Do not manually edit.
|
||||
*/
|
||||
|
||||
module.exports = [
|
||||
"address",
|
||||
"article",
|
||||
"aside",
|
||||
"audio",
|
||||
"blockquote",
|
||||
"canvas",
|
||||
"dd",
|
||||
"div",
|
||||
"dl",
|
||||
"fieldset",
|
||||
"figcaption",
|
||||
"figure",
|
||||
"footer",
|
||||
"form",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"h6",
|
||||
"header",
|
||||
"hgroup",
|
||||
"hr",
|
||||
"main",
|
||||
"nav",
|
||||
"noscript",
|
||||
"ol",
|
||||
"output",
|
||||
"p",
|
||||
"pre",
|
||||
"section",
|
||||
"table",
|
||||
"tfoot",
|
||||
"ul",
|
||||
"video"
|
||||
];
|
||||
|
||||
},{}],6:[function(require,module,exports){
|
||||
|
||||
},{}],7:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
var voidElements = require('void-elements');
|
||||
Object.keys(voidElements).forEach(function (name) {
|
||||
voidElements[name.toUpperCase()] = 1;
|
||||
});
|
||||
|
||||
var blockElements = {};
|
||||
require('block-elements').forEach(function (name) {
|
||||
blockElements[name.toUpperCase()] = 1;
|
||||
});
|
||||
|
||||
/**
|
||||
* isBlockElem(node) determines if the given node is a block element.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isBlockElem(node) {
|
||||
return !!(node && blockElements[node.nodeName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* isVoid(node) determines if the given node is a void element.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isVoid(node) {
|
||||
return !!(node && voidElements[node.nodeName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* whitespace(elem [, isBlock]) removes extraneous whitespace from an
|
||||
* the given element. The function isBlock may optionally be passed in
|
||||
* to determine whether or not an element is a block element; if none
|
||||
* is provided, defaults to using the list of block elements provided
|
||||
* by the `block-elements` module.
|
||||
*
|
||||
* @param {Node} elem
|
||||
* @param {Function} blockTest
|
||||
*/
|
||||
function collapseWhitespace(elem, isBlock) {
|
||||
if (!elem.firstChild || elem.nodeName === 'PRE') return;
|
||||
|
||||
if (typeof isBlock !== 'function') {
|
||||
isBlock = isBlockElem;
|
||||
}
|
||||
|
||||
var prevText = null;
|
||||
var prevVoid = false;
|
||||
|
||||
var prev = null;
|
||||
var node = next(prev, elem);
|
||||
|
||||
while (node !== elem) {
|
||||
if (node.nodeType === 3) {
|
||||
// Node.TEXT_NODE
|
||||
var text = node.data.replace(/[ \r\n\t]+/g, ' ');
|
||||
|
||||
if ((!prevText || / $/.test(prevText.data)) && !prevVoid && text[0] === ' ') {
|
||||
text = text.substr(1);
|
||||
}
|
||||
|
||||
// `text` might be empty at this point.
|
||||
if (!text) {
|
||||
node = remove(node);
|
||||
continue;
|
||||
}
|
||||
|
||||
node.data = text;
|
||||
prevText = node;
|
||||
} else if (node.nodeType === 1) {
|
||||
// Node.ELEMENT_NODE
|
||||
if (isBlock(node) || node.nodeName === 'BR') {
|
||||
if (prevText) {
|
||||
prevText.data = prevText.data.replace(/ $/, '');
|
||||
}
|
||||
|
||||
prevText = null;
|
||||
prevVoid = false;
|
||||
} else if (isVoid(node)) {
|
||||
// Avoid trimming space around non-block, non-BR void elements.
|
||||
prevText = null;
|
||||
prevVoid = true;
|
||||
}
|
||||
} else {
|
||||
node = remove(node);
|
||||
continue;
|
||||
}
|
||||
|
||||
var nextNode = next(prev, node);
|
||||
prev = node;
|
||||
node = nextNode;
|
||||
}
|
||||
|
||||
if (prevText) {
|
||||
prevText.data = prevText.data.replace(/ $/, '');
|
||||
if (!prevText.data) {
|
||||
remove(prevText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove(node) removes the given node from the DOM and returns the
|
||||
* next node in the sequence.
|
||||
*
|
||||
* @param {Node} node
|
||||
* @return {Node} node
|
||||
*/
|
||||
function remove(node) {
|
||||
var next = node.nextSibling || node.parentNode;
|
||||
|
||||
node.parentNode.removeChild(node);
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
/**
|
||||
* next(prev, current) returns the next node in the sequence, given the
|
||||
* current and previous nodes.
|
||||
*
|
||||
* @param {Node} prev
|
||||
* @param {Node} current
|
||||
* @return {Node}
|
||||
*/
|
||||
function next(prev, current) {
|
||||
if (prev && prev.parentNode === current || current.nodeName === 'PRE') {
|
||||
return current.nextSibling || current.parentNode;
|
||||
}
|
||||
|
||||
return current.firstChild || current.nextSibling || current.parentNode;
|
||||
}
|
||||
|
||||
module.exports = collapseWhitespace;
|
||||
|
||||
},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){
|
||||
/**
|
||||
* This file automatically generated from `pre-publish.js`.
|
||||
* Do not manually edit.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
"area": true,
|
||||
"base": true,
|
||||
"br": true,
|
||||
"col": true,
|
||||
"embed": true,
|
||||
"hr": true,
|
||||
"img": true,
|
||||
"input": true,
|
||||
"keygen": true,
|
||||
"link": true,
|
||||
"menuitem": true,
|
||||
"meta": true,
|
||||
"param": true,
|
||||
"source": true,
|
||||
"track": true,
|
||||
"wbr": true
|
||||
};
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue