Skip to content

Commit

Permalink
Add abcjs extension and update all deps to new version
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuix committed Jul 23, 2024
1 parent 5a002fe commit c805dc6
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 279 deletions.
322 changes: 190 additions & 132 deletions docs/showdowns-features.md

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions livedemo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,27 @@
(function(element) {
showdowns.setCDN("local");
showdowns.init();
// showdowns.setShowdownFlavor("original");
showdowns.setMermaidOptions({theme:"forest"});
showdowns.setKatexOptions({delimiters:{
texmath: {
inline: [{ left: "\\@", right: "\\@"},{ left: "$@", right: "@$"}]
},
asciimath: {
inline: [{ left: "\\`@", right: "@\\`"}]
}
}});
// showdowns.setKatexOptions({delimiters:{
// // texmath: {
// // inline: [{ left: "\\@", right: "\\@"},{ left: "$@", right: "@$"}]
// // },
// asciimath: {
// inline: [{ left: "\\~", right: "\\~"}]
// }
// }});
let md = "";
let cssTypes;
window
.fetch("http://127.0.0.1:5500/docs/showdowns-features.md")
.fetch("http://127.0.0.1:15505/docs/showdowns-features.md")
.then(function(response) {
if (response.ok) {
return response.text();
}
})
.then(function(text) {
md = text;
return window.fetch("http://127.0.0.1:5500/docs/Showdown's-Markdown-syntax.md");
return window.fetch("http://127.0.0.1:15505/docs/Showdown's-Markdown-syntax.md");
})
.then(function(response) {
if (response.ok) {
Expand Down
77 changes: 40 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"style": "dist/showdowns.min.css",
"scripts": {
"build": "npm run build:release && npm run build:umd && npm run build:cjs && npm run build:demo",
"build:umd": "rollup -c",
"build:umd:min": "rollup -c --environment MIN",
"build:cjs": "rollup -c --environment TARGET:cjs",
"build:cjs:min": "rollup -c --environment MIN,TARGET:cjs",
"build:umd": "rollup -c --bundleConfigAsCjs",
"build:umd:min": "rollup -c --bundleConfigAsCjs --environment MIN",
"build:cjs": "rollup -c --bundleConfigAsCjs --environment TARGET:cjs",
"build:cjs:min": "rollup -c --bundleConfigAsCjs --environment MIN,TARGET:cjs",
"build:release": "npm run clean && npm run build:umd:min && npm run build:cjs:min",
"build:demo": "rimraf docs && rollup -c --environment DEMO,MIN",
"build:demo": "rimraf docs && rollup -c --bundleConfigAsCjs --environment DEMO,MIN",
"build:dev": "npm run build:umd && npm run build:cjs",
"prepublishOnly": "npm run build:release",
"clean": "rimraf dist"
Expand Down Expand Up @@ -44,46 +44,49 @@
"homepage": "https://github.com/jhuix/showdowns#readme",
"private": false,
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-external-helpers": "^7.10.4",
"@babel/preset-env": "^7.11.5",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-replace": "^2.3.3",
"autoprefixer": "^9.8.6",
"cssnano": "^4.1.10",
"eslint": "^7.11.0",
"less": "^3.12.2",
"postcss-banner": "^3.0.2",
"postcss-nested": "^4.2.3",
"postcss-simple-vars": "^5.0.2",
"rimraf": "^3.0.2",
"rollup": "^1.32.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-copy": "^3.3.0",
"@babel/core": "^7.24.9",
"@babel/plugin-external-helpers": "^7.24.7",
"@babel/preset-env": "^7.24.8",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@types/rollup-plugin-node-builtins": "^2.1.5",
"@types/rollup-plugin-node-globals": "^1.4.4",
"autoprefixer": "^10.4.19",
"cssnano": "^7.0.4",
"eslint": "^9.7.0",
"less": "^4.2.0",
"postcss-banner": "^4.0.1",
"postcss-nested": "^6.2.0",
"postcss-simple-vars": "^7.0.1",
"rimraf": "^6.0.1",
"rollup": "^4.19.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^2.9.0",
"rollup-plugin-terser": "^5.3.1",
"semver": "^6.3.0"
"rollup-plugin-postcss": "^4.0.2",
"semver": "^7.6.3"
},
"dependencies": {
"@rokt33r/js-sequence-diagrams": "^2.0.6-2",
"flowchart.js": "^1.14.1",
"katex": "^0.12.0",
"mermaid": "^8.8.2",
"@viz-js/viz": "^3.7.0",
"abcjs": "^6.4.1",
"flowchart.js": "^1.18.0",
"katex": "^0.16.11",
"mermaid": "^10.9.1",
"railroad-diagrams": "^1.0.0",
"raphael": "^2.3.0",
"showdown": "^1.9.1",
"showdown": "^2.1.0",
"snapsvg": "^0.5.1",
"underscore": "^1.11.0",
"vega": "^5.15.0",
"vega-embed": "^6.12.2",
"vega-lite": "^4.15.0",
"viz.js": "^2.1.2",
"wavedrom": "^2.6.8",
"underscore": "^1.13.6",
"vega": "^5.30.0",
"vega-embed": "^6.26.0",
"vega-lite": "^5.19.0",
"wavedrom": "^3.5.0",
"webfontloader": "^1.6.28"
},
"publishConfig": {
Expand Down
18 changes: 9 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import path from 'path';

// 帮助寻找node_modules里的包
import resolve from 'rollup-plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
// rollup 的 babel 插件,ES6转ES5
import babel from '@rollup/plugin-babel';
// 将非ES6语法的包转为ES6可用
import commonjs from 'rollup-plugin-commonjs';
import commonjs from '@rollup/plugin-commonjs';
// 混淆JS文件
import { terser } from 'rollup-plugin-terser';
import { terser } from '@rollup/plugin-terser';
// 集成zlib crypto等库
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
Expand Down Expand Up @@ -60,9 +60,10 @@ const config = {
sourcemap: true,
banner: jsbanner,
globals: {
ABCJS: 'ABCJS',
raphael: 'Raphael',
'flowchart.js': 'flowchart',
'viz.js': 'Viz',
'@viz-js/viz': 'Viz',
mermaid: 'mermaid',
katex: 'katex',
wavedrom: 'WaveDrom',
Expand All @@ -80,11 +81,12 @@ const config = {
},
// 作用:指出应将哪些模块视为外部模块,否则会被打包进最终的代码里
external: [
'abcjs',
'mermaid',
'katex',
'raphael',
'flowchart.js',
'viz.js',
'@viz-js/viz',
'wavedrom',
'vega',
'vega-lite',
Expand Down Expand Up @@ -135,10 +137,8 @@ if (isFormatCJS) {
resolve({
browser: true,
preferBuiltins: true,
customResolveOptions: {
// 将自定义选项传递给解析插件
moduleDirectory: 'node_modules'
}
// 选择module目录传递给解析插件
moduleDirectories: ['node_modules']
}),
commonjs({
include: ['node_modules/**']
Expand Down
93 changes: 48 additions & 45 deletions src/extensions/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ let distScheme = '';

const cdnSrc = {
local: {
Viz: '../node_modules/viz.js/viz.js',
VizRender: '../node_modules/viz.js/full.render.js',
ABCJS: '../node_modules/abcjs/dist/abcjs-basic.js',
ABCJSCSS: '../node_modules/abcjs/abcjs-audio.css',
Viz: '../node_modules/@viz-js/viz/lib/viz-standalone.js',
Raphael: '../node_modules/raphael/raphael.min.js',
flowchart: '../dist/diagrams/flowchart/flowchart.min.js',
mermaid: '../node_modules/mermaid/dist/mermaid.min.js',
mermaid: '../node_modules/mermaid/dist/mermaid.js',
katex: '../node_modules/katex/dist/katex.min.js',
katexCSS: '../node_modules/katex/dist/katex.min.css',
renderMathInElement: '../node_modules/katex/dist/contrib/auto-render.js',
Expand All @@ -35,60 +36,62 @@ const cdnSrc = {
lowkey: '../node_modules/wavedrom/skins/lowkey.js',
narrow: '../node_modules/wavedrom/skins/narrow.js'
},
vega: '../node_modules/vega/build/vega.min.js',
vegaLite: '../node_modules/vega-lite/build/vega-lite.min.js',
vegaEmbed: '../node_modules/vega-embed/build/vega-embed.min.js'
vega: '../node_modules/vega/build/vega.js',
vegaLite: '../node_modules/vega-lite/build/vega-lite.js',
vegaEmbed: '../node_modules/vega-embed/build/vega-embed.js'
},
cdnjs: {
Viz: scheme + 'cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/viz.js',
VizRender: scheme + 'cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/full.render.js',
ABCJS: scheme + 'cdnjs.cloudflare.com/ajax/libs/abcjs/6.4.1/abcjs-basic-min.js',
ABCJSCSS: scheme + 'cdnjs.cloudflare.com/ajax/libs/abcjs/abcjs-audio.css',
Viz: scheme + 'cdn.jsdelivr.net/npm/@viz-js/viz@3/lib/viz-standalone.js',
Raphael: scheme + 'cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js',
flowchart: scheme + 'cdnjs.cloudflare.com/ajax/libs/flowchart/1.14.1/flowchart.min.js',
mermaid: scheme + 'cdnjs.cloudflare.com/ajax/libs/mermaid/8.8.2/mermaid.min.js',
katex: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.js',
katexCSS: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css',
renderMathInElement: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/contrib/auto-render.js',
railroad: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams',
railroadCSS: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams/railroad-diagrams.css',
flowchart: scheme + 'cdnjs.cloudflare.com/ajax/libs/flowchart/1.18.0/flowchart.min.js',
mermaid: scheme + 'cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.1/mermaid.min.js',
katex: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.11/katex.min.js',
katexCSS: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.11/katex.min.css',
renderMathInElement: scheme + 'cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.11/contrib/auto-render.js',
railroad: scheme + 'cdnjs.cloudflare.com/ajax/libs/railroad-diagrams/1.0.0/railroad-diagrams.js',
railroadCSS: scheme + 'cdnjs.cloudflare.com/ajax/libs/railroad-diagrams/1.0.0/railroad-diagrams.css',
Snap: scheme + 'cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js',
WebFont: scheme + 'cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js',
underscore: scheme + 'cdnjs.cloudflare.com/ajax/libs/underscore.js/1.11.0/underscore-min.js',
sequence: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams/dist/sequence-diagram-min.js',
sequenceCSS: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams/dist/sequence-diagram-min.css',
WaveDrom: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/wavedrom.min.js',
underscore: scheme + 'cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js',
sequence: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams@2.0.6-2/dist/sequence-diagram-min.js',
sequenceCSS: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams@2.0.6-2/dist/sequence-diagram-min.css',
WaveDrom: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/3.5.0/wavedrom.min.js',
WaveDromSkin: {
default: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/skins/default.js',
lowkey: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/skins/lowkey.js',
narrow: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/2.6.8/skins/narrow.js'
default: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/3.5.0/skins/default.js',
lowkey: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/3.5.0/skins/lowkey.js',
narrow: scheme + 'cdnjs.cloudflare.com/ajax/libs/wavedrom/3.5.0/skins/narrow.js'
},
vega: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega/5.15.0/vega.min.js',
vegaLite: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega-lite/4.15.0/vega-lite.min.js',
vegaEmbed: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega-embed/6.12.2/vega-embed.min.js'
vega: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega/5.30.0/vega.min.js',
vegaLite: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega-lite/5.19.0/vega-lite.min.js',
vegaEmbed: scheme + 'cdnjs.cloudflare.com/ajax/libs/vega-embed/6.26.0/vega-embed.min.js'
},
jsdelivr: {
Viz: scheme + 'cdn.jsdelivr.net/npm/viz.js',
VizRender: scheme + 'cdn.jsdelivr.net/npm/viz.js/full.render.js',
Raphael: scheme + 'cdn.jsdelivr.net/npm/raphael/raphael.min.js',
flowchart: scheme + 'cdnjs.cloudflare.com/ajax/libs/flowchart/1.14.1/flowchart.min.js',
mermaid: scheme + 'cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js',
katex: scheme + 'cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js',
katexCSS: scheme + 'cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
renderMathInElement: scheme + 'cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.js',
railroad: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams',
railroadCSS: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams/railroad-diagrams.css',
Snap: scheme + 'cdn.jsdelivr.net/npm/snapsvg',
WebFont: scheme + 'cdn.jsdelivr.net/npm/webfontloader',
underscore: scheme + 'cdn.jsdelivr.net/npm/underscore',
sequence: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams/dist/sequence-diagram-min.js',
sequenceCSS: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/js-sequence-diagrams/dist/sequence-diagram-min.css',
WaveDrom: scheme + 'cdn.jsdelivr.net/npm/wavedrom/wavedrom.min.js',
ABCJS: scheme + 'cdn.jsdelivr.net/npm/abcjs@6/dist/abcjs-basic-min.js',
ABCJSCSS: scheme + 'cdn.jsdelivr.net/npm/abcjs@6/abcjs-audio.css',
Viz: scheme + 'cdn.jsdelivr.net/npm/@viz-js/viz@3/lib/viz-standalone.js',
Raphael: scheme + 'cdn.jsdelivr.net/npm/raphael@2/raphael.min.js',
flowchart: scheme + 'cdnjs.cloudflare.com/ajax/libs/flowchart/1.18.0/flowchart.min.js',
mermaid: scheme + 'cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js',
katex: scheme + 'cdn.jsdelivr.net/npm/katex@0/dist/katex.min.js',
katexCSS: scheme + 'cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css',
renderMathInElement: scheme + 'cdn.jsdelivr.net/npm/katex@0/dist/contrib/auto-render.js',
railroad: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams@1/railroad-diagrams.js',
railroadCSS: scheme + 'cdn.jsdelivr.net/npm/railroad-diagrams@1/railroad-diagrams.css',
Snap: scheme + 'cdn.jsdelivr.net/npm/snapsvg@0/dist/snap.svg-min.js',
WebFont: scheme + 'cdn.jsdelivr.net/npm/webfontloader@1/webfontloader.js',
underscore: scheme + 'cdn.jsdelivr.net/npm/underscore@1/underscore-min.js',
sequence: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/[email protected]/dist/sequence-diagram-min.js',
sequenceCSS: scheme + 'cdn.jsdelivr.net/npm/@rokt33r/[email protected]/dist/sequence-diagram-min.css',
WaveDrom: scheme + 'cdn.jsdelivr.net/npm/wavedrom@3/wavedrom.min.js',
WaveDromSkin: {
default: scheme + 'cdn.jsdelivr.net/npm/wavedrom/skins/default.js',
lowkey: scheme + 'cdn.jsdelivr.net/npm/wavedrom/skins/lowkey.js',
narrow: scheme + 'cdn.jsdelivr.net/npm/wavedrom/skins/narrow.js'
default: scheme + 'cdn.jsdelivr.net/npm/wavedrom@3/skins/default.js',
lowkey: scheme + 'cdn.jsdelivr.net/npm/wavedrom@3/skins/lowkey.js',
narrow: scheme + 'cdn.jsdelivr.net/npm/wavedrom@3/skins/narrow.js'
},
vega: scheme + 'cdn.jsdelivr.net/npm/vega@5/build/vega.js',
vegaLite: scheme + 'cdn.jsdelivr.net/npm/vega-lite@4/build/vega-lite.js',
vegaLite: scheme + 'cdn.jsdelivr.net/npm/vega-lite@5/build/vega-lite.js',
vegaEmbed: scheme + 'cdn.jsdelivr.net/npm/vega-embed@6/build/vega-embed.js'
}
};
Expand Down
Loading

0 comments on commit c805dc6

Please sign in to comment.