@cnblogs/markdown-it-presets 1.8.0-beta2 → 1.9.0-next

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.gitignore +195 -0
  2. package/README.adoc +80 -0
  3. package/math/package.json +8 -0
  4. package/package.json +30 -11
  5. package/tsconfig.base.json +17 -0
  6. package/tsconfig.json +4 -0
  7. package/tslint.json +18 -0
  8. package/index.d.ts +0 -1
  9. package/index.js +0 -18
  10. package/index.js.map +0 -1
  11. package/lib-esm/index.js +0 -2
  12. package/lib-esm/index.js.map +0 -1
  13. package/lib-esm/markdown-it-factory.js +0 -102
  14. package/lib-esm/markdown-it-factory.js.map +0 -1
  15. package/lib-esm/math/factory.js +0 -13
  16. package/lib-esm/math/factory.js.map +0 -1
  17. package/lib-esm/math/impl.js +0 -161
  18. package/lib-esm/math/impl.js.map +0 -1
  19. package/lib-esm/math/index.js +0 -3
  20. package/lib-esm/math/index.js.map +0 -1
  21. package/lib-esm/math/model.js +0 -20
  22. package/lib-esm/math/model.js.map +0 -1
  23. package/lib-esm/option.js +0 -27
  24. package/lib-esm/option.js.map +0 -1
  25. package/lib-esm/plugins/highlight-code-lines.plugin.js +0 -49
  26. package/lib-esm/plugins/highlight-code-lines.plugin.js.map +0 -1
  27. package/lib-esm/plugins/html-filter.plugin.js +0 -43
  28. package/lib-esm/plugins/html-filter.plugin.js.map +0 -1
  29. package/lib-esm/plugins/meta.js +0 -36
  30. package/lib-esm/plugins/meta.js.map +0 -1
  31. package/lib-esm/plugins/multiline-blockquote/multiline-blockquote.plugin.js +0 -11
  32. package/lib-esm/plugins/multiline-blockquote/multiline-blockquote.plugin.js.map +0 -1
  33. package/lib-esm/plugins/multiline-blockquote/multiline-blockquote.rule.js +0 -40
  34. package/lib-esm/plugins/multiline-blockquote/multiline-blockquote.rule.js.map +0 -1
  35. package/lib-esm/plugins/simple-math.plugin.js +0 -147
  36. package/lib-esm/plugins/simple-math.plugin.js.map +0 -1
  37. package/lib-esm/plugins/simple-mermaid.plugin.js +0 -17
  38. package/lib-esm/plugins/simple-mermaid.plugin.js.map +0 -1
  39. package/lib-esm/plugins/toc/index.js +0 -184
  40. package/lib-esm/plugins/toc/index.js.map +0 -1
  41. package/lib-esm/plugins/toc/slugify.js +0 -5
  42. package/lib-esm/plugins/toc/slugify.js.map +0 -1
  43. package/lib-esm/plugins/toc/toc-item.js +0 -2
  44. package/lib-esm/plugins/toc/toc-item.js.map +0 -1
  45. package/lib-esm/plugins/toc/toc-option.js +0 -15
  46. package/lib-esm/plugins/toc/toc-option.js.map +0 -1
  47. package/lib-esm/plugins/unique-custom-id.js +0 -27
  48. package/lib-esm/plugins/unique-custom-id.js.map +0 -1
  49. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  50. package/markdown-it-factory.d.ts +0 -6
  51. package/markdown-it-factory.js +0 -112
  52. package/markdown-it-factory.js.map +0 -1
  53. package/math/factory.d.ts +0 -2
  54. package/math/factory.js +0 -17
  55. package/math/factory.js.map +0 -1
  56. package/math/impl.d.ts +0 -20
  57. package/math/impl.js +0 -166
  58. package/math/impl.js.map +0 -1
  59. package/math/index.d.ts +0 -2
  60. package/math/index.js +0 -8
  61. package/math/index.js.map +0 -1
  62. package/math/model.d.ts +0 -38
  63. package/math/model.js +0 -23
  64. package/math/model.js.map +0 -1
  65. package/option.d.ts +0 -22
  66. package/option.js +0 -36
  67. package/option.js.map +0 -1
  68. package/plugins/highlight-code-lines.plugin.d.ts +0 -7
  69. package/plugins/highlight-code-lines.plugin.js +0 -52
  70. package/plugins/highlight-code-lines.plugin.js.map +0 -1
  71. package/plugins/html-filter.plugin.d.ts +0 -2
  72. package/plugins/html-filter.plugin.js +0 -47
  73. package/plugins/html-filter.plugin.js.map +0 -1
  74. package/plugins/meta.d.ts +0 -2
  75. package/plugins/meta.js +0 -40
  76. package/plugins/meta.js.map +0 -1
  77. package/plugins/multiline-blockquote/multiline-blockquote.plugin.d.ts +0 -7
  78. package/plugins/multiline-blockquote/multiline-blockquote.plugin.js +0 -15
  79. package/plugins/multiline-blockquote/multiline-blockquote.plugin.js.map +0 -1
  80. package/plugins/multiline-blockquote/multiline-blockquote.rule.d.ts +0 -2
  81. package/plugins/multiline-blockquote/multiline-blockquote.rule.js +0 -44
  82. package/plugins/multiline-blockquote/multiline-blockquote.rule.js.map +0 -1
  83. package/plugins/simple-math.plugin.d.ts +0 -2
  84. package/plugins/simple-math.plugin.js +0 -151
  85. package/plugins/simple-math.plugin.js.map +0 -1
  86. package/plugins/simple-mermaid.plugin.d.ts +0 -2
  87. package/plugins/simple-mermaid.plugin.js +0 -21
  88. package/plugins/simple-mermaid.plugin.js.map +0 -1
  89. package/plugins/toc/index.d.ts +0 -3
  90. package/plugins/toc/index.js +0 -187
  91. package/plugins/toc/index.js.map +0 -1
  92. package/plugins/toc/slugify.d.ts +0 -2
  93. package/plugins/toc/slugify.js +0 -8
  94. package/plugins/toc/slugify.js.map +0 -1
  95. package/plugins/toc/toc-item.d.ts +0 -9
  96. package/plugins/toc/toc-item.js +0 -3
  97. package/plugins/toc/toc-item.js.map +0 -1
  98. package/plugins/toc/toc-option.d.ts +0 -26
  99. package/plugins/toc/toc-option.js +0 -18
  100. package/plugins/toc/toc-option.js.map +0 -1
  101. package/plugins/unique-custom-id.d.ts +0 -3
  102. package/plugins/unique-custom-id.js +0 -30
  103. package/plugins/unique-custom-id.js.map +0 -1
  104. package/styles/task-lists.less +0 -19
  105. package/styles/task-lists.min.css +0 -1
  106. package/tsconfig.tsbuildinfo +0 -1
  107. package/umd/markdownItPresets.js +0 -1
  108. package/umd/mathRenderer.js +0 -1
