2025/2/8第一次更新

This commit is contained in:
爱吃咸鱼小猫咪
2025-02-08 18:50:38 +08:00
commit d7af560866
26519 changed files with 5046029 additions and 0 deletions
@@ -0,0 +1,106 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const _sfc_main = {
name: "firstui-audio",
props: {
title: {
type: String,
default: ""
},
desc: {
type: String,
default: ""
},
src: {
type: String,
default: ""
}
},
watch: {
src(newValue, oldValue) {
if (newVal) {
this.handleInitAudio(newVal);
}
}
},
data() {
return {
isPlay: false,
currentTimeStr: "00:00",
durationStr: "00:00",
progress: 0
};
},
created() {
this.innerAudioContext = null;
this.src && this.handleInitAudio(this.src);
},
beforeUnmount() {
this.innerAudioContext && this.innerAudioContext.destroy();
},
methods: {
handleInitAudio(src) {
this.innerAudioContext = common_vendor.index.createInnerAudioContext();
this.innerAudioContext.src = src;
this.innerAudioContext.onPlay(() => {
console.log("开始播放");
});
this.innerAudioContext.onCanplay(() => {
this.innerAudioContext.duration;
setTimeout(() => {
const durationStr = this.parseTime(this.innerAudioContext.duration);
this.durationStr = durationStr;
}, 1e3);
});
this.innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
this.innerAudioContext.onEnded(() => {
this.isPlay = false;
});
this.innerAudioContext.onTimeUpdate(() => {
const currentTime = this.innerAudioContext.currentTime;
const duration = this.innerAudioContext.duration;
const currentTimeStr = this.parseTime(currentTime);
const progress = currentTime / duration * 100;
this.currentTimeStr = currentTimeStr;
this.progress = progress;
});
},
handleControl() {
if (!this.isPlay) {
this.isPlay = true;
this.innerAudioContext && this.innerAudioContext.play();
} else {
this.isPlay = false;
this.innerAudioContext && this.innerAudioContext.pause();
}
},
parseTime(time) {
const minute = Math.floor(time / 60);
const second = Math.floor(time % 60);
return `${minute < 10 ? "0" + minute : minute}:${second < 10 ? "0" + second : second}`;
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.isPlay ? 1 : "",
b: !$data.isPlay ? 1 : "",
c: $props.title
}, $props.title ? {
d: common_vendor.t($props.title)
} : {}, {
e: $props.desc
}, $props.desc ? {
f: common_vendor.t($props.desc)
} : {}, {
g: `${$data.progress}%`,
h: common_vendor.t($data.currentTimeStr),
i: common_vendor.t($data.durationStr),
j: common_vendor.o((...args) => $options.handleControl && $options.handleControl(...args))
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-330431b2"]]);
wx.createComponent(Component);
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,81 @@
.fuiAudio-wrap.data-v-330431b2 {
display: flex;
width: 100%;
box-sizing: border-box;
height: 240rpx;
border: 1rpx solid #ebe9ec;
background: #fdfbfe;
flex-direction: row;
align-items: center;
padding: 0 30rpx;
}
.fuiAudio-left.data-v-330431b2 {
margin-right: 30rpx;
}
.fuiAudio-right.data-v-330431b2 {
flex: 1;
}
.fuiAudio-icon.data-v-330431b2 {
width: 100rpx;
height: 100rpx;
}
.fuiAudio-title.data-v-330431b2 {
margin-bottom: 16rpx;
font-size: 40rpx;
color: #323232;
overflow: hidden;
display: -webkit-box;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
text-overflow: ellipsis;
}
.fuiAudio-progress.data-v-330431b2 {
width: 100%;
height: 6rpx;
background: #ebe9ec;
border-radius: 4rpx;
margin-bottom: 10rpx;
}
.fuiAudio-author.data-v-330431b2 {
margin-bottom: 16rpx;
font-size: 28rpx;
color: #999;
}
.fuiAudio-time.data-v-330431b2 {
display: flex;
width: 100%;
flex-direction: row;
justify-content: space-between;
color: #999;
}
.fuiAudio-progress.data-v-330431b2 {
position: relative;
}
.fuiAudio-current.data-v-330431b2 {
position: absolute;
left: 0;
top: 0;
width: 10%;
height: 100%;
background: #249b27;
}
.fuiAudio-hidden.data-v-330431b2 {
opacity: 0;
visibility: hidden;
transform: scale(0);
position: absolute;
}
@@ -0,0 +1,54 @@
"use strict";
require("./high-light/index.js");
const common_vendor = require("../../../common/vendor.js");
const components_firstui_fuiParse_highLight_highlight_code = require("./high-light/highlight.code.js");
const LANGUAGE_LIST = [
"javascript",
"css",
"xml",
"sql",
"typescript",
"markdown",
"c++",
"c"
];
const _sfc_main = {
name: "firstui-audio",
props: {
codeText: {
type: String,
default: ""
},
language: {
type: String,
default: "javascript"
}
},
data() {
return {
code: ""
};
},
created() {
this.parseCode(this.codeText, this.language);
},
methods: {
parseCode(input, language) {
const lang = LANGUAGE_LIST.includes(language) ? language : "javascript";
const {
value
} = components_firstui_fuiParse_highLight_highlight_code._hljs.highlight(lang, input);
const highlighted = value.replace("&amp;", "&").trim();
let codeResult = `<code class="${lang}">${highlighted}</code>`;
codeResult = codeResult.replace(/\n/g, "<br/>").replace("<code>", "");
this.code = codeResult;
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.code
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1 @@
<view class="{{['hljs', virtualHostClass]}}" style="{{virtualHostStyle}}"><rich-text nodes="{{a}}" space="nbsp"></rich-text></view>
@@ -0,0 +1,110 @@
/*
Style with support for rainbow parens
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #282c34;
color: #d1d9e1;
}
.hljs-comment,
.hljs-quote {
color: #969896;
font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type,
.hljs-addition {
color: #cc99cc;
}
.hljs-number,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #f99157;
}
.hljs-string,
.hljs-doctag,
.hljs-regexp {
color: #8abeb7;
}
.hljs-title,
.hljs-name,
.hljs-section,
.hljs-built_in {
color: #b5bd68;
}
.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-class .hljs-title {
color: #ffcc66;
}
.hljs-section,
.hljs-name,
.hljs-strong {
font-weight: bold;
}
.hljs-symbol,
.hljs-bullet,
.hljs-subst,
.hljs-meta,
.hljs-link {
color: #f99157;
}
.hljs-deletion {
color: #dc322f;
}
.hljs-formula {
background: #eee8d5;
}
.hljs-attr,
.hljs-attribute {
color: #81a2be;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-comment, .hljs-quote{
color: #969896;
font-style: italic;
}
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type, .hljs-addition {
color: #cc99cc;
}
.hljs-number, .hljs-selector-attr, .hljs-selector-pseudo {
color: #f99157;
}
.hljs-string, .hljs-doctag, .hljs-regexp {
color: #8abeb7;
}
.hljs-title, .hljs-name, .hljs-section, .hljs-built_in {
color: #b5bd68;
}
.hljs-variable, .hljs-template-variable, .hljs-selector-id, .hljs-class .hljs-title {
color: #ffcc66;
}
.hljs-section, .hljs-name, .hljs-strong {
font-weight: bold;
}
.hljs-symbol, .hljs-bullet, .hljs-subst, .hljs-meta, .hljs-link {
color: #f99157;
}
.hljs-deletion {
color: #dc322f;
}
.hljs-formula {
background: #eee8d5;
}
.hljs-attr, .hljs-attribute {
color: #81a2be;
}
.hljs-emphasis {
font-style: italic;
}
@@ -0,0 +1,423 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const components_firstui_fuiParse_utils_html2json = require("./utils/html2json.js");
const components_firstui_fuiParse_marked_index = require("./marked/index.js");
const components_firstui_fuiParse_utils_util = require("./utils/util.js");
const firstuiCode = () => "./firstui-code.js";
const firstuiAudio = () => "./firstui-audio.js";
const BIND_NAME = "fuiParse";
const _sfc_main = {
name: "fui-parse",
inject: {
parsegroup: {
value: "parsegroup",
default: null
}
},
components: {
firstuiCode,
firstuiAudio
},
props: {
// 可选:html | markdown (md)
language: {
type: String,
default: "html"
},
nodes: {
type: [String, Object, Array],
default: ""
}
},
watch: {
nodes: {
handler(val) {
if (!val)
return;
if (this.language === "markdown" || this.language === "md") {
const parseNodes = components_firstui_fuiParse_marked_index.marked(val);
setTimeout(() => {
this._parseNodes(parseNodes);
}, 0);
} else {
setTimeout(() => {
this._parseNodes(val);
}, 0);
}
},
immediate: true
}
},
beforeUnmount() {
components_firstui_fuiParse_utils_util.util.cacheInstance.remove(this.pageNodeKey);
},
data() {
return {
pageNodeKey: "",
nodesData: [],
bindData: {},
width: 0,
height: 0,
thBgcolor: true,
mode: ""
};
},
created() {
this.$nextTick(() => {
setTimeout(() => {
if (this.parsegroup) {
this.thBgcolor = this.parsegroup.thBgcolor;
}
this.mode = "widthFix";
}, 50);
});
},
methods: {
_parseNodes(nodes) {
this.pageNodeKey = this.parsegroup ? this.parsegroup.pageNodeKey : BIND_NAME;
if (typeof nodes === "string") {
this._parseHtml(nodes);
} else if (Array.isArray(nodes)) {
this.nodesData = nodes;
} else {
this.nodesData = [nodes];
}
},
_parseHtml(html) {
const transData = components_firstui_fuiParse_utils_html2json.HtmlToJson.html2json(html, this.pageNodeKey);
transData.view = {};
transData.view.imagePadding = 0;
this.nodesData = transData.nodes;
this.bindData = {
[this.pageNodeKey]: transData
};
components_firstui_fuiParse_utils_util.util.cacheInstance.set(this.pageNodeKey, transData);
},
/**
* 图片视觉宽高计算函数区
* @param {*} e
*/
fuiParseImgLoad(e) {
const {
from: tagFrom,
index
} = e.target.dataset || e.currentTarget.dataset || {};
if (typeof tagFrom !== "undefined" && tagFrom.length > 0) {
const {
width,
height
} = e.detail;
const recal = this._fuiAutoImageCal(width, height);
this.width = recal.imageWidth;
this.height = recal.imageHeight;
const nodesData = this.nodesData;
nodesData[index].loaded = true;
this.nodesData = nodesData;
}
},
/**
* 预览图片
* @param {*} e
*/
fuiParseImgTap(e) {
const {
src
} = e.target.dataset || e.currentTarget.dataset;
let {
imageUrls = []
} = components_firstui_fuiParse_utils_util.util.cacheInstance.get(this.pageNodeKey);
if (imageUrls.length == 0) {
imageUrls = [src];
}
if (this.parsegroup) {
if (this.parsegroup.imgPreview) {
common_vendor.index.previewImage({
current: src,
urls: imageUrls
});
}
this.parsegroup.previewImage(src, imageUrls);
} else {
common_vendor.index.previewImage({
current: src,
urls: imageUrls
});
}
},
/**
* 计算视觉优先的图片宽高
* @param {*} originalWidth
* @param {*} originalHeight
*/
_fuiAutoImageCal(originalWidth, originalHeight) {
let autoWidth = 0, autoHeight = 0;
const results = {};
const [windowWidth, windowHeight] = components_firstui_fuiParse_utils_util.util.getSystemInfo();
if (originalWidth > windowWidth) {
autoWidth = windowWidth;
autoHeight = autoWidth * originalHeight / originalWidth;
results.imageWidth = autoWidth;
results.imageHeight = autoHeight;
} else {
results.imageWidth = originalWidth;
results.imageHeight = originalHeight;
}
return results;
},
/**
* 增加a标签跳转
* @param {*} e
*/
fuiParseTagATap(e) {
const {
src = ""
} = e.currentTarget.dataset;
if (this.parsegroup) {
this.parsegroup.onATap(src);
return;
}
const isInnerPage = src.indexOf("http") === -1;
if (isInnerPage) {
common_vendor.index.navigateTo({
url: src
});
}
}
}
};
if (!Array) {
const _easycom_fui_parse2 = common_vendor.resolveComponent("fui-parse");
const _component_firstui_code = common_vendor.resolveComponent("firstui-code");
const _component_firstui_audio = common_vendor.resolveComponent("firstui-audio");
(_easycom_fui_parse2 + _component_firstui_code + _component_firstui_audio)();
}
const _easycom_fui_parse = () => Promise.resolve().then(() => Rjov5oiR55qE5byA5rqQ6aG555uuL215c2VsZi1hY2dpL3NyYy9jb21wb25lbnRzL2ZpcnN0dWkvZnVpLXBhcnNlL2Z1aS1wYXJzZS52dWU);
if (!Math) {
_easycom_fui_parse();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.f($data.nodesData, (item, index, i0) => {
return common_vendor.e({
a: item.node == "element"
}, item.node == "element" ? common_vendor.e({
b: item.tag == "button"
}, item.tag == "button" ? {
c: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-0-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
})
} : item && item.tag == "code" ? {
e: "231dc595-1-" + i0,
f: common_vendor.p({
codeText: item.content,
language: item.attr && item.attr.lang
}),
g: common_vendor.n(item.classStr),
h: common_vendor.s(item.styleStr)
} : item.tag == "ol" ? {
j: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: common_vendor.t(idx + 1),
b: "231dc595-2-" + i0 + "-" + i1,
c: common_vendor.p({
nodes: child
}),
d: idx
};
}),
k: common_vendor.n(item.classStr),
l: common_vendor.s(item.styleStr)
} : item.tag == "ul" ? {
n: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-3-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
o: common_vendor.n(item.classStr),
p: common_vendor.s(item.style && item.style.Str)
} : item.tag == "li" ? {
r: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-4-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
s: common_vendor.n(item.classStr),
t: common_vendor.s(item.styleStr)
} : item.tag == "video" ? {
w: common_vendor.n(item.classStr),
x: common_vendor.n(`fuiParse-${item.tag}-video`),
y: item.attr && item.attr.src,
z: common_vendor.n(item.classStr),
A: common_vendor.n(`fuiParse-${item.tag}`),
B: common_vendor.s(item.styleStr)
} : item.tag == "img" ? common_vendor.e({
D: item.attr && item.attr.src
}, item.attr && item.attr.src ? {
E: common_vendor.n(item.classStr),
F: common_vendor.n(`fuiParse-${item.tag}`),
G: common_vendor.n(item.loaded ? "fuiParse-img-fadein" : ""),
H: item.from,
I: item.attr.src,
J: item.imgIndex,
K: item.loaded ? item.attr.src : "",
L: common_vendor.o((...args) => $options.fuiParseImgTap && $options.fuiParseImgTap(...args), index),
M: $data.mode,
N: common_vendor.s("width:" + (item.attr.width || $data.width) + "px;height:" + (item.attr.height || $data.height) + "px;" + item.styleStr),
O: item.loaded ? 1 : "",
P: $data.mode,
Q: item.from,
R: index,
S: item.attr.src,
T: common_vendor.o((...args) => $options.fuiParseImgLoad && $options.fuiParseImgLoad(...args), index)
} : {}) : item.tag == "a" ? {
V: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-5-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
W: common_vendor.o((...args) => $options.fuiParseTagATap && $options.fuiParseTagATap(...args), index),
X: common_vendor.n(item.classStr),
Y: common_vendor.n(`fuiParse-${item.tag}`),
Z: item.attr && item.attr.title,
aa: item.attr && item.attr.href,
ab: common_vendor.s(item.styleStr)
} : item.tag == "table" ? {
ad: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-6-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
ae: common_vendor.n(item.classStr),
af: common_vendor.n(`fuiParse-${item.tag}`)
} : item.tag == "tr" ? {
ah: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: common_vendor.n(child.classStr),
b: common_vendor.n(`fuiParse-${child.tag}`),
c: common_vendor.n(`fuiParse-${child.tag}-container`),
d: common_vendor.n(child.tag == "th" && $data.thBgcolor ? "fuiParse-th__bg" : ""),
e: common_vendor.s(child.styleStr),
f: "231dc595-7-" + i0 + "-" + i1,
g: common_vendor.p({
nodes: child
}),
h: idx
};
}),
ai: common_vendor.n(item.classStr),
aj: common_vendor.n(`fuiParse-${item.tag}`)
} : item.tag == "td" ? {
al: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: common_vendor.n(child.classStr),
b: common_vendor.n(`fuiParse-${child.tag}`),
c: common_vendor.n(`fuiParse-${child.tag}-container`),
d: common_vendor.s(child.styleStr),
e: "231dc595-8-" + i0 + "-" + i1,
f: common_vendor.p({
nodes: child
}),
g: idx
};
}),
am: common_vendor.n(item.classStr),
an: common_vendor.n(`fuiParse-${item.tag}`)
} : item.tag == "audio" ? {
ap: common_vendor.n(item.classStr),
aq: common_vendor.s(item.styleStr),
ar: "231dc595-9-" + i0,
as: common_vendor.p({
src: item.attr && item.attr.src,
title: item.attr && item.attr.title,
desc: item.attr && item.attr.desc
})
} : item.tag == "br" ? {} : item.tagType == "block" ? {
aw: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-10-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
ax: common_vendor.n(item.classStr),
ay: common_vendor.n(`fuiParse-${item.tag}`),
az: common_vendor.s(item.styleStr)
} : {
aA: common_vendor.f(item.nodes, (child, idx, i1) => {
return {
a: "231dc595-11-" + i0 + "-" + i1,
b: common_vendor.p({
nodes: child
}),
c: idx
};
}),
aB: common_vendor.n(item.classStr),
aC: common_vendor.n(`fuiParse-${item.tag}`),
aD: common_vendor.n(`fuiParse-${item.tagType}`),
aE: common_vendor.s(item.styleStr)
}, {
d: item && item.tag == "code",
i: item.tag == "ol",
m: item.tag == "ul",
q: item.tag == "li",
v: item.tag == "video",
C: item.tag == "img",
U: item.tag == "a",
ac: item.tag == "table",
ag: item.tag == "tr",
ak: item.tag == "td",
ao: item.tag == "audio",
at: item.tag == "br",
av: item.tagType == "block"
}) : item.node == "text" ? {
aG: common_vendor.f(item.textArray, (textItem, idx, i1) => {
return common_vendor.e({
a: textItem.node == "text"
}, textItem.node == "text" ? {
b: common_vendor.t(textItem.text),
c: common_vendor.n(textItem.text == "\\n" ? "fuiParse-hide" : "")
} : textItem.node == "element" ? {
e: textItem.baseSrc + textItem.text
} : {}, {
d: textItem.node == "element",
f: idx
});
}),
aH: common_vendor.s(item.styleStr)
} : {}, {
aF: item.node == "text",
aI: index
});
})
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-231dc595"]]);
wx.createComponent(Component);
const Rjov5oiR55qE5byA5rqQ6aG555uuL215c2VsZi1hY2dpL3NyYy9jb21wb25lbnRzL2ZpcnN0dWkvZnVpLXBhcnNlL2Z1aS1wYXJzZS52dWU = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"firstui-code": "./firstui-code",
"firstui-audio": "./firstui-audio",
"fui-parse": "./fui-parse"
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,349 @@
.fui-parse__wrap.data-v-231dc595 {
display: inline;
max-width: 100%;
font-weight: normal;
}
.fuiParse.data-v-231dc595 {
margin: 0 5px;
font-family: Helvetica, sans-serif;
font-size: 28rpx;
color: #666;
line-height: 1.8;
}
.fuiParse-inline.data-v-231dc595 {
display: inline;
margin: 0;
padding: 0;
line-height: 1.75;
}
.mb10.data-v-231dc595 {
margin-bottom: 0.63em;
}
/*//标题 */
.fuiParse-div.data-v-231dc595 {
/* margin: 0; */
padding: 0;
}
.fuiParse-h1.data-v-231dc595 {
font-size: 2em;
margin: .67em 0
}
.fuiParse-h2.data-v-231dc595 {
font-size: 1.5em;
margin: .75em 0
}
.fuiParse-h3.data-v-231dc595 {
font-size: 1.17em;
margin: .83em 0
}
.fuiParse-h4.data-v-231dc595 {
margin: 1.12em 0
}
.fuiParse-h5.data-v-231dc595 {
font-size: .83em;
margin: 1.5em 0
}
.fuiParse-h6.data-v-231dc595 {
font-size: .75em;
margin: 1.67em 0
}
.fuiParse-h1.data-v-231dc595 {
font-size: 18px;
font-weight: 500;
margin-bottom: .9em;
}
.fuiParse-h2.data-v-231dc595 {
font-size: 16px;
font-weight: 500;
margin-bottom: .34em;
}
.fuiParse-h3.data-v-231dc595 {
font-weight: 500;
font-size: 15px;
margin-bottom: .34em;
}
.fuiParse-h4.data-v-231dc595 {
font-weight: 500;
font-size: 14px;
margin-bottom: .24em;
}
.fuiParse-h5.data-v-231dc595 {
font-weight: 500;
font-size: 13px;
margin-bottom: .14em;
}
.fuiParse-h6.data-v-231dc595 {
font-weight: 500;
font-size: 12px;
margin-bottom: .04em;
}
.fuiParse-h1.data-v-231dc595,
.fuiParse-h1 text.data-v-231dc595,
.fuiParse-h2.data-v-231dc595,
.fuiParse-h2 text.data-v-231dc595,
.fuiParse-h3.data-v-231dc595,
.fuiParse-h3 text.data-v-231dc595,
.fuiParse-h4.data-v-231dc595,
.fuiParse-h4 text.data-v-231dc595,
.fuiParse-h5.data-v-231dc595,
.fuiParse-h5 text.data-v-231dc595,
.fuiParse-h6.data-v-231dc595,
.fuiParse-h6 text.data-v-231dc595,
.fuiParse-b.data-v-231dc595,
.fuiParse-b text.data-v-231dc595,
.fuiParse-strong.data-v-231dc595,
.fuiParse-strong text.data-v-231dc595 {
font-weight: bold;
}
.fuiParse-i.data-v-231dc595,
.fuiParse-i text.data-v-231dc595,
.fuiParse-cite.data-v-231dc595,
.fuiParse-em.data-v-231dc595,
.fuiParse-em text.data-v-231dc595,
.fuiParse-var.data-v-231dc595,
.fuiParse-address.data-v-231dc595,
.fuiParse-address text.data-v-231dc595 {
font-style: italic
}
.fuiParse-pre.data-v-231dc595,
.fuiParse-tt.data-v-231dc595,
.fuiParse-code.data-v-231dc595,
.fuiParse-kbd.data-v-231dc595,
.fuiParse-samp.data-v-231dc595 {
font-family: monospace
}
.fuiParse-pre.data-v-231dc595 {
white-space: pre;
overflow-x: scroll;
background: #f5f5f5;
}
.fuiParse-p.data-v-231dc595 {
max-width: 100%;
word-break: break-all;
white-space: pre-wrap;
box-sizing: border-box;
}
.fuiParse-section.data-v-231dc595 {
max-width: 100%;
overflow: hidden;
white-space: pre-wrap;
box-sizing: border-box;
}
.fuiParse-big.data-v-231dc595 {
font-size: 1.17em
}
.fuiParse-small.data-v-231dc595,
.fuiParse-sub.data-v-231dc595,
.fuiParse-sup.data-v-231dc595 {
font-size: .83em
}
.fuiParse-sub.data-v-231dc595 {
vertical-align: sub
}
.fuiParse-sup.data-v-231dc595 {
vertical-align: super
}
.fuiParse-s.data-v-231dc595,
.fuiParse-strike.data-v-231dc595,
.fuiParse-del.data-v-231dc595 {
text-decoration: line-through
}
/*fuiParse-自定义个性化的css样式*/
/*增加video的css样式*/
.fuiParse-strong.data-v-231dc595,
.fuiParse-s.data-v-231dc595 {
display: inline
}
.fuiParse-a.data-v-231dc595 {
word-break: break-all;
overflow: auto;
color: var(--fui-color-link, #465CFF);
}
.fuiParse-video.data-v-231dc595 {
max-width: 100% !important;
text-align: center;
margin: 10px 0;
}
.fuiParse-video-video.data-v-231dc595 {
width: 100%;
}
.fuiParse-blockquote.data-v-231dc595 {
padding: 10px 0 10px 5px;
font-family: Courier, Calibri, "宋体";
background: #f5f5f5;
border-left: 3px solid #dbdbdb;
}
.fuiParse-code.data-v-231dc595,
.fuiParse-code-style.data-v-231dc595 {
background: #f5f5f5;
line-height: 1.75;
}
.fuiParse-li.data-v-231dc595,
.fuiParse-li-inner.data-v-231dc595 {
align-items: baseline;
margin: 10rpx 0;
}
.fuiParse-li-text.data-v-231dc595 {
flex-direction: row;
align-items: center;
line-height: 20px;
}
.fuiParse-li-circle.data-v-231dc595,
.fuiParse-ol-number.data-v-231dc595 {
margin: 10rpx 10rpx 10rpx 0;
}
.fuiParse-li-circle.data-v-231dc595 {
display: inline-flex;
width: 5px;
height: 5px;
margin-top: 34rpx !important;
background-color: #333;
border-radius: 50%;
}
.fuiParse-li-square.data-v-231dc595 {
display: inline-flex;
width: 10rpx;
height: 10rpx;
background-color: #333;
margin-right: 5px;
}
.fuiParse-li-ring.data-v-231dc595 {
display: inline-flex;
width: 10rpx;
height: 10rpx;
border: 2rpx solid #333;
border-radius: 50%;
background-color: #fff;
margin-right: 5px;
}
.fuiParse-u.data-v-231dc595 {
text-decoration: underline;
}
.fuiParse-hide.data-v-231dc595 {
display: none;
}
.fuiEmojiView.data-v-231dc595 {
align-items: center;
}
.fuiEmoji.data-v-231dc595 {
width: 16px;
height: 16px;
}
.fuiParse-table.data-v-231dc595 {
border-bottom: 1px solid #e0e0e0;
font-size: 0;
overflow-x: scroll;
}
.fuiParse-tr.data-v-231dc595 {
display: flex;
flex-direction: row;
border-right: 1px solid #e0e0e0;
}
.fuiParse-th.data-v-231dc595,
.fuiParse-td.data-v-231dc595 {
flex: 1;
padding: 5px;
font-size: 28rpx;
word-break: break-all;
text-align: center;
}
.fuiParse-th image.data-v-231dc595,
.fuiParse-td image.data-v-231dc595,
.fuiParse-td .fuiParse-img.data-v-231dc595 {
width: 100% !important;
}
.fuiParse-th-container.data-v-231dc595,
.fuiParse-td-container.data-v-231dc595 {
border-left: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0
}
.fuiParse-td.data-v-231dc595:last {
border-top: 1px solid #e0e0e0;
}
.fuiParse-th__bg.data-v-231dc595 {
background: #f0f0f0;
}
.fuiParse-del.data-v-231dc595 {
display: inline;
}
.fuiParse-figure.data-v-231dc595 {
overflow: hidden;
}
.fuiParse-ol-inner.data-v-231dc595,
.fuiParse-ul-inner.data-v-231dc595 {
display: flex;
align-items: flex-start;
flex-direction: row;
line-height: 28px;
}
.fuiParse-img-inner.data-v-231dc595 {
position: relative;
min-height: 100rpx;
}
.fuiParse-img.data-v-231dc595 {
background-color: #efefef;
overflow: hidden;
max-width: 100%;
width: 100%;
display: block;
}
.fuiParse-img-fadein.data-v-231dc595 {
animation: fade-in-231dc595 1s linear;
}
.fuiParse-img-inner .fuiParse-img__loading.data-v-231dc595 {
display: block;
position: absolute;
top: 50%;
left: 50%;
margin-top: -30rpx;
margin-left: -30rpx;
animation: loading-231dc595 1s linear 0s infinite;
width: 60rpx !important;
height: 60rpx !important;
}
/* audio */
.fuiParse-audio-inner.data-v-231dc595 {
width: 100%;
height: 200rpx;
}
/* common */
.mr5.data-v-231dc595 {
margin-right: 5px;
}
.flex-full.data-v-231dc595 {
flex: 1;
}
.overflow-hide.data-v-231dc595 {
overflow: hidden;
}
@keyframes loading-231dc595 {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes fade-in-231dc595 {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.fuiParse-img__hidden.data-v-231dc595 {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
@@ -0,0 +1,853 @@
"use strict";
const _hljs = function(factory) {
var globalObject = typeof window === "object" && window || typeof self === "object" && self;
if (globalObject) {
globalObject.hljs = factory({});
return globalObject.hljs;
} else {
return factory({});
}
}(function(hljs) {
var ArrayProto = [], objectKeys = Object.keys;
var languages = {}, aliases = {};
var SAFE_MODE = true;
var noHighlightRe = /^(no-?highlight|plain|text)$/i, languagePrefixRe = /\blang(?:uage)?-([\w-]+)\b/i, fixMarkupRe = /((^(<[^>]+>|\t|)+|(?:\n)))/gm;
var spanEndTag = "</span>";
var LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
var options = {
classPrefix: "hljs-",
tabReplace: null,
useBR: false,
languages: void 0
};
var COMMON_KEYWORDS = "of and for in not or if then".split(" ");
function escape(value) {
return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function tag(node) {
return node.nodeName.toLowerCase();
}
function testRe(re, lexeme) {
var match = re && re.exec(lexeme);
return match && match.index === 0;
}
function isNotHighlighted(language) {
return noHighlightRe.test(language);
}
function blockLanguage(block) {
var i, match, length, _class;
var classes = block.className + " ";
classes += block.parentNode ? block.parentNode.className : "";
match = languagePrefixRe.exec(classes);
if (match) {
var language = getLanguage(match[1]);
if (!language) {
console.warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
console.warn("Falling back to no-highlight mode for this block.", block);
}
return language ? match[1] : "no-highlight";
}
classes = classes.split(/\s+/);
for (i = 0, length = classes.length; i < length; i++) {
_class = classes[i];
if (isNotHighlighted(_class) || getLanguage(_class)) {
return _class;
}
}
}
function inherit(parent) {
var key;
var result = {};
var objects = Array.prototype.slice.call(arguments, 1);
for (key in parent)
result[key] = parent[key];
objects.forEach(function(obj) {
for (key in obj)
result[key] = obj[key];
});
return result;
}
function nodeStream(node) {
var result = [];
(function _nodeStream(node2, offset) {
for (var child = node2.firstChild; child; child = child.nextSibling) {
if (child.nodeType === 3)
offset += child.nodeValue.length;
else if (child.nodeType === 1) {
result.push({
event: "start",
offset,
node: child
});
offset = _nodeStream(child, offset);
if (!tag(child).match(/br|hr|img|input/)) {
result.push({
event: "stop",
offset,
node: child
});
}
}
}
return offset;
})(node, 0);
return result;
}
function mergeStreams(original, highlighted, value) {
var processed = 0;
var result = "";
var nodeStack = [];
function selectStream() {
if (!original.length || !highlighted.length) {
return original.length ? original : highlighted;
}
if (original[0].offset !== highlighted[0].offset) {
return original[0].offset < highlighted[0].offset ? original : highlighted;
}
return highlighted[0].event === "start" ? original : highlighted;
}
function open(node) {
function attr_str(a) {
return " " + a.nodeName + '="' + escape(a.value).replace(/"/g, "&quot;") + '"';
}
result += "<" + tag(node) + ArrayProto.map.call(node.attributes, attr_str).join("") + ">";
}
function close(node) {
result += "</" + tag(node) + ">";
}
function render(event) {
(event.event === "start" ? open : close)(event.node);
}
while (original.length || highlighted.length) {
var stream = selectStream();
result += escape(value.substring(processed, stream[0].offset));
processed = stream[0].offset;
if (stream === original) {
nodeStack.reverse().forEach(close);
do {
render(stream.splice(0, 1)[0]);
stream = selectStream();
} while (stream === original && stream.length && stream[0].offset === processed);
nodeStack.reverse().forEach(open);
} else {
if (stream[0].event === "start") {
nodeStack.push(stream[0].node);
} else {
nodeStack.pop();
}
render(stream.splice(0, 1)[0]);
}
}
return result + escape(value.substr(processed));
}
function dependencyOnParent(mode) {
if (!mode)
return false;
return mode.endsWithParent || dependencyOnParent(mode.starts);
}
function expand_or_clone_mode(mode) {
if (mode.variants && !mode.cached_variants) {
mode.cached_variants = mode.variants.map(function(variant) {
return inherit(mode, {
variants: null
}, variant);
});
}
if (mode.cached_variants)
return mode.cached_variants;
if (dependencyOnParent(mode))
return [inherit(mode, {
starts: mode.starts ? inherit(mode.starts) : null
})];
if (Object.isFrozen(mode))
return [inherit(mode)];
return [mode];
}
function compileKeywords(rawKeywords, case_insensitive) {
var compiled_keywords = {};
if (typeof rawKeywords === "string") {
splitAndCompile("keyword", rawKeywords);
} else {
objectKeys(rawKeywords).forEach(function(className) {
splitAndCompile(className, rawKeywords[className]);
});
}
return compiled_keywords;
function splitAndCompile(className, str) {
if (case_insensitive) {
str = str.toLowerCase();
}
str.split(" ").forEach(function(keyword) {
var pair = keyword.split("|");
compiled_keywords[pair[0]] = [className, scoreForKeyword(pair[0], pair[1])];
});
}
}
function scoreForKeyword(keyword, providedScore) {
if (providedScore)
return Number(providedScore);
return commonKeyword(keyword) ? 0 : 1;
}
function commonKeyword(word) {
return COMMON_KEYWORDS.indexOf(word.toLowerCase()) != -1;
}
function compileLanguage(language) {
function reStr(re) {
return re && re.source || re;
}
function langRe(value, global) {
return new RegExp(
reStr(value),
"m" + (language.case_insensitive ? "i" : "") + (global ? "g" : "")
);
}
function reCountMatchGroups(re) {
return new RegExp(re.toString() + "|").exec("").length - 1;
}
function joinRe(regexps, separator) {
var backreferenceRe = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
var numCaptures = 0;
var ret = "";
for (var i = 0; i < regexps.length; i++) {
numCaptures += 1;
var offset = numCaptures;
var re = reStr(regexps[i]);
if (i > 0) {
ret += separator;
}
ret += "(";
while (re.length > 0) {
var match = backreferenceRe.exec(re);
if (match == null) {
ret += re;
break;
}
ret += re.substring(0, match.index);
re = re.substring(match.index + match[0].length);
if (match[0][0] == "\\" && match[1]) {
ret += "\\" + String(Number(match[1]) + offset);
} else {
ret += match[0];
if (match[0] == "(") {
numCaptures++;
}
}
}
ret += ")";
}
return ret;
}
function buildModeRegex(mode) {
var matchIndexes = {};
var matcherRe;
var regexes = [];
var matcher = {};
var matchAt = 1;
function addRule(rule, regex) {
matchIndexes[matchAt] = rule;
regexes.push([rule, regex]);
matchAt += reCountMatchGroups(regex) + 1;
}
var term;
for (var i = 0; i < mode.contains.length; i++) {
var re;
term = mode.contains[i];
if (term.beginKeywords) {
re = "\\.?(?:" + term.begin + ")\\.?";
} else {
re = term.begin;
}
addRule(term, re);
}
if (mode.terminator_end)
addRule("end", mode.terminator_end);
if (mode.illegal)
addRule("illegal", mode.illegal);
var terminators = regexes.map(function(el) {
return el[1];
});
matcherRe = langRe(joinRe(terminators, "|"), true);
matcher.lastIndex = 0;
matcher.exec = function(s) {
var rule;
if (regexes.length === 0)
return null;
matcherRe.lastIndex = matcher.lastIndex;
var match = matcherRe.exec(s);
if (!match) {
return null;
}
for (var i2 = 0; i2 < match.length; i2++) {
if (match[i2] != void 0 && matchIndexes["" + i2] != void 0) {
rule = matchIndexes["" + i2];
break;
}
}
if (typeof rule === "string") {
match.type = rule;
match.extra = [mode.illegal, mode.terminator_end];
} else {
match.type = "begin";
match.rule = rule;
}
return match;
};
return matcher;
}
function compileMode(mode, parent) {
if (mode.compiled)
return;
mode.compiled = true;
mode.keywords = mode.keywords || mode.beginKeywords;
if (mode.keywords)
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
mode.lexemesRe = langRe(mode.lexemes || /\w+/, true);
if (parent) {
if (mode.beginKeywords) {
mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")\\b";
}
if (!mode.begin)
mode.begin = /\B|\b/;
mode.beginRe = langRe(mode.begin);
if (mode.endSameAsBegin)
mode.end = mode.begin;
if (!mode.end && !mode.endsWithParent)
mode.end = /\B|\b/;
if (mode.end)
mode.endRe = langRe(mode.end);
mode.terminator_end = reStr(mode.end) || "";
if (mode.endsWithParent && parent.terminator_end)
mode.terminator_end += (mode.end ? "|" : "") + parent.terminator_end;
}
if (mode.illegal)
mode.illegalRe = langRe(mode.illegal);
if (mode.relevance == null)
mode.relevance = 1;
if (!mode.contains) {
mode.contains = [];
}
mode.contains = Array.prototype.concat.apply([], mode.contains.map(function(c) {
return expand_or_clone_mode(c === "self" ? mode : c);
}));
mode.contains.forEach(function(c) {
compileMode(c, mode);
});
if (mode.starts) {
compileMode(mode.starts, parent);
}
mode.terminators = buildModeRegex(mode);
}
if (language.contains && language.contains.indexOf("self") != -1) {
if (!SAFE_MODE) {
throw new Error(
"ERR: contains `self` is not supported at the top-level of a language. See documentation."
);
} else {
language.contains = language.contains.filter(function(mode) {
return mode != "self";
});
}
}
compileMode(language);
}
function highlight(languageName, code, ignore_illegals, continuation) {
var codeToHighlight = code;
function escapeRe(value) {
return new RegExp(value.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "m");
}
function endOfMode(mode, lexeme) {
if (testRe(mode.endRe, lexeme)) {
while (mode.endsParent && mode.parent) {
mode = mode.parent;
}
return mode;
}
if (mode.endsWithParent) {
return endOfMode(mode.parent, lexeme);
}
}
function keywordMatch(mode, match2) {
var match_str = language.case_insensitive ? match2[0].toLowerCase() : match2[0];
return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
}
function buildSpan(className, insideSpan, leaveOpen, noPrefix) {
if (!leaveOpen && insideSpan === "")
return "";
if (!className)
return insideSpan;
var classPrefix = noPrefix ? "" : options.classPrefix, openSpan = '<span class="' + classPrefix, closeSpan = leaveOpen ? "" : spanEndTag;
openSpan += className + '">';
return openSpan + insideSpan + closeSpan;
}
function processKeywords() {
var keyword_match, last_index, match2, result2;
if (!top.keywords)
return escape(mode_buffer);
result2 = "";
last_index = 0;
top.lexemesRe.lastIndex = 0;
match2 = top.lexemesRe.exec(mode_buffer);
while (match2) {
result2 += escape(mode_buffer.substring(last_index, match2.index));
keyword_match = keywordMatch(top, match2);
if (keyword_match) {
relevance += keyword_match[1];
result2 += buildSpan(keyword_match[0], escape(match2[0]));
} else {
result2 += escape(match2[0]);
}
last_index = top.lexemesRe.lastIndex;
match2 = top.lexemesRe.exec(mode_buffer);
}
return result2 + escape(mode_buffer.substr(last_index));
}
function processSubLanguage() {
var explicit = typeof top.subLanguage === "string";
if (explicit && !languages[top.subLanguage]) {
return escape(mode_buffer);
}
var result2 = explicit ? highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) : highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : void 0);
if (top.relevance > 0) {
relevance += result2.relevance;
}
if (explicit) {
continuations[top.subLanguage] = result2.top;
}
return buildSpan(result2.language, result2.value, false, true);
}
function processBuffer() {
result += top.subLanguage != null ? processSubLanguage() : processKeywords();
mode_buffer = "";
}
function startNewMode(mode) {
result += mode.className ? buildSpan(mode.className, "", true) : "";
top = Object.create(mode, {
parent: {
value: top
}
});
}
function doBeginMatch(match2) {
var lexeme = match2[0];
var new_mode = match2.rule;
if (new_mode && new_mode.endSameAsBegin) {
new_mode.endRe = escapeRe(lexeme);
}
if (new_mode.skip) {
mode_buffer += lexeme;
} else {
if (new_mode.excludeBegin) {
mode_buffer += lexeme;
}
processBuffer();
if (!new_mode.returnBegin && !new_mode.excludeBegin) {
mode_buffer = lexeme;
}
}
startNewMode(new_mode);
return new_mode.returnBegin ? 0 : lexeme.length;
}
function doEndMatch(match2) {
var lexeme = match2[0];
var matchPlusRemainder = codeToHighlight.substr(match2.index);
var end_mode = endOfMode(top, matchPlusRemainder);
if (!end_mode) {
return;
}
var origin = top;
if (origin.skip) {
mode_buffer += lexeme;
} else {
if (!(origin.returnEnd || origin.excludeEnd)) {
mode_buffer += lexeme;
}
processBuffer();
if (origin.excludeEnd) {
mode_buffer = lexeme;
}
}
do {
if (top.className) {
result += spanEndTag;
}
if (!top.skip && !top.subLanguage) {
relevance += top.relevance;
}
top = top.parent;
} while (top !== end_mode.parent);
if (end_mode.starts) {
if (end_mode.endSameAsBegin) {
end_mode.starts.endRe = end_mode.endRe;
}
startNewMode(end_mode.starts);
}
return origin.returnEnd ? 0 : lexeme.length;
}
var lastMatch = {};
function processLexeme(text_before_match, match2) {
var lexeme = match2 && match2[0];
mode_buffer += text_before_match;
if (lexeme == null) {
processBuffer();
return 0;
}
if (lastMatch.type == "begin" && match2.type == "end" && lastMatch.index == match2.index && lexeme === "") {
mode_buffer += codeToHighlight.slice(match2.index, match2.index + 1);
return 1;
}
lastMatch = match2;
if (match2.type === "begin") {
return doBeginMatch(match2);
} else if (match2.type === "illegal" && !ignore_illegals) {
throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || "<unnamed>") + '"');
} else if (match2.type === "end") {
var processed = doEndMatch(match2);
if (processed != void 0)
return processed;
}
mode_buffer += lexeme;
return lexeme.length;
}
var language = getLanguage(languageName);
if (!language) {
console.error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
throw new Error('Unknown language: "' + languageName + '"');
}
compileLanguage(language);
var top = continuation || language;
var continuations = {};
var result = "", current;
for (current = top; current !== language; current = current.parent) {
if (current.className) {
result = buildSpan(current.className, "", true) + result;
}
}
var mode_buffer = "";
var relevance = 0;
try {
var match, count, index = 0;
while (true) {
top.terminators.lastIndex = index;
match = top.terminators.exec(codeToHighlight);
if (!match)
break;
count = processLexeme(codeToHighlight.substring(index, match.index), match);
index = match.index + count;
}
processLexeme(codeToHighlight.substr(index));
for (current = top; current.parent; current = current.parent) {
if (current.className) {
result += spanEndTag;
}
}
return {
relevance,
value: result,
illegal: false,
language: languageName,
top
};
} catch (err) {
if (err.message && err.message.indexOf("Illegal") !== -1) {
return {
illegal: true,
relevance: 0,
value: escape(codeToHighlight)
};
} else if (SAFE_MODE) {
return {
relevance: 0,
value: escape(codeToHighlight),
language: languageName,
top,
errorRaised: err
};
} else {
throw err;
}
}
}
function highlightAuto(code, languageSubset) {
languageSubset = languageSubset || options.languages || objectKeys(languages);
var result = {
relevance: 0,
value: escape(code)
};
var second_best = result;
languageSubset.filter(getLanguage).filter(autoDetection).forEach(function(name) {
var current = highlight(name, code, false);
current.language = name;
if (current.relevance > second_best.relevance) {
second_best = current;
}
if (current.relevance > result.relevance) {
second_best = result;
result = current;
}
});
if (second_best.language) {
result.second_best = second_best;
}
return result;
}
function fixMarkup(value) {
if (!(options.tabReplace || options.useBR)) {
return value;
}
return value.replace(fixMarkupRe, function(match, p1) {
if (options.useBR && match === "\n") {
return "<br>";
} else if (options.tabReplace) {
return p1.replace(/\t/g, options.tabReplace);
}
return "";
});
}
function buildClassName(prevClassName, currentLang, resultLang) {
var language = currentLang ? aliases[currentLang] : resultLang, result = [prevClassName.trim()];
if (!prevClassName.match(/\bhljs\b/)) {
result.push("hljs");
}
if (prevClassName.indexOf(language) === -1) {
result.push(language);
}
return result.join(" ").trim();
}
function highlightBlock(block) {
var node, originalStream, result, resultNode, text;
var language = blockLanguage(block);
if (isNotHighlighted(language))
return;
if (options.useBR) {
node = document.createElement("div");
node.innerHTML = block.innerHTML.replace(/\n/g, "").replace(/<br[ \/]*>/g, "\n");
} else {
node = block;
}
text = node.textContent;
result = language ? highlight(language, text, true) : highlightAuto(text);
originalStream = nodeStream(node);
if (originalStream.length) {
resultNode = document.createElement("div");
resultNode.innerHTML = result.value;
result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
}
result.value = fixMarkup(result.value);
block.innerHTML = result.value;
block.className = buildClassName(block.className, language, result.language);
block.result = {
language: result.language,
re: result.relevance
};
if (result.second_best) {
block.second_best = {
language: result.second_best.language,
re: result.second_best.relevance
};
}
}
function configure(user_options) {
options = inherit(options, user_options);
}
function initHighlighting() {
if (initHighlighting.called)
return;
initHighlighting.called = true;
var blocks = document.querySelectorAll("pre code");
ArrayProto.forEach.call(blocks, highlightBlock);
}
function initHighlightingOnLoad() {
window.addEventListener("DOMContentLoaded", initHighlighting, false);
window.addEventListener("load", initHighlighting, false);
}
var PLAINTEXT_LANGUAGE = {
disableAutodetect: true
};
function registerLanguage(name, language) {
var lang;
try {
lang = language(hljs);
} catch (error) {
console.error("Language definition for '{}' could not be registered.".replace("{}", name));
if (!SAFE_MODE) {
throw error;
} else {
console.error(error);
}
lang = PLAINTEXT_LANGUAGE;
}
languages[name] = lang;
lang.rawDefinition = language.bind(null, hljs);
if (lang.aliases) {
lang.aliases.forEach(function(alias) {
aliases[alias] = name;
});
}
}
function listLanguages() {
return objectKeys(languages);
}
function requireLanguage(name) {
var lang = getLanguage(name);
if (lang) {
return lang;
}
var err = new Error("The '{}' language is required, but not loaded.".replace("{}", name));
throw err;
}
function getLanguage(name) {
name = (name || "").toLowerCase();
return languages[name] || languages[aliases[name]];
}
function autoDetection(name) {
var lang = getLanguage(name);
return lang && !lang.disableAutodetect;
}
hljs.highlight = highlight;
hljs.highlightAuto = highlightAuto;
hljs.fixMarkup = fixMarkup;
hljs.highlightBlock = highlightBlock;
hljs.configure = configure;
hljs.initHighlighting = initHighlighting;
hljs.initHighlightingOnLoad = initHighlightingOnLoad;
hljs.registerLanguage = registerLanguage;
hljs.listLanguages = listLanguages;
hljs.getLanguage = getLanguage;
hljs.requireLanguage = requireLanguage;
hljs.autoDetection = autoDetection;
hljs.inherit = inherit;
hljs.debugMode = function() {
SAFE_MODE = false;
};
hljs.IDENT_RE = "[a-zA-Z]\\w*";
hljs.UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
hljs.NUMBER_RE = "\\b\\d+(\\.\\d+)?";
hljs.C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
hljs.BINARY_NUMBER_RE = "\\b(0b[01]+)";
hljs.RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
hljs.BACKSLASH_ESCAPE = {
begin: "\\\\[\\s\\S]",
relevance: 0
};
hljs.APOS_STRING_MODE = {
className: "string",
begin: "'",
end: "'",
illegal: "\\n",
contains: [hljs.BACKSLASH_ESCAPE]
};
hljs.QUOTE_STRING_MODE = {
className: "string",
begin: '"',
end: '"',
illegal: "\\n",
contains: [hljs.BACKSLASH_ESCAPE]
};
hljs.PHRASAL_WORDS_MODE = {
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
};
hljs.COMMENT = function(begin, end, inherits) {
var mode = hljs.inherit(
{
className: "comment",
begin,
end,
contains: []
},
inherits || {}
);
mode.contains.push(hljs.PHRASAL_WORDS_MODE);
mode.contains.push({
className: "doctag",
begin: "(?:TODO|FIXME|NOTE|BUG|XXX):",
relevance: 0
});
return mode;
};
hljs.C_LINE_COMMENT_MODE = hljs.COMMENT("//", "$");
hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT("/\\*", "\\*/");
hljs.HASH_COMMENT_MODE = hljs.COMMENT("#", "$");
hljs.NUMBER_MODE = {
className: "number",
begin: hljs.NUMBER_RE,
relevance: 0
};
hljs.C_NUMBER_MODE = {
className: "number",
begin: hljs.C_NUMBER_RE,
relevance: 0
};
hljs.BINARY_NUMBER_MODE = {
className: "number",
begin: hljs.BINARY_NUMBER_RE,
relevance: 0
};
hljs.CSS_NUMBER_MODE = {
className: "number",
begin: hljs.NUMBER_RE + "(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
relevance: 0
};
hljs.REGEXP_MODE = {
className: "regexp",
begin: /\//,
end: /\/[gimuy]*/,
illegal: /\n/,
contains: [
hljs.BACKSLASH_ESCAPE,
{
begin: /\[/,
end: /\]/,
relevance: 0,
contains: [hljs.BACKSLASH_ESCAPE]
}
]
};
hljs.TITLE_MODE = {
className: "title",
begin: hljs.IDENT_RE,
relevance: 0
};
hljs.UNDERSCORE_TITLE_MODE = {
className: "title",
begin: hljs.UNDERSCORE_IDENT_RE,
relevance: 0
};
hljs.METHOD_GUARD = {
// excludes method names from keyword processing
begin: "\\.\\s*" + hljs.UNDERSCORE_IDENT_RE,
relevance: 0
};
var constants = [
hljs.BACKSLASH_ESCAPE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.PHRASAL_WORDS_MODE,
hljs.COMMENT,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.HASH_COMMENT_MODE,
hljs.NUMBER_MODE,
hljs.C_NUMBER_MODE,
hljs.BINARY_NUMBER_MODE,
hljs.CSS_NUMBER_MODE,
hljs.REGEXP_MODE,
hljs.TITLE_MODE,
hljs.UNDERSCORE_TITLE_MODE,
hljs.METHOD_GUARD
];
constants.forEach(function(obj) {
deepFreeze(obj);
});
function deepFreeze(o) {
Object.freeze(o);
var objIsFunction = typeof o === "function";
Object.getOwnPropertyNames(o).forEach(function(prop) {
if (o.hasOwnProperty(prop) && o[prop] !== null && (typeof o[prop] === "object" || typeof o[prop] === "function") && (objIsFunction ? prop !== "caller" && prop !== "callee" && prop !== "arguments" : true) && !Object.isFrozen(o[prop])) {
deepFreeze(o[prop]);
}
});
return o;
}
return hljs;
});
exports._hljs = _hljs;
@@ -0,0 +1,18 @@
"use strict";
const components_firstui_fuiParse_highLight_highlight_code = require("./highlight.code.js");
const components_firstui_fuiParse_highLight_languages_javascript = require("./languages/javascript.js");
const components_firstui_fuiParse_highLight_languages_css = require("./languages/css.js");
const components_firstui_fuiParse_highLight_languages_xml = require("./languages/xml.js");
const components_firstui_fuiParse_highLight_languages_sql = require("./languages/sql.js");
const components_firstui_fuiParse_highLight_languages_typescript = require("./languages/typescript.js");
const components_firstui_fuiParse_highLight_languages_markdown = require("./languages/markdown.js");
const components_firstui_fuiParse_highLight_languages_cpp = require("./languages/cpp.js");
const components_firstui_fuiParse_highLight_languages_c = require("./languages/c.js");
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("javascript", components_firstui_fuiParse_highLight_languages_javascript.javascript);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("css", components_firstui_fuiParse_highLight_languages_css.css);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("xml", components_firstui_fuiParse_highLight_languages_xml.xml);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("sql", components_firstui_fuiParse_highLight_languages_sql.sql);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("typescript", components_firstui_fuiParse_highLight_languages_typescript.typescript);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("markdown", components_firstui_fuiParse_highLight_languages_markdown.markdown);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("c++", components_firstui_fuiParse_highLight_languages_cpp.cpp);
components_firstui_fuiParse_highLight_highlight_code._hljs.registerLanguage("c", components_firstui_fuiParse_highLight_languages_c.c);
@@ -0,0 +1,238 @@
"use strict";
const components_firstui_fuiParse_highLight_regex = require("../regex.js");
function cLike(hljs) {
const C_LINE_COMMENT_MODE = hljs.COMMENT("//", "$", {
contains: [{
begin: /\\\n/
}]
});
const DECLTYPE_AUTO_RE = "decltype\\(auto\\)";
const NAMESPACE_RE = "[a-zA-Z_]\\w*::";
const TEMPLATE_ARGUMENT_RE = "<[^<>]+>";
const FUNCTION_TYPE_RE = "(" + DECLTYPE_AUTO_RE + "|" + components_firstui_fuiParse_highLight_regex.optional(NAMESPACE_RE) + "[a-zA-Z_]\\w*" + components_firstui_fuiParse_highLight_regex.optional(TEMPLATE_ARGUMENT_RE) + ")";
const CPP_PRIMITIVE_TYPES = {
className: "keyword",
begin: "\\b[a-z\\d_]*_t\\b"
};
const CHARACTER_ESCAPES = "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)";
const STRINGS = {
className: "string",
variants: [
{
begin: '(u8?|U|L)?"',
end: '"',
illegal: "\\n",
contains: [hljs.BACKSLASH_ESCAPE]
},
{
begin: "(u8?|U|L)?'(" + CHARACTER_ESCAPES + "|.)",
end: "'",
illegal: "."
}
// hljs.END_SAME_AS_BEGIN({
// begin: /(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,
// end: /\)([^()\\ ]{0,16})"/
// })
]
};
const NUMBERS = {
className: "number",
variants: [
{
begin: "\\b(0b[01']+)"
},
{
begin: "(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"
},
{
begin: "(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"
}
],
relevance: 0
};
const PREPROCESSOR = {
className: "meta",
begin: /#\s*[a-z]+\b/,
end: /$/,
keywords: {
"meta-keyword": "if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"
},
contains: [
{
begin: /\\\n/,
relevance: 0
},
hljs.inherit(STRINGS, {
className: "meta-string"
}),
{
className: "meta-string",
begin: /<.*?>/,
end: /$/,
illegal: "\\n"
},
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
};
const TITLE_MODE = {
className: "title",
begin: components_firstui_fuiParse_highLight_regex.optional(NAMESPACE_RE) + hljs.IDENT_RE,
relevance: 0
};
const FUNCTION_TITLE = components_firstui_fuiParse_highLight_regex.optional(NAMESPACE_RE) + hljs.IDENT_RE + "\\s*\\(";
const CPP_KEYWORDS = {
keyword: "int float while private char char8_t char16_t char32_t catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid wchar_t short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignas alignof constexpr consteval constinit decltype concept co_await co_return co_yield requires noexcept static_assert thread_local restrict final override atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq",
built_in: "std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex imaginary _Imaginary",
literal: "true false nullptr NULL"
};
const EXPRESSION_CONTAINS = [
PREPROCESSOR,
CPP_PRIMITIVE_TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
NUMBERS,
STRINGS
];
const EXPRESSION_CONTEXT = {
// This mode covers expression context where we can't expect a function
// definition and shouldn't highlight anything that looks like one:
// `return some()`, `else if()`, `(x*sum(1, 2))`
variants: [
{
begin: /=/,
end: /;/
},
{
begin: /\(/,
end: /\)/
},
{
beginKeywords: "new throw return else",
end: /;/
}
],
keywords: CPP_KEYWORDS,
contains: EXPRESSION_CONTAINS.concat([{
begin: /\(/,
end: /\)/,
keywords: CPP_KEYWORDS,
contains: EXPRESSION_CONTAINS.concat(["self"]),
relevance: 0
}]),
relevance: 0
};
const FUNCTION_DECLARATION = {
className: "function",
begin: "(" + FUNCTION_TYPE_RE + "[\\*&\\s]+)+" + FUNCTION_TITLE,
returnBegin: true,
end: /[{;=]/,
excludeEnd: true,
keywords: CPP_KEYWORDS,
illegal: /[^\w\s\*&:<>]/,
contains: [
{
// to prevent it from being confused as the function title
begin: DECLTYPE_AUTO_RE,
keywords: CPP_KEYWORDS,
relevance: 0
},
{
begin: FUNCTION_TITLE,
returnBegin: true,
contains: [TITLE_MODE],
relevance: 0
},
{
className: "params",
begin: /\(/,
end: /\)/,
keywords: CPP_KEYWORDS,
relevance: 0,
contains: [
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
CPP_PRIMITIVE_TYPES,
// Count matching parentheses.
{
begin: /\(/,
end: /\)/,
keywords: CPP_KEYWORDS,
relevance: 0,
contains: [
"self",
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRINGS,
NUMBERS,
CPP_PRIMITIVE_TYPES
]
}
]
},
CPP_PRIMITIVE_TYPES,
C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
PREPROCESSOR
]
};
return {
aliases: [
"c",
"cc",
"h",
"c++",
"h++",
"hpp",
"hh",
"hxx",
"cxx"
],
keywords: CPP_KEYWORDS,
// the base c-like language will NEVER be auto-detected, rather the
// derivitives: c, c++, arduino turn auto-detect back on for themselves
disableAutodetect: true,
illegal: "</",
contains: [].concat(
EXPRESSION_CONTEXT,
FUNCTION_DECLARATION,
EXPRESSION_CONTAINS,
[
PREPROCESSOR,
{
// containers: ie, `vector <int> rooms (9);`
begin: "\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",
end: ">",
keywords: CPP_KEYWORDS,
contains: [
"self",
CPP_PRIMITIVE_TYPES
]
},
{
begin: hljs.IDENT_RE + "::",
keywords: CPP_KEYWORDS
},
{
className: "class",
beginKeywords: "enum class struct union",
end: /[{;:<>=]/,
contains: [
{
beginKeywords: "final class struct"
},
hljs.TITLE_MODE
]
}
]
),
exports: {
preprocessor: PREPROCESSOR,
strings: STRINGS,
keywords: CPP_KEYWORDS
}
};
}
exports.cLike = cLike;
@@ -0,0 +1,9 @@
"use strict";
const components_firstui_fuiParse_highLight_languages_cLike = require("./c-like.js");
function c(hljs) {
const lang = components_firstui_fuiParse_highLight_languages_cLike.cLike(hljs);
lang.name = "C";
lang.aliases = ["c", "h"];
return lang;
}
exports.c = c;
@@ -0,0 +1,10 @@
"use strict";
const components_firstui_fuiParse_highLight_languages_cLike = require("./c-like.js");
function cpp(hljs) {
const lang = components_firstui_fuiParse_highLight_languages_cLike.cLike(hljs);
lang.disableAutodetect = false;
lang.name = "C++";
lang.aliases = ["cc", "c++", "h++", "hpp", "hh", "hxx", "cxx"];
return lang;
}
exports.cpp = cpp;
@@ -0,0 +1,145 @@
"use strict";
function css(hljs) {
var FUNCTION_LIKE = {
begin: /[\w-]+\(/,
returnBegin: true,
contains: [
{
className: "built_in",
begin: /[\w-]+/
},
{
begin: /\(/,
end: /\)/,
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.CSS_NUMBER_MODE
]
}
]
};
var ATTRIBUTE = {
className: "attribute",
begin: /\S/,
end: ":",
excludeEnd: true,
starts: {
endsWithParent: true,
excludeEnd: true,
contains: [
FUNCTION_LIKE,
hljs.CSS_NUMBER_MODE,
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
hljs.C_BLOCK_COMMENT_MODE,
{
className: "number",
begin: "#[0-9A-Fa-f]+"
},
{
className: "meta",
begin: "!important"
}
]
}
};
var AT_IDENTIFIER = "@[a-z-]+";
var AT_MODIFIERS = "and or not only";
var AT_PROPERTY_RE = /@\-?\w[\w]*(\-\w+)*/;
var IDENT_RE = "[a-zA-Z-][a-zA-Z0-9_-]*";
var RULE = {
begin: /(?:[A-Z\_\.\-]+|--[a-zA-Z0-9_-]+)\s*:/,
returnBegin: true,
end: ";",
endsWithParent: true,
contains: [
ATTRIBUTE
]
};
return {
case_insensitive: true,
illegal: /[=\/|'\$]/,
contains: [
hljs.C_BLOCK_COMMENT_MODE,
{
className: "selector-id",
begin: /#[A-Za-z0-9_-]+/
},
{
className: "selector-class",
begin: /\.[A-Za-z0-9_-]+/
},
{
className: "selector-attr",
begin: /\[/,
end: /\]/,
illegal: "$",
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE
]
},
{
className: "selector-pseudo",
begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/
},
// matching these here allows us to treat them more like regular CSS
// rules so everything between the {} gets regular rule highlighting,
// which is what we want for page and font-face
{
begin: "@(page|font-face)",
lexemes: AT_IDENTIFIER,
keywords: "@page @font-face"
},
{
begin: "@",
end: "[{;]",
// at_rule eating first "{" is a good thing
// because it doesnt let it to be parsed as
// a rule set but instead drops parser into
// the default mode which is how it should be.
illegal: /:/,
// break on Less variables @var: ...
returnBegin: true,
contains: [
{
className: "keyword",
begin: AT_PROPERTY_RE
},
{
begin: /\s/,
endsWithParent: true,
excludeEnd: true,
relevance: 0,
keywords: AT_MODIFIERS,
contains: [
{
begin: /[a-z-]+:/,
className: "attribute"
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.CSS_NUMBER_MODE
]
}
]
},
{
className: "selector-tag",
begin: IDENT_RE,
relevance: 0
},
{
begin: "{",
end: "}",
illegal: /\S/,
contains: [
hljs.C_BLOCK_COMMENT_MODE,
RULE
]
}
]
};
}
exports.css = css;
@@ -0,0 +1,254 @@
"use strict";
function javascript(hljs) {
var FRAGMENT = {
begin: "<>",
end: "</>"
};
var XML_TAG = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/
};
var IDENT_RE = "[A-Za-z$_][0-9A-Za-z$_]*";
var KEYWORDS = {
keyword: "in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",
literal: "true false null undefined NaN Infinity",
built_in: "eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"
};
var NUMBER = {
className: "number",
variants: [
{ begin: "\\b(0[bB][01]+)n?" },
{ begin: "\\b(0[oO][0-7]+)n?" },
{ begin: hljs.C_NUMBER_RE + "n?" }
],
relevance: 0
};
var SUBST = {
className: "subst",
begin: "\\$\\{",
end: "\\}",
keywords: KEYWORDS,
contains: []
// defined later
};
var HTML_TEMPLATE = {
begin: "html`",
end: "",
starts: {
end: "`",
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: "xml"
}
};
var CSS_TEMPLATE = {
begin: "css`",
end: "",
starts: {
end: "`",
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: "css"
}
};
var TEMPLATE_STRING = {
className: "string",
begin: "`",
end: "`",
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
SUBST.contains = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
TEMPLATE_STRING,
NUMBER,
hljs.REGEXP_MODE
];
var PARAMS_CONTAINS = SUBST.contains.concat([
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]);
return {
aliases: ["js", "jsx", "mjs", "cjs"],
keywords: KEYWORDS,
contains: [
{
className: "meta",
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
},
{
className: "meta",
begin: /^#!/,
end: /$/
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
TEMPLATE_STRING,
hljs.C_LINE_COMMENT_MODE,
hljs.COMMENT(
"/\\*\\*",
"\\*/",
{
relevance: 0,
contains: [
{
className: "doctag",
begin: "@[A-Za-z]+",
contains: [
{
className: "type",
begin: "\\{",
end: "\\}",
relevance: 0
},
{
className: "variable",
begin: IDENT_RE + "(?=\\s*(-)|$)",
endsParent: true,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
),
hljs.C_BLOCK_COMMENT_MODE,
NUMBER,
{
// object attr container
begin: /[{,\n]\s*/,
relevance: 0,
contains: [
{
begin: IDENT_RE + "\\s*:",
returnBegin: true,
relevance: 0,
contains: [{ className: "attr", begin: IDENT_RE, relevance: 0 }]
}
]
},
{
// "value" container
begin: "(" + hljs.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
keywords: "return throw case",
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.REGEXP_MODE,
{
className: "function",
begin: "(\\(.*?\\)|" + IDENT_RE + ")\\s*=>",
returnBegin: true,
end: "\\s*=>",
contains: [
{
className: "params",
variants: [
{
begin: IDENT_RE
},
{
begin: /\(\s*\)/
},
{
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: PARAMS_CONTAINS
}
]
}
]
},
{
className: "",
begin: /\s/,
end: /\s*/,
skip: true
},
{
// JSX
variants: [
{ begin: FRAGMENT.begin, end: FRAGMENT.end },
{ begin: XML_TAG.begin, end: XML_TAG.end }
],
subLanguage: "xml",
contains: [
{
begin: XML_TAG.begin,
end: XML_TAG.end,
skip: true,
contains: ["self"]
}
]
}
],
relevance: 0
},
{
className: "function",
beginKeywords: "function",
end: /\{/,
excludeEnd: true,
contains: [
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE }),
{
className: "params",
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
contains: PARAMS_CONTAINS
}
],
illegal: /\[|%/
},
{
begin: /\$[(.]/
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
},
hljs.METHOD_GUARD,
{
// ES6 class
className: "class",
beginKeywords: "class",
end: /[{;=]/,
excludeEnd: true,
illegal: /[:"\[\]]/,
contains: [
{ beginKeywords: "extends" },
hljs.UNDERSCORE_TITLE_MODE
]
},
{
beginKeywords: "constructor get set",
end: /\{/,
excludeEnd: true
}
],
illegal: /#(?!!)/
};
}
exports.javascript = javascript;
@@ -0,0 +1,123 @@
"use strict";
function markdown(hljs) {
return {
aliases: ["md", "mkdown", "mkd"],
contains: [
// highlight headers
{
className: "section",
variants: [
{ begin: "^#{1,6}", end: "$" },
{ begin: "^.+?\\n[=-]{2,}$" }
]
},
// inline html
{
begin: "<",
end: ">",
subLanguage: "xml",
relevance: 0
},
// lists (indicators only)
{
className: "bullet",
begin: "^\\s*([*+-]|(\\d+\\.))\\s+"
},
// strong segments
{
className: "strong",
begin: "[*_]{2}.+?[*_]{2}"
},
// emphasis segments
{
className: "emphasis",
variants: [
{ begin: "\\*.+?\\*" },
{
begin: "_.+?_",
relevance: 0
}
]
},
// blockquotes
{
className: "quote",
begin: "^>\\s+",
end: "$"
},
// code snippets
{
className: "code",
variants: [
{
begin: "^```\\w*\\s*$",
end: "^```[ ]*$"
},
{
begin: "`.+?`"
},
{
begin: "^( {4}|\\t)",
end: "$",
relevance: 0
}
]
},
// horizontal rules
{
begin: "^[-\\*]{3,}",
end: "$"
},
// using links - title and link
{
begin: "\\[.+?\\][\\(\\[].*?[\\)\\]]",
returnBegin: true,
contains: [
{
className: "string",
begin: "\\[",
end: "\\]",
excludeBegin: true,
returnEnd: true,
relevance: 0
},
{
className: "link",
begin: "\\]\\(",
end: "\\)",
excludeBegin: true,
excludeEnd: true
},
{
className: "symbol",
begin: "\\]\\[",
end: "\\]",
excludeBegin: true,
excludeEnd: true
}
],
relevance: 10
},
{
begin: /^\[[^\n]+\]:/,
returnBegin: true,
contains: [
{
className: "symbol",
begin: /\[/,
end: /\]/,
excludeBegin: true,
excludeEnd: true
},
{
className: "link",
begin: /:\s*/,
end: /$/,
excludeBegin: true
}
]
}
]
};
}
exports.markdown = markdown;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,212 @@
"use strict";
function typescript(hljs) {
var JS_IDENT_RE = "[A-Za-z$_][0-9A-Za-z$_]*";
var KEYWORDS = {
keyword: "in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class public private protected get set super static implements enum export import declare type namespace abstract as from extends async await",
literal: "true false null undefined NaN Infinity",
built_in: "eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document any number boolean string void Promise"
};
var DECORATOR = {
className: "meta",
begin: "@" + JS_IDENT_RE
};
var ARGS = {
begin: "\\(",
end: /\)/,
keywords: KEYWORDS,
contains: [
"self",
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
hljs.NUMBER_MODE
]
};
var PARAMS = {
className: "params",
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
DECORATOR,
ARGS
]
};
var NUMBER = {
className: "number",
variants: [
{ begin: "\\b(0[bB][01]+)n?" },
{ begin: "\\b(0[oO][0-7]+)n?" },
{ begin: hljs.C_NUMBER_RE + "n?" }
],
relevance: 0
};
var SUBST = {
className: "subst",
begin: "\\$\\{",
end: "\\}",
keywords: KEYWORDS,
contains: []
// defined later
};
var HTML_TEMPLATE = {
begin: "html`",
end: "",
starts: {
end: "`",
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: "xml"
}
};
var CSS_TEMPLATE = {
begin: "css`",
end: "",
starts: {
end: "`",
returnEnd: false,
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
],
subLanguage: "css"
}
};
var TEMPLATE_STRING = {
className: "string",
begin: "`",
end: "`",
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
SUBST.contains = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
TEMPLATE_STRING,
NUMBER,
hljs.REGEXP_MODE
];
return {
aliases: ["ts"],
keywords: KEYWORDS,
contains: [
{
className: "meta",
begin: /^\s*['"]use strict['"]/
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
HTML_TEMPLATE,
CSS_TEMPLATE,
TEMPLATE_STRING,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
NUMBER,
{
// "value" container
begin: "(" + hljs.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
keywords: "return throw case",
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.REGEXP_MODE,
{
className: "function",
begin: "(\\(.*?\\)|" + hljs.IDENT_RE + ")\\s*=>",
returnBegin: true,
end: "\\s*=>",
contains: [
{
className: "params",
variants: [
{
begin: hljs.IDENT_RE
},
{
begin: /\(\s*\)/
},
{
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
"self",
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
}
]
}
]
}
],
relevance: 0
},
{
className: "function",
beginKeywords: "function",
end: /[\{;]/,
excludeEnd: true,
keywords: KEYWORDS,
contains: [
"self",
hljs.inherit(hljs.TITLE_MODE, { begin: JS_IDENT_RE }),
PARAMS
],
illegal: /%/,
relevance: 0
// () => {} is more typical in TypeScript
},
{
beginKeywords: "constructor",
end: /[\{;]/,
excludeEnd: true,
contains: [
"self",
PARAMS
]
},
{
// prevent references like module.id from being higlighted as module definitions
begin: /module\./,
keywords: { built_in: "module" },
relevance: 0
},
{
beginKeywords: "module",
end: /\{/,
excludeEnd: true
},
{
beginKeywords: "interface",
end: /\{/,
excludeEnd: true,
keywords: "interface extends"
},
{
begin: /\$[(.]/
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
},
{
begin: "\\." + hljs.IDENT_RE,
relevance: 0
// hack: prevents detection of keywords after dots
},
DECORATOR,
ARGS
]
};
}
exports.typescript = typescript;
@@ -0,0 +1,161 @@
"use strict";
function xml(hljs) {
var XML_IDENT_RE = "[A-Za-z0-9\\._:-]+";
var XML_ENTITIES = {
className: "symbol",
begin: "&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;"
};
var XML_META_KEYWORDS = {
begin: "\\s",
contains: [
{
className: "meta-keyword",
begin: "#?[a-z_][a-z1-9_-]+",
illegal: "\\n"
}
]
};
var XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, { begin: "\\(", end: "\\)" });
var APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, { className: "meta-string" });
var QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, { className: "meta-string" });
var TAG_INTERNALS = {
endsWithParent: true,
illegal: /</,
relevance: 0,
contains: [
{
className: "attr",
begin: XML_IDENT_RE,
relevance: 0
},
{
begin: /=\s*/,
relevance: 0,
contains: [
{
className: "string",
endsParent: true,
variants: [
{ begin: /"/, end: /"/, contains: [XML_ENTITIES] },
{ begin: /'/, end: /'/, contains: [XML_ENTITIES] },
{ begin: /[^\s"'=<>`]+/ }
]
}
]
}
]
};
return {
aliases: ["html", "xhtml", "rss", "atom", "xjb", "xsd", "xsl", "plist", "wsf", "svg"],
case_insensitive: true,
contains: [
{
className: "meta",
begin: "<![a-z]",
end: ">",
relevance: 10,
contains: [
XML_META_KEYWORDS,
QUOTE_META_STRING_MODE,
APOS_META_STRING_MODE,
XML_META_PAR_KEYWORDS,
{
begin: "\\[",
end: "\\]",
contains: [
{
className: "meta",
begin: "<![a-z]",
end: ">",
contains: [
XML_META_KEYWORDS,
XML_META_PAR_KEYWORDS,
QUOTE_META_STRING_MODE,
APOS_META_STRING_MODE
]
}
]
}
]
},
hljs.COMMENT(
"<!--",
"-->",
{
relevance: 10
}
),
{
begin: "<\\!\\[CDATA\\[",
end: "\\]\\]>",
relevance: 10
},
XML_ENTITIES,
{
className: "meta",
begin: /<\?xml/,
end: /\?>/,
relevance: 10
},
{
begin: /<\?(php)?/,
end: /\?>/,
subLanguage: "php",
contains: [
// We don't want the php closing tag ?> to close the PHP block when
// inside any of the following blocks:
{ begin: "/\\*", end: "\\*/", skip: true },
{ begin: 'b"', end: '"', skip: true },
{ begin: "b'", end: "'", skip: true },
hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null, className: null, contains: null, skip: true }),
hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null, className: null, contains: null, skip: true })
]
},
{
className: "tag",
/*
The lookahead pattern (?=...) ensures that 'begin' only matches
'<style' as a single word, followed by a whitespace or an
ending braket. The '$' is needed for the lexeme to be recognized
by hljs.subMode() that tests lexemes outside the stream.
*/
begin: "<style(?=\\s|>)",
end: ">",
keywords: { name: "style" },
contains: [TAG_INTERNALS],
starts: {
end: "</style>",
returnEnd: true,
subLanguage: ["css", "xml"]
}
},
{
className: "tag",
// See the comment in the <style tag about the lookahead pattern
begin: "<script(?=\\s|>)",
end: ">",
keywords: { name: "script" },
contains: [TAG_INTERNALS],
starts: {
end: "<\/script>",
returnEnd: true,
subLanguage: ["actionscript", "javascript", "handlebars", "xml"]
}
},
{
className: "tag",
begin: "</?",
end: "/?>",
contains: [
{
className: "name",
begin: /[^\/><\s]+/,
relevance: 0
},
TAG_INTERNALS
]
}
]
};
}
exports.xml = xml;
@@ -0,0 +1,16 @@
"use strict";
function source(re) {
if (!re)
return null;
if (typeof re === "string")
return re;
return re.source;
}
function optional(re) {
return concat("(", re, ")?");
}
function concat(...args) {
const joined = args.map((x) => source(x)).join("");
return joined;
}
exports.optional = optional;
@@ -0,0 +1,988 @@
"use strict";
var block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: noop,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
nptable: noop,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: "^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$))",
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
table: noop,
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
text: /^[^\n]+/
};
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
block.bullet = /(?:[*+-]|\d+\.)/;
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
block.item = edit(block.item, "gm").replace(/bull/g, block.bullet).getRegex();
block.list = edit(block.list).replace(/bull/g, block.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + block.def.source + ")").getRegex();
block._tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
block._comment = /<!--(?!-?>)[\s\S]*?-->/;
block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
block.paragraph = edit(block.paragraph).replace("hr", block.hr).replace("heading", block.heading).replace("lheading", block.lheading).replace("tag", block._tag).getRegex();
block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex();
block.normal = merge({}, block);
block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
block.gfm.paragraph = edit(block.paragraph).replace("(?!", "(?!" + block.gfm.fences.source.replace("\\1", "\\2") + "|" + block.list.source.replace("\\1", "\\3") + "|").getRegex();
block.tables = merge({}, block.gfm, {
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
});
block.pedantic = merge({}, block.normal, {
html: edit(
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
).replace("comment", block._comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
});
function Lexer(options) {
this.tokens = [];
this.tokens.links = /* @__PURE__ */ Object.create(null);
this.options = options || marked.defaults;
this.rules = block.normal;
if (this.options.pedantic) {
this.rules = block.pedantic;
} else if (this.options.gfm) {
if (this.options.tables) {
this.rules = block.tables;
} else {
this.rules = block.gfm;
}
}
}
Lexer.rules = block;
Lexer.lex = function(src, options) {
var lexer = new Lexer(options);
return lexer.lex(src);
};
Lexer.prototype.lex = function(src) {
src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ").replace(/\u00a0/g, " ").replace(/\u2424/g, "\n");
return this.token(src, true);
};
Lexer.prototype.token = function(src, top) {
src = src.replace(/^ +$/gm, "");
var next, loose, cap, bull, b, item, listStart, listItems, t, space, i, tag, l, isordered, istask, ischecked;
while (src) {
if (cap = this.rules.newline.exec(src)) {
src = src.substring(cap[0].length);
if (cap[0].length > 1) {
this.tokens.push({
type: "space"
});
}
}
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
cap = cap[0].replace(/^ {4}/gm, "");
this.tokens.push({
type: "code",
text: !this.options.pedantic ? rtrim(cap, "\n") : cap
});
continue;
}
if (cap = this.rules.fences.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "code",
lang: cap[2],
text: cap[3] || ""
});
continue;
}
if (cap = this.rules.heading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "heading",
depth: cap[1].length,
text: cap[2]
});
continue;
}
if (top && (cap = this.rules.nptable.exec(src))) {
item = {
type: "table",
header: splitCells(cap[1].replace(/^ *| *\| *$/g, "")),
align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
cells: cap[3] ? cap[3].replace(/\n$/, "").split("\n") : []
};
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = "right";
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = "center";
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = "left";
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = splitCells(item.cells[i], item.header.length);
}
this.tokens.push(item);
continue;
}
}
if (cap = this.rules.hr.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "hr"
});
continue;
}
if (cap = this.rules.blockquote.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "blockquote_start"
});
cap = cap[0].replace(/^ *> ?/gm, "");
this.token(cap, top);
this.tokens.push({
type: "blockquote_end"
});
continue;
}
if (cap = this.rules.list.exec(src)) {
src = src.substring(cap[0].length);
bull = cap[2];
isordered = bull.length > 1;
listStart = {
type: "list_start",
ordered: isordered,
start: isordered ? +bull : "",
loose: false
};
this.tokens.push(listStart);
cap = cap[0].match(this.rules.item);
listItems = [];
next = false;
l = cap.length;
i = 0;
for (; i < l; i++) {
item = cap[i];
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) +/, "");
if (~item.indexOf("\n ")) {
space -= item.length;
item = !this.options.pedantic ? item.replace(new RegExp("^ {1," + space + "}", "gm"), "") : item.replace(/^ {1,4}/gm, "");
}
if (this.options.smartLists && i !== l - 1) {
b = block.bullet.exec(cap[i + 1])[0];
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
src = cap.slice(i + 1).join("\n") + src;
i = l - 1;
}
}
loose = next || /\n\n(?!\s*$)/.test(item);
if (i !== l - 1) {
next = item.charAt(item.length - 1) === "\n";
if (!loose)
loose = next;
}
if (loose) {
listStart.loose = true;
}
istask = /^\[[ xX]\] /.test(item);
ischecked = void 0;
if (istask) {
ischecked = item[1] !== " ";
item = item.replace(/^\[[ xX]\] +/, "");
}
t = {
type: "list_item_start",
task: istask,
checked: ischecked,
loose
};
listItems.push(t);
this.tokens.push(t);
this.token(item, false);
this.tokens.push({
type: "list_item_end"
});
}
if (listStart.loose) {
l = listItems.length;
i = 0;
for (; i < l; i++) {
listItems[i].loose = true;
}
}
this.tokens.push({
type: "list_end"
});
continue;
}
if (cap = this.rules.html.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize ? "paragraph" : "html",
pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
text: cap[0]
});
continue;
}
if (top && (cap = this.rules.def.exec(src))) {
src = src.substring(cap[0].length);
if (cap[3])
cap[3] = cap[3].substring(1, cap[3].length - 1);
tag = cap[1].toLowerCase().replace(/\s+/g, " ");
if (!this.tokens.links[tag]) {
this.tokens.links[tag] = {
href: cap[2],
title: cap[3]
};
}
continue;
}
if (top && (cap = this.rules.table.exec(src))) {
item = {
type: "table",
header: splitCells(cap[1].replace(/^ *| *\| *$/g, "")),
align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, "").split("\n") : []
};
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = "right";
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = "center";
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = "left";
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = splitCells(
item.cells[i].replace(/^ *\| *| *\| *$/g, ""),
item.header.length
);
}
this.tokens.push(item);
continue;
}
}
if (cap = this.rules.lheading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "heading",
depth: cap[2] === "=" ? 1 : 2,
text: cap[1]
});
continue;
}
if (top && (cap = this.rules.paragraph.exec(src))) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "paragraph",
text: cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1]
});
continue;
}
if (cap = this.rules.text.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: "text",
text: cap[0]
});
continue;
}
if (src) {
throw new Error("Infinite loop on byte: " + src.charCodeAt(0));
}
}
return this.tokens;
};
var inline = {
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
url: noop,
tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
// CDATA section
link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
br: /^( {2,}|\\)\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
};
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
inline.tag = edit(inline.tag).replace("comment", block._comment).replace("attribute", inline._attribute).getRegex();
inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/;
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex();
inline.reflink = edit(inline.reflink).replace("label", inline._label).getRegex();
inline.normal = merge({}, inline);
inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline._label).getRegex(),
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline._label).getRegex()
});
inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace("])", "~|])").getRegex(),
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("email", inline._email).getRegex(),
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/,
text: edit(inline.text).replace("]|", "~]|").replace("|", "|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&'*+/=?^_`{\\|}~-]+@|").getRegex()
});
inline.breaks = merge({}, inline.gfm, {
br: edit(inline.br).replace("{2,}", "*").getRegex(),
text: edit(inline.gfm.text).replace("{2,}", "*").getRegex()
});
function InlineLexer(links, options) {
this.options = options || marked.defaults;
this.links = links;
this.rules = inline.normal;
this.renderer = this.options.renderer || new Renderer();
this.renderer.options = this.options;
if (!this.links) {
throw new Error("Tokens array requires a `links` property.");
}
if (this.options.pedantic) {
this.rules = inline.pedantic;
} else if (this.options.gfm) {
if (this.options.breaks) {
this.rules = inline.breaks;
} else {
this.rules = inline.gfm;
}
}
}
InlineLexer.rules = inline;
InlineLexer.output = function(src, links, options) {
var inline2 = new InlineLexer(links, options);
return inline2.output(src);
};
InlineLexer.prototype.output = function(src) {
var out = "", link, text, href, title, cap, prevCapZero;
while (src) {
if (cap = this.rules.escape.exec(src)) {
src = src.substring(cap[0].length);
out += cap[1];
continue;
}
if (cap = this.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === "@") {
text = escape(this.mangle(cap[1]));
href = "mailto:" + text;
} else {
text = escape(cap[1]);
href = text;
}
out += this.renderer.link(href, null, text);
continue;
}
if (!this.inLink && (cap = this.rules.url.exec(src))) {
do {
prevCapZero = cap[0];
cap[0] = this.rules._backpedal.exec(cap[0])[0];
} while (prevCapZero !== cap[0]);
src = src.substring(cap[0].length);
if (cap[2] === "@") {
text = escape(cap[0]);
href = "mailto:" + text;
} else {
text = escape(cap[0]);
if (cap[1] === "www.") {
href = "http://" + text;
} else {
href = text;
}
}
out += this.renderer.link(href, null, text);
continue;
}
if (cap = this.rules.tag.exec(src)) {
if (!this.inLink && /^<a /i.test(cap[0])) {
this.inLink = true;
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
this.inLink = false;
}
src = src.substring(cap[0].length);
out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
continue;
}
if (cap = this.rules.link.exec(src)) {
src = src.substring(cap[0].length);
this.inLink = true;
href = cap[2];
if (this.options.pedantic) {
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
if (link) {
href = link[1];
title = link[3];
} else {
title = "";
}
} else {
title = cap[3] ? cap[3].slice(1, -1) : "";
}
href = href.trim().replace(/^<([\s\S]*)>$/, "$1");
out += this.outputLink(cap, {
href: InlineLexer.escapes(href),
title: InlineLexer.escapes(title)
});
this.inLink = false;
continue;
}
if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
src = src.substring(cap[0].length);
link = (cap[2] || cap[1]).replace(/\s+/g, " ");
link = this.links[link.toLowerCase()];
if (!link || !link.href) {
out += cap[0].charAt(0);
src = cap[0].substring(1) + src;
continue;
}
this.inLink = true;
out += this.outputLink(cap, link);
this.inLink = false;
continue;
}
if (cap = this.rules.strong.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}
if (cap = this.rules.em.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.codespan(escape(cap[2].trim(), true));
continue;
}
if (cap = this.rules.br.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.br();
continue;
}
if (cap = this.rules.del.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.del(this.output(cap[1]));
continue;
}
if (cap = this.rules.text.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.text(escape(this.smartypants(cap[0])));
continue;
}
if (src) {
throw new Error("Infinite loop on byte: " + src.charCodeAt(0));
}
}
return out;
};
InlineLexer.escapes = function(text) {
return text ? text.replace(InlineLexer.rules._escapes, "$1") : text;
};
InlineLexer.prototype.outputLink = function(cap, link) {
var href = link.href, title = link.title ? escape(link.title) : null;
return cap[0].charAt(0) !== "!" ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]));
};
InlineLexer.prototype.smartypants = function(text) {
if (!this.options.smartypants)
return text;
return text.replace(/---/g, "—").replace(/--/g, "").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1").replace(/'/g, "").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1“").replace(/"/g, "”").replace(/\.{3}/g, "…");
};
InlineLexer.prototype.mangle = function(text) {
if (!this.options.mangle)
return text;
var out = "", l = text.length, i = 0, ch;
for (; i < l; i++) {
ch = text.charCodeAt(i);
if (Math.random() > 0.5) {
ch = "x" + ch.toString(16);
}
out += "&#" + ch + ";";
}
return out;
};
function Renderer(options) {
this.options = options || marked.defaults;
}
Renderer.prototype.code = function(code, lang, escaped) {
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
escaped = true;
code = out;
}
}
if (!lang) {
return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>";
}
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
};
Renderer.prototype.blockquote = function(quote) {
return "<blockquote>\n" + quote + "</blockquote>\n";
};
Renderer.prototype.html = function(html) {
return html;
};
Renderer.prototype.heading = function(text, level, raw) {
if (this.options.headerIds) {
return "<h" + level + ' id="' + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, "-") + '">' + text + "</h" + level + ">\n";
}
return "<h" + level + ">" + text + "</h" + level + ">\n";
};
Renderer.prototype.hr = function() {
return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
};
Renderer.prototype.list = function(body, ordered, start) {
var type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
};
Renderer.prototype.listitem = function(text) {
return "<li>" + text + "</li>\n";
};
Renderer.prototype.checkbox = function(checked) {
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
};
Renderer.prototype.paragraph = function(text) {
return "<p>" + text + "</p>\n";
};
Renderer.prototype.table = function(header, body) {
if (body)
body = "<tbody>" + body + "</tbody>";
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
};
Renderer.prototype.tablerow = function(content) {
return "<tr>\n" + content + "</tr>\n";
};
Renderer.prototype.tablecell = function(content, flags) {
var type = flags.header ? "th" : "td";
var tag = flags.align ? "<" + type + ' align="' + flags.align + '">' : "<" + type + ">";
return tag + content + "</" + type + ">\n";
};
Renderer.prototype.strong = function(text) {
return "<strong>" + text + "</strong>";
};
Renderer.prototype.em = function(text) {
return "<em>" + text + "</em>";
};
Renderer.prototype.codespan = function(text) {
return "<code>" + text + "</code>";
};
Renderer.prototype.br = function() {
return this.options.xhtml ? "<br/>" : "<br>";
};
Renderer.prototype.del = function(text) {
return "<del>" + text + "</del>";
};
Renderer.prototype.link = function(href, title, text) {
if (this.options.sanitize) {
try {
var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, "").toLowerCase();
} catch (e) {
return text;
}
if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf(
"data:"
) === 0) {
return text;
}
}
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
try {
href = encodeURI(href).replace(/%25/g, "%");
} catch (e) {
return text;
}
var out = '<a href="' + escape(href) + '"';
if (title) {
out += ' title="' + title + '"';
}
out += ">" + text + "</a>";
return out;
};
Renderer.prototype.image = function(href, title, text) {
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
var out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
}
out += this.options.xhtml ? "/>" : ">";
return out;
};
Renderer.prototype.text = function(text) {
return text;
};
function TextRenderer() {
}
TextRenderer.prototype.strong = TextRenderer.prototype.em = TextRenderer.prototype.codespan = TextRenderer.prototype.del = TextRenderer.prototype.text = function(text) {
return text;
};
TextRenderer.prototype.link = TextRenderer.prototype.image = function(href, title, text) {
return "" + text;
};
TextRenderer.prototype.br = function() {
return "";
};
function Parser(options) {
this.tokens = [];
this.token = null;
this.options = options || marked.defaults;
this.options.renderer = this.options.renderer || new Renderer();
this.renderer = this.options.renderer;
this.renderer.options = this.options;
}
Parser.parse = function(src, options) {
var parser = new Parser(options);
return parser.parse(src);
};
Parser.prototype.parse = function(src) {
this.inline = new InlineLexer(src.links, this.options);
this.inlineText = new InlineLexer(
src.links,
merge({}, this.options, {
renderer: new TextRenderer()
})
);
this.tokens = src.reverse();
var out = "";
while (this.next()) {
out += this.tok();
}
return out;
};
Parser.prototype.next = function() {
return this.token = this.tokens.pop();
};
Parser.prototype.peek = function() {
return this.tokens[this.tokens.length - 1] || 0;
};
Parser.prototype.parseText = function() {
var body = this.token.text;
while (this.peek().type === "text") {
body += "\n" + this.next().text;
}
return this.inline.output(body);
};
Parser.prototype.tok = function() {
switch (this.token.type) {
case "space": {
return "";
}
case "hr": {
return this.renderer.hr();
}
case "heading": {
return this.renderer.heading(
this.inline.output(this.token.text),
this.token.depth,
unescape(this.inlineText.output(this.token.text))
);
}
case "code": {
return this.renderer.code(
this.token.text,
this.token.lang,
this.token.escaped
);
}
case "table": {
var header = "", body = "", i, row, cell, j;
cell = "";
for (i = 0; i < this.token.header.length; i++) {
cell += this.renderer.tablecell(
this.inline.output(this.token.header[i]),
{
header: true,
align: this.token.align[i]
}
);
}
header += this.renderer.tablerow(cell);
for (i = 0; i < this.token.cells.length; i++) {
row = this.token.cells[i];
cell = "";
for (j = 0; j < row.length; j++) {
cell += this.renderer.tablecell(
this.inline.output(row[j]),
{
header: false,
align: this.token.align[j]
}
);
}
body += this.renderer.tablerow(cell);
}
return this.renderer.table(header, body);
}
case "blockquote_start": {
body = "";
while (this.next().type !== "blockquote_end") {
body += this.tok();
}
return this.renderer.blockquote(body);
}
case "list_start": {
body = "";
var ordered = this.token.ordered, start = this.token.start;
while (this.next().type !== "list_end") {
body += this.tok();
}
return this.renderer.list(body, ordered, start);
}
case "list_item_start": {
body = "";
var loose = this.token.loose;
if (this.token.task) {
body += this.renderer.checkbox(this.token.checked);
}
while (this.next().type !== "list_item_end") {
body += !loose && this.token.type === "text" ? this.parseText() : this.tok();
}
return this.renderer.listitem(body);
}
case "html": {
return this.renderer.html(this.token.text);
}
case "paragraph": {
return this.renderer.paragraph(this.inline.output(this.token.text));
}
case "text": {
return this.renderer.paragraph(this.parseText());
}
}
};
function escape(html, encode) {
return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function unescape(html) {
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
n = n.toLowerCase();
if (n === "colon")
return ":";
if (n.charAt(0) === "#") {
return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
}
return "";
});
}
function edit(regex, opt) {
regex = regex.source || regex;
opt = opt || "";
return {
replace: function(name, val) {
val = val.source || val;
val = val.replace(/(^|[^\[])\^/g, "$1");
regex = regex.replace(name, val);
return this;
},
getRegex: function() {
return new RegExp(regex, opt);
}
};
}
function resolveUrl(base, href) {
if (!baseUrls[" " + base]) {
if (/^[^:]+:\/*[^/]*$/.test(base)) {
baseUrls[" " + base] = base + "/";
} else {
baseUrls[" " + base] = rtrim(base, "/", true);
}
}
base = baseUrls[" " + base];
if (href.slice(0, 2) === "//") {
return base.replace(/:[\s\S]*/, ":") + href;
} else if (href.charAt(0) === "/") {
return base.replace(/(:\/*[^/]*)[\s\S]*/, "$1") + href;
} else {
return base + href;
}
}
var baseUrls = {};
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
function noop() {
}
noop.exec = noop;
function merge(obj) {
var i = 1, target, key;
for (; i < arguments.length; i++) {
target = arguments[i];
for (key in target) {
if (Object.prototype.hasOwnProperty.call(target, key)) {
obj[key] = target[key];
}
}
}
return obj;
}
function splitCells(tableRow, count) {
var row = tableRow.replace(/\|/g, function(match, offset, str) {
var escaped = false, curr = offset;
while (--curr >= 0 && str[curr] === "\\")
escaped = !escaped;
if (escaped) {
return "|";
} else {
return " |";
}
}), cells = row.split(/ \|/), i = 0;
if (cells.length > count) {
cells.splice(count);
} else {
while (cells.length < count)
cells.push("");
}
for (; i < cells.length; i++) {
cells[i] = cells[i].trim().replace(/\\\|/g, "|");
}
return cells;
}
function rtrim(str, c, invert) {
if (str.length === 0) {
return "";
}
var suffLen = 0;
while (suffLen < str.length) {
var currChar = str.charAt(str.length - suffLen - 1);
if (currChar === c && !invert) {
suffLen++;
} else if (currChar !== c && invert) {
suffLen++;
} else {
break;
}
}
return str.substr(0, str.length - suffLen);
}
function marked(src, opt, callback) {
if (typeof src === "undefined" || src === null) {
throw new Error("marked(): input parameter is undefined or null");
}
if (typeof src !== "string") {
throw new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected");
}
if (callback || typeof opt === "function") {
if (!callback) {
callback = opt;
opt = null;
}
opt = merge({}, marked.defaults, opt || {});
var highlight = opt.highlight, tokens, pending, i = 0;
try {
tokens = Lexer.lex(src, opt);
} catch (e) {
return callback(e);
}
pending = tokens.length;
var done = function(err) {
if (err) {
opt.highlight = highlight;
return callback(err);
}
var out;
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
opt.highlight = highlight;
return err ? callback(err) : callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!pending)
return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== "code") {
return --pending || done();
}
return highlight(token.text, token.lang, function(err, code) {
if (err)
return done(err);
if (code == null || code === token.text) {
return --pending || done();
}
token.text = code;
token.escaped = true;
--pending || done();
});
})(tokens[i]);
}
return;
}
try {
if (opt)
opt = merge({}, marked.defaults, opt);
return Parser.parse(Lexer.lex(src, opt), opt);
} catch (e) {
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
if ((opt || marked.defaults).silent) {
return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
}
throw e;
}
}
marked.options = marked.setOptions = function(opt) {
merge(marked.defaults, opt);
return marked;
};
marked.getDefaults = function() {
return {
baseUrl: null,
breaks: false,
gfm: true,
headerIds: true,
headerPrefix: "",
highlight: null,
langPrefix: "language-",
mangle: true,
pedantic: false,
renderer: new Renderer(),
sanitize: false,
sanitizer: null,
silent: false,
smartLists: false,
smartypants: false,
tables: true,
xhtml: false
};
};
marked.defaults = marked.getDefaults();
marked.Parser = Parser;
marked.parser = Parser.parse;
marked.Renderer = Renderer;
marked.TextRenderer = TextRenderer;
marked.Lexer = Lexer;
marked.lexer = Lexer.lex;
marked.InlineLexer = InlineLexer;
marked.inlineLexer = InlineLexer.output;
marked.parse = marked;
exports.marked = marked;
@@ -0,0 +1,231 @@
"use strict";
const components_firstui_fuiParse_utils_wxDiscode = require("./wxDiscode.js");
const components_firstui_fuiParse_utils_htmlparser = require("./htmlparser.js");
var __placeImgeUrlHttps = "https";
var __emojisReg = "";
var __emojisBaseSrc = "";
var __emojis = {};
makeMap(
"area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"
);
var block = makeMap(
"br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"
);
var inline = makeMap(
"abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"
);
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
makeMap(
"checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"
);
makeMap("wxxxcode-style,script,style,view,scroll-view,block");
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
function removeDOCTYPE(html) {
return html.replace(/<\?xml.*\?>\n/, "").replace(/<.*!doctype.*\>\n/, "").replace(/<.*!DOCTYPE.*\>\n/, "");
}
function trimHtml(html) {
return html.replace(/<!--.*?-->/ig, "").replace(/[ ]+</ig, "<");
}
function removeInvalidTags(html) {
return html.replace(/\<head(.|\n)*<\/head\>/ig, "").replace(/\<title(.|\n)*<\/title\>/ig, "").replace(/\<script(.|\n)*<\/script\>/ig, "").replace(/\<meta(.|\n)*<\/meta\>/ig, "").replace(/\<style(.|\n)*<\/style\>/gm, "");
}
function html2json(html, bindName) {
html = removeDOCTYPE(html);
html = removeInvalidTags(html);
html = trimHtml(html);
html = components_firstui_fuiParse_utils_wxDiscode.wxDiscode.strDiscode(html);
var bufArray = [];
var results = {
node: bindName,
nodes: [],
images: [],
imageUrls: []
};
var index = 0;
components_firstui_fuiParse_utils_htmlparser.HTMLParser(html, {
start: function(tag, attrs, unary, content) {
var node = {
node: "element",
tag
};
content && (node["content"] = content);
if (bufArray.length === 0) {
node.index = index.toString();
index += 1;
} else {
var parent = bufArray[0];
if (parent.nodes === void 0) {
parent.nodes = [];
}
node.index = parent.index + "." + parent.nodes.length;
}
if (block[tag]) {
node.tagType = "block";
} else if (inline[tag]) {
node.tagType = "inline";
} else if (closeSelf[tag]) {
node.tagType = "closeSelf";
}
if (attrs.length !== 0) {
node.attr = attrs.reduce(function(pre, attr) {
var name = attr.name;
var value2 = attr.value;
if (name == "class") {
node.classStr = value2;
}
if (name == "style") {
node.styleStr = value2;
}
if (value2.match(/ /)) {
value2 = value2.split(" ");
}
if (pre[name]) {
if (Array.isArray(pre[name])) {
pre[name].push(value2);
} else {
pre[name] = [pre[name], value2];
}
} else {
pre[name] = value2;
}
return pre;
}, {});
}
if (node.tag === "img") {
node.imgIndex = results.images.length;
var imgUrl = node.attr.src;
if (imgUrl[0] == "") {
imgUrl.splice(0, 1);
}
imgUrl = components_firstui_fuiParse_utils_wxDiscode.wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
node.attr.src = imgUrl;
node.from = bindName;
results.images.push(node);
results.imageUrls.push(imgUrl);
}
if (node.tag === "font") {
var fontSize = [
"x-small",
"small",
"medium",
"large",
"x-large",
"xx-large",
"-webkit-xxx-large"
];
var styleAttrs = {
"color": "color",
"face": "font-family",
"size": "font-size"
};
if (!node.attr.style)
node.attr.style = [];
if (!node.styleStr)
node.styleStr = "";
for (var key in styleAttrs) {
if (node.attr[key]) {
var value = key === "size" ? fontSize[node.attr[key] - 1] : node.attr[key];
node.attr.style.push(styleAttrs[key]);
node.attr.style.push(value);
node.styleStr += styleAttrs[key] + ": " + value + ";";
}
}
}
if (node.tag === "source") {
results.source = node.attr.src;
}
if (unary) {
var parent = bufArray[0] || results;
if (parent.nodes === void 0) {
parent.nodes = [];
}
parent.nodes.push(node);
} else {
bufArray.unshift(node);
}
},
end: function(tag) {
var node = bufArray.shift();
if (node.tag !== tag)
console.error("invalid state: mismatch end tag");
if (node.tag === "video" && results.source) {
node.attr.src = results.source;
delete results.source;
}
if (bufArray.length === 0) {
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === void 0) {
parent.nodes = [];
}
parent.nodes.push(node);
}
},
chars: function(text) {
var node = {
node: "text",
text,
textArray: transEmojiStr(text)
};
if (bufArray.length === 0) {
node.index = index.toString();
index += 1;
results.nodes.push(node);
} else {
var parent = bufArray[0];
if (parent.nodes === void 0) {
parent.nodes = [];
}
node.index = parent.index + "." + parent.nodes.length;
parent.nodes.push(node);
}
},
comment: function(text) {
}
});
return results;
}
function transEmojiStr(str) {
var emojiObjs = [];
if (__emojisReg.length == 0 || !__emojis) {
var emojiObj = {};
emojiObj.node = "text";
emojiObj.text = str;
array = [emojiObj];
return array;
}
str = str.replace(/\[([^\[\]]+)\]/g, ":$1:");
var eReg = new RegExp("[:]");
var array = str.split(eReg);
for (var i = 0; i < array.length; i++) {
var ele = array[i];
var emojiObj = {};
if (__emojis[ele]) {
emojiObj.node = "element";
emojiObj.tag = "emoji";
emojiObj.text = __emojis[ele];
emojiObj.baseSrc = __emojisBaseSrc;
} else {
emojiObj.node = "text";
emojiObj.text = ele;
}
emojiObjs.push(emojiObj);
}
return emojiObjs;
}
function emojisInit(reg = "", baseSrc = "/fuiParse/emojis/", emojis) {
__emojisReg = reg;
__emojisBaseSrc = baseSrc;
__emojis = emojis;
}
const HtmlToJson = {
html2json,
emojisInit
};
exports.HtmlToJson = HtmlToJson;
@@ -0,0 +1,129 @@
"use strict";
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/, endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/, attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
var codeTag = /^<code.*?>([\s\S]*?)<\/code>/;
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
var codeContent = "";
function HTMLParser(html, handler) {
var index, chars, match, stack = [], last = html;
stack.last = function() {
return this[this.length - 1];
};
while (html) {
chars = true;
if (!stack.last() || !special[stack.last()]) {
if (html.indexOf("<!--") == 0) {
index = html.indexOf("-->");
if (index >= 0) {
if (handler.comment)
handler.comment(html.substring(4, index));
html = html.substring(index + 3);
chars = false;
}
} else if (html.indexOf("</") == 0) {
match = html.match(endTag);
if (match) {
html = html.substring(match[0].length);
match[0].replace(endTag, parseEndTag);
chars = false;
}
} else if (html.indexOf("<") == 0) {
match = html.match(startTag);
if (match) {
var tagName = match[1];
if (tagName === "code") {
var codeTagMatch = html.match(codeTag);
codeContent = codeTagMatch[1] || "";
}
html = html.substring(match[0].length);
match[0].replace(startTag, parseStartTag);
chars = false;
}
}
if (chars) {
index = html.indexOf("<");
var text = "";
while (index === 0) {
text += "<";
html = html.substring(1);
index = html.indexOf("<");
}
text += index < 0 ? html : html.substring(0, index);
html = index < 0 ? "" : html.substring(index);
if (handler.chars && text.trim() !== "") {
handler.chars(text);
}
}
} else {
html = html.replace(new RegExp("([\\s\\S]*?)</" + stack.last() + "[^>]*>"), function(all, text2) {
text2 = text2.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
if (handler.chars && text2.trim() !== "")
handler.chars(text2);
return "";
});
parseEndTag("", stack.last());
}
if (html == last)
throw "Parse Error: " + html;
last = html;
}
parseEndTag();
function parseStartTag(tag, tagName2, rest, unary) {
tagName2 = tagName2.toLowerCase();
if (block[tagName2]) {
while (stack.last() && inline[stack.last()]) {
parseEndTag("", stack.last());
}
}
if (closeSelf[tagName2] && stack.last() == tagName2) {
parseEndTag("", tagName2);
}
unary = empty[tagName2] || !!unary;
if (!unary)
stack.push(tagName2);
if (handler.start) {
var attrs = [];
rest.replace(attr, function(match2, name) {
var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : "";
attrs.push({
name,
value,
escaped: value.replace(/(^|[^\\])"/g, '$1\\"')
//"
});
});
if (handler.start) {
var tagContent = codeContent || "";
handler.start(tagName2, attrs, unary, tagContent);
codeContent = "";
}
}
}
function parseEndTag(tag, tagName2) {
if (!tagName2)
var pos = 0;
else {
tagName2 = tagName2.toLowerCase();
for (var pos = stack.length - 1; pos >= 0; pos--)
if (stack[pos] == tagName2)
break;
}
if (pos >= 0) {
for (var i = stack.length - 1; i >= pos; i--)
if (handler.end)
handler.end(stack[i]);
stack.length = pos;
}
}
}
function makeMap(str) {
var obj = {}, items = str.split(",");
for (var i = 0; i < items.length; i++)
obj[items[i]] = true;
return obj;
}
exports.HTMLParser = HTMLParser;
@@ -0,0 +1,47 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
let windowWidth = 0;
let windowHeight = 0;
common_vendor.index.getSystemInfo({
success(res) {
windowWidth = res.windowWidth;
windowHeight = res.windowHeight;
}
});
const getSystemInfo = () => {
return [windowWidth, windowHeight];
};
const bindInstance = () => {
let instance = {};
return {
/**
* 提供键名,绑定对象值
*/
set: (bindName, data = null) => {
if (!instance[bindName]) {
instance[bindName] = data;
}
return instance[bindName] || {};
},
get: (bindName) => {
return instance[bindName] || {};
},
/**
* 清除实例对象的所有缓存值
*/
clear: () => {
instance = {};
},
/**
* 清楚实例对象特定的键
*/
remove: (bindName) => {
instance[bindName] && delete instance[bindName];
}
};
};
const util = {
getSystemInfo,
cacheInstance: bindInstance()
};
exports.util = util;
@@ -0,0 +1,184 @@
"use strict";
function strNumDiscode(str) {
str = str.replace(/&forall;/g, "∀");
str = str.replace(/&part;/g, "∂");
str = str.replace(/&exists;/g, "∃");
str = str.replace(/&empty;/g, "∅");
str = str.replace(/&nabla;/g, "∇");
str = str.replace(/&isin;/g, "∈");
str = str.replace(/&notin;/g, "∉");
str = str.replace(/&ni;/g, "∋");
str = str.replace(/&prod;/g, "∏");
str = str.replace(/&sum;/g, "∑");
str = str.replace(/&minus;/g, "");
str = str.replace(/&lowast;/g, "");
str = str.replace(/&radic;/g, "√");
str = str.replace(/&prop;/g, "∝");
str = str.replace(/&infin;/g, "∞");
str = str.replace(/&ang;/g, "∠");
str = str.replace(/&and;/g, "∧");
str = str.replace(/&or;/g, "");
str = str.replace(/&cap;/g, "∩");
str = str.replace(/&cap;/g, "");
str = str.replace(/&int;/g, "∫");
str = str.replace(/&there4;/g, "∴");
str = str.replace(/&sim;/g, "");
str = str.replace(/&cong;/g, "≅");
str = str.replace(/&asymp;/g, "≈");
str = str.replace(/&ne;/g, "≠");
str = str.replace(/&le;/g, "≤");
str = str.replace(/&ge;/g, "≥");
str = str.replace(/&sub;/g, "⊂");
str = str.replace(/&sup;/g, "⊃");
str = str.replace(/&nsub;/g, "⊄");
str = str.replace(/&sube;/g, "⊆");
str = str.replace(/&supe;/g, "⊇");
str = str.replace(/&oplus;/g, "⊕");
str = str.replace(/&otimes;/g, "⊗");
str = str.replace(/&perp;/g, "⊥");
str = str.replace(/&sdot;/g, "⋅");
return str;
}
function strGreeceDiscode(str) {
str = str.replace(/&Alpha;/g, "Α");
str = str.replace(/&Beta;/g, "Β");
str = str.replace(/&Gamma;/g, "Γ");
str = str.replace(/&Delta;/g, "Δ");
str = str.replace(/&Epsilon;/g, "Ε");
str = str.replace(/&Zeta;/g, "Ζ");
str = str.replace(/&Eta;/g, "Η");
str = str.replace(/&Theta;/g, "Θ");
str = str.replace(/&Iota;/g, "Ι");
str = str.replace(/&Kappa;/g, "Κ");
str = str.replace(/&Lambda;/g, "Λ");
str = str.replace(/&Mu;/g, "Μ");
str = str.replace(/&Nu;/g, "Ν");
str = str.replace(/&Xi;/g, "Ν");
str = str.replace(/&Omicron;/g, "Ο");
str = str.replace(/&Pi;/g, "Π");
str = str.replace(/&Rho;/g, "Ρ");
str = str.replace(/&Sigma;/g, "Σ");
str = str.replace(/&Tau;/g, "Τ");
str = str.replace(/&Upsilon;/g, "Υ");
str = str.replace(/&Phi;/g, "Φ");
str = str.replace(/&Chi;/g, "Χ");
str = str.replace(/&Psi;/g, "Ψ");
str = str.replace(/&Omega;/g, "Ω");
str = str.replace(/&alpha;/g, "α");
str = str.replace(/&beta;/g, "β");
str = str.replace(/&gamma;/g, "γ");
str = str.replace(/&delta;/g, "δ");
str = str.replace(/&epsilon;/g, "ε");
str = str.replace(/&zeta;/g, "ζ");
str = str.replace(/&eta;/g, "η");
str = str.replace(/&theta;/g, "θ");
str = str.replace(/&iota;/g, "ι");
str = str.replace(/&kappa;/g, "κ");
str = str.replace(/&lambda;/g, "λ");
str = str.replace(/&mu;/g, "μ");
str = str.replace(/&nu;/g, "ν");
str = str.replace(/&xi;/g, "ξ");
str = str.replace(/&omicron;/g, "ο");
str = str.replace(/&pi;/g, "π");
str = str.replace(/&rho;/g, "ρ");
str = str.replace(/&sigmaf;/g, "ς");
str = str.replace(/&sigma;/g, "σ");
str = str.replace(/&tau;/g, "τ");
str = str.replace(/&upsilon;/g, "υ");
str = str.replace(/&phi;/g, "φ");
str = str.replace(/&chi;/g, "χ");
str = str.replace(/&psi;/g, "ψ");
str = str.replace(/&omega;/g, "ω");
str = str.replace(/&thetasym;/g, "ϑ");
str = str.replace(/&upsih;/g, "ϒ");
str = str.replace(/&piv;/g, "ϖ");
str = str.replace(/&middot;/g, "·");
return str;
}
function strcharacterDiscode(str) {
str = str.replace(/&nbsp;/g, " ");
str = str.replace(/&quot;/g, "'");
str = str.replace(/&amp;/g, "&");
str = str.replace(/&lt;/g, "<");
str = str.replace(/&gt;/g, ">");
str = str.replace(/&#8226;/g, "•");
return str;
}
function strOtherDiscode(str) {
str = str.replace(/&OElig;/g, "Œ");
str = str.replace(/&oelig;/g, "œ");
str = str.replace(/&Scaron;/g, "Š");
str = str.replace(/&scaron;/g, "š");
str = str.replace(/&Yuml;/g, "Ÿ");
str = str.replace(/&fnof;/g, "ƒ");
str = str.replace(/&circ;/g, "ˆ");
str = str.replace(/&tilde;/g, "˜");
str = str.replace(/&ensp;/g, "");
str = str.replace(/&emsp;/g, "");
str = str.replace(/&thinsp;/g, "");
str = str.replace(/&zwnj;/g, "");
str = str.replace(/&zwj;/g, "");
str = str.replace(/&lrm;/g, "");
str = str.replace(/&rlm;/g, "");
str = str.replace(/&ndash;/g, "");
str = str.replace(/&mdash;/g, "—");
str = str.replace(/&lsquo;/g, "");
str = str.replace(/&rsquo;/g, "");
str = str.replace(/&sbquo;/g, "");
str = str.replace(/&ldquo;/g, "“");
str = str.replace(/&rdquo;/g, "”");
str = str.replace(/&bdquo;/g, "„");
str = str.replace(/&dagger;/g, "†");
str = str.replace(/&Dagger;/g, "‡");
str = str.replace(/&bull;/g, "•");
str = str.replace(/&hellip;/g, "…");
str = str.replace(/&permil;/g, "‰");
str = str.replace(/&prime;/g, "");
str = str.replace(/&Prime;/g, "″");
str = str.replace(/&lsaquo;/g, "");
str = str.replace(/&rsaquo;/g, "");
str = str.replace(/&oline;/g, "‾");
str = str.replace(/&euro;/g, "€");
str = str.replace(/&trade;/g, "™");
str = str.replace(/&larr;/g, "←");
str = str.replace(/&uarr;/g, "↑");
str = str.replace(/&rarr;/g, "→");
str = str.replace(/&darr;/g, "↓");
str = str.replace(/&harr;/g, "↔");
str = str.replace(/&crarr;/g, "↵");
str = str.replace(/&lceil;/g, "⌈");
str = str.replace(/&rceil;/g, "⌉");
str = str.replace(/&lfloor;/g, "⌊");
str = str.replace(/&rfloor;/g, "⌋");
str = str.replace(/&loz;/g, "◊");
str = str.replace(/&spades;/g, "♠");
str = str.replace(/&clubs;/g, "♣");
str = str.replace(/&hearts;/g, "♥");
str = str.replace(/&diams;/g, "♦");
str = str.replace(/&#39;/g, "'");
return str;
}
function strMoreDiscode(str) {
return str;
}
function strDiscode(str) {
str = strNumDiscode(str);
str = strGreeceDiscode(str);
str = strcharacterDiscode(str);
str = strOtherDiscode(str);
str = strMoreDiscode(str);
return str;
}
function urlToHttpUrl(url, rep) {
var patt1 = new RegExp("^//");
var result = patt1.test(url);
if (result) {
url = rep + ":" + url;
}
return url;
}
const wxDiscode = {
strDiscode,
urlToHttpUrl
};
exports.wxDiscode = wxDiscode;