docusaurus-plugin-openapi-docs 0.0.0-723 → 0.0.0-724
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.
- package/lib/markdown/utils.d.ts +3 -0
- package/lib/markdown/utils.js +22 -1
- package/package.json +2 -2
- package/src/markdown/utils.ts +22 -0
package/lib/markdown/utils.d.ts
CHANGED
|
@@ -8,3 +8,6 @@ export declare function render(children: Children): string;
|
|
|
8
8
|
export declare const lessThan: RegExp;
|
|
9
9
|
export declare const greaterThan: RegExp;
|
|
10
10
|
export declare const codeFence: RegExp;
|
|
11
|
+
export declare const curlyBrackets: RegExp;
|
|
12
|
+
export declare const codeBlock: RegExp;
|
|
13
|
+
export declare function clean(value: string | undefined): string;
|
package/lib/markdown/utils.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.codeFence = exports.greaterThan = exports.lessThan = exports.render = exports.guard = exports.create = void 0;
|
|
9
|
+
exports.clean = exports.codeBlock = exports.curlyBrackets = exports.codeFence = exports.greaterThan = exports.lessThan = exports.render = exports.guard = exports.create = void 0;
|
|
10
10
|
function create(tag, props) {
|
|
11
11
|
const { children, ...rest } = props;
|
|
12
12
|
let propString = "";
|
|
@@ -38,3 +38,24 @@ exports.render = render;
|
|
|
38
38
|
exports.lessThan = /<(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/gu;
|
|
39
39
|
exports.greaterThan = /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
40
40
|
exports.codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|
|
41
|
+
exports.curlyBrackets = /([{}])/g;
|
|
42
|
+
exports.codeBlock = /(^```.*[\s\S]*?```$|`[^`].+?`)/gm;
|
|
43
|
+
function clean(value) {
|
|
44
|
+
if (!value) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
let sections = value.split(exports.codeBlock);
|
|
48
|
+
for (let sectionIndex in sections) {
|
|
49
|
+
if (!sections[sectionIndex].startsWith("`")) {
|
|
50
|
+
sections[sectionIndex] = sections[sectionIndex]
|
|
51
|
+
.replace(exports.lessThan, "<")
|
|
52
|
+
.replace(exports.greaterThan, ">")
|
|
53
|
+
.replace(exports.codeFence, function (match) {
|
|
54
|
+
return match.replace(/\\>/g, ">");
|
|
55
|
+
})
|
|
56
|
+
.replace(exports.curlyBrackets, "\\$1");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return sections.join("");
|
|
60
|
+
}
|
|
61
|
+
exports.clean = clean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-724",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "210bdf060a30737037cd96cf410991c2401d7d45"
|
|
64
64
|
}
|
package/src/markdown/utils.ts
CHANGED
|
@@ -47,3 +47,25 @@ export const lessThan =
|
|
|
47
47
|
export const greaterThan =
|
|
48
48
|
/(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|bold|a|li|ol|ul|img|svg|div|center|\/|\s|"|'))>/gu;
|
|
49
49
|
export const codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
|
|
50
|
+
export const curlyBrackets = /([{}])/g;
|
|
51
|
+
export const codeBlock = /(^```.*[\s\S]*?```$|`[^`].+?`)/gm;
|
|
52
|
+
|
|
53
|
+
export function clean(value: string | undefined): string {
|
|
54
|
+
if (!value) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let sections = value.split(codeBlock);
|
|
59
|
+
for (let sectionIndex in sections) {
|
|
60
|
+
if (!sections[sectionIndex].startsWith("`")) {
|
|
61
|
+
sections[sectionIndex] = sections[sectionIndex]
|
|
62
|
+
.replace(lessThan, "<")
|
|
63
|
+
.replace(greaterThan, ">")
|
|
64
|
+
.replace(codeFence, function (match) {
|
|
65
|
+
return match.replace(/\\>/g, ">");
|
|
66
|
+
})
|
|
67
|
+
.replace(curlyBrackets, "\\$1");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return sections.join("");
|
|
71
|
+
}
|