@scalar/openapi-to-markdown 1.7.8 → 1.7.10
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/CHANGELOG.md +17 -0
- package/dist/parse-description.d.ts.map +1 -1
- package/dist/parse-description.js +2 -5
- package/dist/parse-html-description.d.ts.map +1 -1
- package/dist/parse-html-description.js +2 -7
- package/dist/render-document.d.ts.map +1 -1
- package/dist/render-document.js +4 -9
- package/package.json +22 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scalar/openapi-to-markdown
|
|
2
2
|
|
|
3
|
+
## 1.7.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#11124](https://github.com/scalar/scalar/pull/11124): Render Markdown through `@scalar/markdown` instead of `@scalar/code-highlight`
|
|
8
|
+
|
|
9
|
+
None of them pull in lowlight or highlight.js any more: code blocks in descriptions are highlighted by `@scalar/highlight`, the same highlighter `ScalarCodeBlock` uses. A fenced code block without a language is no longer auto-detected and renders as plain text. In `@scalar/openapi-to-markdown` this shows up in descriptions that contain HTML or alerts: an unlabeled fence used to come out labeled with highlight.js's guess (often wrong, such as `properties` for JSON), and now stays unlabeled.
|
|
10
|
+
- [#11124](https://github.com/scalar/scalar/pull/11124): Share one copy of the Markdown parser stack
|
|
11
|
+
|
|
12
|
+
`@scalar/markdown` adds `parseMarkdown`, `mdastFromHtml` and `createMarkdownSerializer`. `@scalar/openapi-to-markdown` and `@scalar/asyncapi-to-markdown` use them instead of importing `unified`, `remark-*` and `rehype-*` themselves. `@scalar/markdown` bundles that stack, so a bundle that included both used to carry two copies of parse5, micromark and the mdast/hast utilities; the API Reference standalone build is about 330 KB smaller, 99 KB gzipped. Sharing the stack does not change the Markdown either package produces.
|
|
13
|
+
|
|
14
|
+
## 1.7.9
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#11099](https://github.com/scalar/scalar/pull/11099): Update compatible runtime and styling dependencies, align editor dependency versions, and preserve document-change comparisons with updated microdiff semantics.
|
|
19
|
+
|
|
3
20
|
## 1.7.8
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-description.d.ts","sourceRoot":"","sources":["../src/parse-description.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-description.d.ts","sourceRoot":"","sources":["../src/parse-description.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,WAAW,EAAE,MAAM,OAAO,CAAA;AAiG7D,0FAA0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;AAE1E,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,QAAO,CAAC,MAAM,iBAAiB,CAuDlE,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,GAAU,OAAO,WAAW,EAAE,EAAE,aAAa,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAkB3G,CAAA"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import remarkParse from 'remark-parse';
|
|
3
|
-
import { unified } from 'unified';
|
|
1
|
+
import { parseMarkdown } from '@scalar/markdown';
|
|
4
2
|
import { safeUrl } from './markdown-nodes.js';
|
|
5
|
-
const parser = unified().use(remarkParse).use(remarkGfm).freeze();
|
|
6
3
|
const containsHtml = (node) => node.type === 'html' || ('children' in node && node.children.some(containsHtml));
|
|
7
4
|
/** Remove images and unsafe URLs without converting ordinary Markdown to HTML. */
|
|
8
5
|
const clean = (node) => {
|
|
@@ -91,7 +88,7 @@ export const createDescriptionParser = () => {
|
|
|
91
88
|
if (isPlainText(value)) {
|
|
92
89
|
return [{ type: 'paragraph', children: [{ type: 'text', value: value.trim() }] }];
|
|
93
90
|
}
|
|
94
|
-
const parsed =
|
|
91
|
+
const parsed = parseMarkdown(value);
|
|
95
92
|
// Raw HTML and GitHub alerts retain Scalar's existing conversion behavior.
|
|
96
93
|
const tree = containsHtml(parsed) || /^\s*>\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|SUCCESS)\]/im.test(value)
|
|
97
94
|
? await (await import('./parse-html-description.js')).parseHtmlDescription(value)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-html-description.d.ts","sourceRoot":"","sources":["../src/parse-html-description.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"parse-html-description.d.ts","sourceRoot":"","sources":["../src/parse-html-description.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,IAGpD,CAAA"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { htmlFromMarkdown } from '@scalar/
|
|
2
|
-
import rehypeParse from 'rehype-parse';
|
|
3
|
-
import rehypeRemark from 'rehype-remark';
|
|
4
|
-
import rehypeSanitize from 'rehype-sanitize';
|
|
5
|
-
import { unified } from 'unified';
|
|
6
|
-
const converter = unified().use(rehypeParse, { fragment: true }).use(rehypeSanitize).use(rehypeRemark).freeze();
|
|
1
|
+
import { htmlFromMarkdown, mdastFromHtml } from '@scalar/markdown';
|
|
7
2
|
/** Compatibility path loaded only for descriptions containing HTML or Scalar alerts. */
|
|
8
3
|
export const parseHtmlDescription = (value) => {
|
|
9
4
|
const html = htmlFromMarkdown(value, { removeTags: ['img', 'picture'] });
|
|
10
|
-
return
|
|
5
|
+
return mdastFromHtml(html);
|
|
11
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-document.d.ts","sourceRoot":"","sources":["../src/render-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-document.d.ts","sourceRoot":"","sources":["../src/render-document.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,8DAA8D,CAAA;AAYrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAqD7D,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,QAAO,CAAC,CACzC,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,oBAAoB,KAC3B,OAAO,CAAC,MAAM,CAAC,CAyRnB,CAAA"}
|
package/dist/render-document.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { createMarkdownSerializer } from '@scalar/markdown';
|
|
2
3
|
import { forEachPathItemOperation, getResolvedPathItem, } from '@scalar/workspace-store/helpers/for-each-path-item-operation';
|
|
3
4
|
import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
4
|
-
import remarkGfm from 'remark-gfm';
|
|
5
|
-
import remarkStringify from 'remark-stringify';
|
|
6
|
-
import { unified } from 'unified';
|
|
7
5
|
import { anchor, createDocumentAnchors } from './document-anchors.js';
|
|
8
6
|
import { createDocumentExamples } from './document-examples.js';
|
|
9
7
|
import { field, heading, inlineCode, item, link, list, paragraph, strong, text } from './markdown-nodes.js';
|
|
@@ -13,9 +11,7 @@ import { formatOperationMethod, renderOperation } from './render-operation.js';
|
|
|
13
11
|
import { createSchemaRenderer } from './render-schema.js';
|
|
14
12
|
import { renderSecurity } from './render-security.js';
|
|
15
13
|
import { getTagSections } from './render-tags.js';
|
|
16
|
-
const
|
|
17
|
-
.use(remarkGfm)
|
|
18
|
-
.use(remarkStringify, {
|
|
14
|
+
const serialize = createMarkdownSerializer({
|
|
19
15
|
bullet: '-',
|
|
20
16
|
join: [
|
|
21
17
|
(left, right, parent) => {
|
|
@@ -33,8 +29,7 @@ const serializer = unified()
|
|
|
33
29
|
return undefined;
|
|
34
30
|
},
|
|
35
31
|
],
|
|
36
|
-
})
|
|
37
|
-
.freeze();
|
|
32
|
+
});
|
|
38
33
|
/** Authored values must survive even when the model does not generate an object example. */
|
|
39
34
|
const hasAuthoredExamples = (view) => isObject(view.schema) &&
|
|
40
35
|
(view.schema.example !== undefined || (Array.isArray(view.schema.examples) && view.schema.examples.length > 0));
|
|
@@ -119,7 +114,7 @@ export const createDocumentRenderer = () => {
|
|
|
119
114
|
}
|
|
120
115
|
const children = nodes.splice(0);
|
|
121
116
|
await expandDescriptions(children, description);
|
|
122
|
-
sections.push(
|
|
117
|
+
sections.push(serialize({ type: 'root', children }).trimEnd());
|
|
123
118
|
};
|
|
124
119
|
if (!single) {
|
|
125
120
|
const { info } = document;
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"llm",
|
|
17
17
|
"swagger"
|
|
18
18
|
],
|
|
19
|
-
"version": "1.7.
|
|
19
|
+
"version": "1.7.10",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22.19.0"
|
|
22
22
|
},
|
|
@@ -45,33 +45,33 @@
|
|
|
45
45
|
"CHANGELOG.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@scalar/
|
|
49
|
-
"@scalar/
|
|
50
|
-
"@scalar/
|
|
51
|
-
"@scalar/openapi-upgrader": "0.
|
|
52
|
-
"@scalar/workspace-store": "0.
|
|
53
|
-
"rehype-parse": "^9.0.1",
|
|
54
|
-
"rehype-remark": "^10.0.1",
|
|
55
|
-
"rehype-sanitize": "^6.0.0",
|
|
56
|
-
"remark-gfm": "^4.0.1",
|
|
57
|
-
"remark-parse": "^11.0.0",
|
|
58
|
-
"remark-stringify": "^11.0.0",
|
|
59
|
-
"unified": "^11.0.5"
|
|
48
|
+
"@scalar/helpers": "0.19.0",
|
|
49
|
+
"@scalar/json-magic": "0.21.1",
|
|
50
|
+
"@scalar/markdown": "0.1.0",
|
|
51
|
+
"@scalar/openapi-upgrader": "0.5.1",
|
|
52
|
+
"@scalar/workspace-store": "0.75.0"
|
|
60
53
|
},
|
|
61
54
|
"devDependencies": {
|
|
62
|
-
"@scalar/components": "0.35.
|
|
55
|
+
"@scalar/components": "0.35.3",
|
|
63
56
|
"@scalar/galaxy": "0.7.4",
|
|
64
|
-
"@scalar/
|
|
65
|
-
"@
|
|
57
|
+
"@scalar/highlight": "0.7.0",
|
|
58
|
+
"@scalar/themes": "0.20.3",
|
|
59
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
66
60
|
"@types/mdast": "^4.0.4",
|
|
67
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
68
|
-
"marked": "^18.
|
|
61
|
+
"@vitejs/plugin-vue": "^6.0.11",
|
|
62
|
+
"marked": "^18.2.0",
|
|
63
|
+
"rehype-parse": "^9.0.1",
|
|
64
|
+
"rehype-sanitize": "^6.0.0",
|
|
69
65
|
"rehype-stringify": "^10.0.1",
|
|
70
|
-
"
|
|
66
|
+
"remark-gfm": "^4.0.1",
|
|
67
|
+
"remark-parse": "^11.0.0",
|
|
68
|
+
"remark-stringify": "^11.0.0",
|
|
69
|
+
"tailwindcss": "^4.3.5",
|
|
71
70
|
"tsx": "4.23.15",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
71
|
+
"unified": "^11.0.5",
|
|
72
|
+
"vite": "8.3.8",
|
|
73
|
+
"vitest": "5.1.0",
|
|
74
|
+
"vue": "^3.5.45",
|
|
75
75
|
"vue-tsc": "3.3.11"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|