package/.gitignore ADDED
@@ -0,0 +1,195 @@
1
+
2
+ # Created by https://www.gitignore.io/api/node
3
+ # Edit at https://www.gitignore.io/?templates=node
4
+ out-tsc/
5
+ temp/
6
+ ### Node ###
7
+ # Logs
8
+ logs
9
+ *.log
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ lerna-debug.log*
14
+
15
+ # Diagnostic reports (https://nodejs.org/api/report.html)
16
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17
+
18
+ # Runtime data
19
+ pids
20
+ *.pid
21
+ *.seed
22
+ *.pid.lock
23
+
24
+ # Directory for instrumented libs generated by jscoverage/JSCover
25
+ lib-cov
26
+
27
+ # Coverage directory used by tools like istanbul
28
+ coverage
29
+ *.lcov
30
+
31
+ # nyc test coverage
32
+ .nyc_output
33
+
34
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35
+ .grunt
36
+
37
+ # Bower dependency directory (https://bower.io/)
38
+ bower_components
39
+
40
+ # node-waf configuration
41
+ .lock-wscript
42
+
43
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
44
+ build/Release
45
+
46
+ # Dependency directories
47
+ node_modules/
48
+ jspm_packages/
49
+
50
+ # TypeScript v1 declaration files
51
+ typings/
52
+
53
+ # TypeScript cache
54
+ *.tsbuildinfo
55
+
56
+ # Optional npm cache directory
57
+ .npm
58
+
59
+ # Optional eslint cache
60
+ .eslintcache
61
+
62
+ # Optional REPL history
63
+ .node_repl_history
64
+
65
+ # Output of 'npm pack'
66
+ *.tgz
67
+
68
+ # Yarn Integrity file
69
+ .yarn-integrity
70
+
71
+ # dotenv environment variables file
72
+ .env
73
+ .env.test
74
+
75
+ # parcel-bundler cache (https://parceljs.org/)
76
+ .cache
77
+
78
+ # next.js build output
79
+ .next
80
+
81
+ # nuxt.js build output
82
+ .nuxt
83
+
84
+ # react / gatsby
85
+ public/
86
+
87
+ # vuepress build output
88
+ .vuepress/dist
89
+
90
+ # Serverless directories
91
+ .serverless/
92
+
93
+ # FuseBox cache
94
+ .fusebox/
95
+
96
+ # DynamoDB Local files
97
+ .dynamodb/
98
+
99
+ # End of https://www.gitignore.io/api/node
100
+
101
+ # Created by https://www.gitignore.io/api/jetbrains
102
+ # Edit at https://www.gitignore.io/?templates=jetbrains
103
+
104
+ ### JetBrains ###
105
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
106
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
107
+
108
+ # User-specific stuff
109
+ .idea/**/workspace.xml
110
+ .idea/**/tasks.xml
111
+ .idea/**/usage.statistics.xml
112
+ .idea/**/dictionaries
113
+ .idea/**/shelf
114
+
115
+ # Generated files
116
+ .idea/**/contentModel.xml
117
+
118
+ # Sensitive or high-churn files
119
+ .idea/**/dataSources/
120
+ .idea/**/dataSources.ids
121
+ .idea/**/dataSources.local.xml
122
+ .idea/**/sqlDataSources.xml
123
+ .idea/**/dynamic.xml
124
+ .idea/**/uiDesigner.xml
125
+ .idea/**/dbnavigator.xml
126
+
127
+ # Gradle
128
+ .idea/**/gradle.xml
129
+ .idea/**/libraries
130
+
131
+ # Gradle and Maven with auto-import
132
+ # When using Gradle or Maven with auto-import, you should exclude module files,
133
+ # since they will be recreated, and may cause churn. Uncomment if using
134
+ # auto-import.
135
+ # .idea/modules.xml
136
+ # .idea/*.iml
137
+ # .idea/modules
138
+ # *.iml
139
+ # *.ipr
140
+
141
+ # CMake
142
+ cmake-build-*/
143
+
144
+ # Mongo Explorer plugin
145
+ .idea/**/mongoSettings.xml
146
+
147
+ # File-based project format
148
+ *.iws
149
+
150
+ # IntelliJ
151
+ out/
152
+
153
+ # mpeltonen/sbt-idea plugin
154
+ .idea_modules/
155
+
156
+ # JIRA plugin
157
+ atlassian-ide-plugin.xml
158
+
159
+ # Cursive Clojure plugin
160
+ .idea/replstate.xml
161
+
162
+ # Crashlytics plugin (for Android Studio and IntelliJ)
163
+ com_crashlytics_export_strings.xml
164
+ crashlytics.properties
165
+ crashlytics-build.properties
166
+ fabric.properties
167
+
168
+ # Editor-based Rest Client
169
+ .idea/httpRequests
170
+
171
+ # Android studio 3.1+ serialized cache file
172
+ .idea/caches/build_file_checksums.ser
173
+
174
+ ### JetBrains Patch ###
175
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
176
+
177
+ # *.iml
178
+ # modules.xml
179
+ # .idea/misc.xml
180
+ # *.ipr
181
+
182
+ # Sonarlint plugin
183
+ .idea/**/sonarlint/
184
+
185
+ # SonarQube Plugin
186
+ .idea/**/sonarIssues.xml
187
+
188
+ # Markdown Navigator plugin
189
+ .idea/**/markdown-navigator.xml
190
+ .idea/**/markdown-navigator/
191
+
192
+ # End of https://www.gitignore.io/api/jetbrains
193
+
194
+ /dist
195
+ /.idea
package/README.adoc ADDED
@@ -0,0 +1,80 @@
1
+ = markdown-it-presets
2
+
3
+ == Usage
4
+
5
+ [source,bash]
6
+ ----
7
+ yarn add @zeeko-myget/markdown-it-presets@latest
8
+ ----
9
+
10
+ == Breaking Changes
11
+
12
+ === 0.0.4
13
+
14
+ . 移除了所有的预设,必须传递完整的参数
15
+ . 不再支持服务端渲染数学公式结果,请在前端使用 MathJax 进行渲染
16
+
17
+ === Node.js or javascript bundler
18
+
19
+ [source,javascript]
20
+ ----
21
+ // Node.js
22
+ const { markdownItFactory } = require('@zeeko/markdown-it-presets');
23
+
24
+ // ECMA moudle
25
+ import { markdownItFactory } from '@zeeko/markdown-it-presets';
26
+ ----
27
+
28
+ === HTML
29
+
30
+ [source,html]
31
+ ----
32
+ <!--optional start-->
33
+ <script src="https://path/to/highlight.js"></script>
34
+ <!--optional end-->
35
+
36
+ <script src="./node_modules/@zeeko-myget/markdown-it-presets/umd/markdown-it-persets.js"></script>
37
+
38
+ <script>
39
+ const { markdownItFactory } = window.markdownItPresets;
40
+ </script>
41
+ ----
42
+
43
+ == API
44
+
45
+ [source,ts]
46
+ ----
47
+ markdownItFactory(opt: MarkdownItPresetsOption = defaultOption): MarkdownIt
48
+ ----
49
+
50
+ .options
51
+ |===
52
+ | Name | Type | Description | Default value
53
+
54
+ | `codeHighlight` | Boolean | 是否使用 hljs 进行代码高亮 | `false`
55
+
56
+ | `math` | Boolean | 是否将`$`或`$$`包围的内容转换为数学公式供 MathJax 渲染 | `false`
57
+
58
+ | `disableRules` | Array<string> | 需要禁用的 markdown 语法规则 | `[]`
59
+ | `html` | Boolean | 是否允许渲染 HTML | `false`
60
+ |===
61
+
62
+ == Development
63
+
64
+ [source,bash]
65
+ ----
66
+ # restore
67
+ yarn install
68
+ # restore peer dependencies
69
+ yarn add highlight.js
70
+
71
+ # build
72
+ ./build.sh
73
+
74
+ # test
75
+ yarn test
76
+
77
+ # publish
78
+ export NPM_TOKEN="YOUR-TOKEN-HERE"
79
+ ./publish.sh
80
+ ----
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@cnblogs/markdown-it-presets/math",
3
+ "types": "../dist/types/math/index.d.ts",
4
+ "type": "module",
5
+ "module": "../dist/es6/math/index.mjs",
6
+ "main": "../dist/commonjs/math/index.cjs",
7
+ "sideEffectes": false
8
+ }
package/package.json CHANGED
@@ -1,22 +1,29 @@
1
1
  {
2
2
  "name": "@cnblogs/markdown-it-presets",
3
- "version": "1.8.0-beta2",
3
+ "version": "1.9.0-next",
4
4
  "description": "Markdown-it configuration for cnblogs.com",
5
5
  "repository": "git@github.com:cnblogs/packages.git",
6
6
  "main": "index.js",
7
7
  "license": "MIT",
8
8
  "exports": {
9
- "./*": "./*",
10
- ".": "./lib-esm/index.js",
11
- "./math/": "./lib-esm/math/",
12
- "./math": "./lib-esm/math/index.js"
9
+ ".": {
10
+ "require": "./dist/commonjs/index.cjs",
11
+ "default": "./dist/es6/index.mjs"
12
+ },
13
+ "./math": {
14
+ "types": "./dist/types/math/index.d.ts",
15
+ "require": "./dist/commonjs/math/index.cjs",
16
+ "default": "./dist/es6/math/index.mjs"
17
+ }
13
18
  },
14
- "types": "./index.d.ts",
19
+ "type": "module",
20
+ "types": "./dist/types/index.d.ts",
15
21
  "scripts": {
16
- "build": "shx rm -rf ./dist && npm run build:umd && npm run build:tsc && npm run build:lib-esm && shx cp ./package.json ./dist/ && shx cp -r ./src/styles ./dist && shx mv ./dist/umd/styles/** ./dist/styles/ && shx rm -rf ./dist/umd/styles",
17
- "build:umd": "webpack --config webpack.config.js && shx rm -rf ./dist/umd/styles/*.js",
18
- "build:tsc": "tsc -p ./",
19
- "build:lib-esm": "tsc -p ./ -m es6 --declaration false --declarationMap false -m es6 --outDir dist/lib-esm",
22
+ "build": "shx rm -rf ./dist/** && npm run build:umd && npm run build:commonjs && npm run build:es6 && shx cp -r ./src/presets/styles ./dist && npm run build:types",
23
+ "build:umd": "webpack --config webpack.config.mjs && shx mkdir -p ./dist/styles && shx mv ./dist/umd/styles/** ./dist/styles/ && shx rm -rf ./dist/umd/styles",
24
+ "build:es6": "shx rm -rf ./out-tsc/** && tsc -p ./ -m es6 --declaration true --declarationDir ./out-tsc/ --declarationMap false -m es6 --outDir dist/es6 && renamer --find .js --replace .mjs \"dist/es6/**\"",
25
+ "build:commonjs": "tsc -p ./ -m commonjs --declarationMap false -m es6 --outDir dist/commonjs && renamer --find .js --replace .cjs \"dist/commonjs/**\"",
26
+ "build:types": "api-extractor run --local -c api-extractor.json --verbose && api-extractor run --local -c api-extractor-math.json",
20
27
  "inspect": "webpack --config webpack.config.js --profile --json > dist/umd/stats.json && webpack-bundle-analyzer dist/umd/stats.json",
21
28
  "test": "jest",
22
29
  "format": "prettier --write ."
@@ -45,6 +52,7 @@
45
52
  "@babel/preset-env": "^7.12.7",
46
53
  "@babel/preset-typescript": "^7.12.7",
47
54
  "@cnblogs/prettier-config": "^2.0.3",
55
+ "@microsoft/api-extractor": "^7.34.4",
48
56
  "@types/babel__core": "^7.1.12",
49
57
  "@types/jest": "^26.0.17",
50
58
  "@types/katex": "^0.11.0",
@@ -65,6 +73,7 @@
65
73
  "postcss": "^8.4.5",
66
74
  "postcss-loader": "^7.0.1",
67
75
  "prettier": "^2.5.1",
76
+ "renamer": "^4.0.0",
68
77
  "shx": "^0.3.4",
69
78
  "ts-jest": "^26.4.4",
70
79
  "typescript": "^4.6.4",
@@ -83,5 +92,15 @@
83
92
  "@cnblogs-team:registry": "https://npm.pkg.github.com/",
84
93
  "@cnblogs-gitlab:registry": "https://gitlab.cnblogs.com/api/v4/projects/371/packages/npm/",
85
94
  "@cnblogs:registry": "https://registry.npmjs.org/"
86
- }
95
+ },
96
+ "files": [
97
+ "dist/",
98
+ "math/",
99
+ "package.json",
100
+ "README.adoc",
101
+ ".gitignore",
102
+ "tslint.json",
103
+ "tsconfig.base.json",
104
+ "tsconfig.json"
105
+ ]
87
106
  }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "es2015",
4
+ "declaration": false,
5
+ "removeComments": true,
6
+ "moduleResolution": "node",
7
+ "target": "es2015",
8
+ "sourceMap": true,
9
+ "lib": ["es2020"],
10
+ "outDir": "./dist",
11
+ "baseUrl": "./",
12
+ "incremental": true,
13
+ "esModuleInterop": true,
14
+ "strictBindCallApply": true
15
+ },
16
+ "exclude": ["node_modules", "dist"]
17
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
4
+ }
package/tslint.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "defaultSeverity": "error",
3
+ "extends": ["tslint:recommended"],
4
+ "jsRules": {
5
+ "no-unused-expression": true
6
+ },
7
+ "rules": {
8
+ "quotemark": [true, "single"],
9
+ "member-access": [false],
10
+ "ordered-imports": [false],
11
+ "max-line-length": [true, 150],
12
+ "member-ordering": [false],
13
+ "interface-name": [false],
14
+ "arrow-parens": false,
15
+ "object-literal-sort-keys": false
16
+ },
17
+ "rulesDirectory": []
18
+ }
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './markdown-it-factory';
package/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./markdown-it-factory"), exports);
18
- //# sourceMappingURL=index.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
package/lib-esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './markdown-it-factory';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -1,102 +0,0 @@
1
- import MarkdownIt from 'markdown-it';
2
- import hljs from 'highlight.js';
3
- import MarkdownItContainer from 'markdown-it-container';
4
- import MdAbbr from 'markdown-it-abbr';
5
- import MdDefList from 'markdown-it-deflist';
6
- import MdEmoji from 'markdown-it-emoji';
7
- import MdFootnote from 'markdown-it-footnote';
8
- import MdMark from 'markdown-it-mark';
9
- import MdSub from 'markdown-it-sub';
10
- import MdSup from 'markdown-it-sup';
11
- import MdAnchor from 'markdown-it-anchor';
12
- import LazyHeaders from 'markdown-it-lazy-headers';
13
- import InlineTokensIterator from 'markdown-it-for-inline';
14
- import MarkdownTaskLists from 'markdown-it-task-lists';
15
- import MarkdownItAttrs from 'markdown-it-attrs';
16
- import { simpleMathPlugin } from './plugins/simple-math.plugin';
17
- import { diagramPlugin } from './plugins/simple-mermaid.plugin';
18
- import { HtmlFilterPlugin } from './plugins/html-filter.plugin';
19
- import { MultilineBlockquotePlugin, MultilineBlockquoteRule, } from './plugins/multiline-blockquote/multiline-blockquote.plugin';
20
- import { defaultTaskListsOption, defaultMarkdownItOption as defaultOption, defaultLinkifyOptions, anchorOption, } from './option';
21
- import { TocPlugin } from './plugins/toc';
22
- import { HighlightCodeLinesPlugin, LineNumberAttrRegex, } from './plugins/highlight-code-lines.plugin';
23
- import { meta } from './plugins/meta';
24
- import { UniqueCustomIdAttrs } from './plugins/unique-custom-id';
25
- const mdUtils = new MarkdownIt().utils;
26
- const defaultCodeHighlight = (str, lang) => {
27
- if (lang && hljs.getLanguage(lang)) {
28
- try {
29
- const result = hljs.highlight(lang, str, true);
30
- return `<pre class="hljs"><code data-lang="${result.language}">${result.value}</code></pre>`;
31
- }
32
- catch (_a) { }
33
- }
34
- return `<pre class="hljs"><code>${mdUtils.escapeHtml(str)}</code></pre>`;
35
- };
36
- const addLinkAttributes = [
37
- InlineTokensIterator,
38
- 'url_new_win',
39
- 'link_open',
40
- (tokens, idx) => {
41
- const token = tokens[idx];
42
- const href = token.attrGet('href');
43
- if (!href) {
44
- return;
45
- }
46
- if (!href.startsWith('#')) {
47
- token.attrPush(['target', '_blank']);
48
- }
49
- },
50
- ];
51
- const markdownItFactory = ({ html, codeHighlight, taskListsOption, math, disableRules, linkify: linkifyOption, } = defaultOption) => {
52
- const mdOpt = {
53
- html: html,
54
- breaks: true,
55
- linkify: true,
56
- };
57
- taskListsOption !== null && taskListsOption !== void 0 ? taskListsOption : (taskListsOption = defaultTaskListsOption);
58
- linkifyOption = Object.assign({}, defaultLinkifyOptions, linkifyOption !== null && linkifyOption !== void 0 ? linkifyOption : defaultLinkifyOptions);
59
- if (codeHighlight) {
60
- mdOpt.highlight = defaultCodeHighlight;
61
- }
62
- const md = new MarkdownIt(mdOpt)
63
- .use(MarkdownItContainer)
64
- .use(diagramPlugin)
65
- .use(MarkdownItAttrs, { allowedAttributes: ['id', 'class', LineNumberAttrRegex] })
66
- .use(MdAnchor, anchorOption)
67
- .use(UniqueCustomIdAttrs)
68
- .use(TocPlugin)
69
- .use(MdAbbr)
70
- .use(MdDefList)
71
- .use(MdEmoji)
72
- .use(MdFootnote)
73
- .use(MdMark)
74
- .use(MdSub)
75
- .use(MdSup)
76
- .use(HighlightCodeLinesPlugin)
77
- .use(LazyHeaders)
78
- .use(MarkdownTaskLists, taskListsOption)
79
- .use(HtmlFilterPlugin)
80
- .use(...addLinkAttributes)
81
- .use(MultilineBlockquotePlugin);
82
- md.block.ruler.before('hr', 'meta', meta);
83
- if (math) {
84
- md.use(simpleMathPlugin);
85
- }
86
- if (disableRules && disableRules.length > 0) {
87
- md.disable(disableRules);
88
- }
89
- const { normalize: defaultNormalize } = md.linkify.set(linkifyOption);
90
- if (linkifyOption.fuzzyLink && linkifyOption.fuzzyLinkUseHttps) {
91
- md.linkify.normalize = ((match) => {
92
- if (!match.schema) {
93
- match.url = `https://${match.url}`;
94
- return;
95
- }
96
- defaultNormalize(match);
97
- });
98
- }
99
- return md;
100
- };
101
- export { MultilineBlockquotePlugin, MultilineBlockquoteRule, markdownItFactory, MarkdownIt, HighlightCodeLinesPlugin, };
102
- //# sourceMappingURL=markdown-it-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-it-factory.js","sourceRoot":"","sources":["../../src/markdown-it-factory.ts"],"names":[],"mappings":"AAAA,OAAO,UAAgC,MAAM,aAAa,CAAC;AAC3D,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAC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AC,CAAC;AAEF,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EAEvB,iBAAiB,EACjB,UAAU,EAEV,wBAAwB,GAC3B,CAAC"}
@@ -1,13 +0,0 @@
1
- import { MathEngine } from './model';
2
- import { Mathjax2Renderer, MathJax3Renderer } from './impl';
3
- export const createMathJaxRenderer = (rendererConfig) => {
4
- switch (rendererConfig.engine) {
5
- case MathEngine.MathJax2:
6
- return new Mathjax2Renderer().config(rendererConfig);
7
- case MathEngine.MathJax3:
8
- return new MathJax3Renderer().config(rendererConfig);
9
- default:
10
- throw Error('Renderer unavailable');
11
- }
12
- };
13
- //# sourceMappingURL=factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/math/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAkD,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACjC,cAAiB,EACsD,EAAE;IACzE,QAAQ,cAAc,CAAC,MAAM,EAAE;QAC3B,KAAK,UAAU,CAAC,QAAQ;YACpB,OAAO,IAAI,gBAAgB,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzD,KAAK,UAAU,CAAC,QAAQ;YACpB,OAAO,IAAI,gBAAgB,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzD;YACI,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;KAC3C;AACL,CAAC,CAAC"}