Skip to content

Commit 6157583

Browse files
authored
Optimize markdown parsing (#2850)
1 parent 359bb97 commit 6157583

File tree

15 files changed

+283
-80
lines changed

15 files changed

+283
-80
lines changed

.changeset/nervous-buses-own.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@gitbook/openapi-parser': patch
3+
'@gitbook/react-openapi': patch
4+
'gitbook': patch
5+
---
6+
7+
Improve Markdown parsing

bun.lock

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"packages/gitbook": {
3333
"name": "gitbook",
34-
"version": "0.6.0",
34+
"version": "0.6.1",
3535
"dependencies": {
3636
"@gitbook/api": "^0.93.0",
3737
"@gitbook/cache-do": "workspace:*",
@@ -61,6 +61,8 @@
6161
"mathjax": "^3.2.2",
6262
"mdast-util-to-markdown": "^2.1.2",
6363
"memoizee": "^0.4.15",
64+
"micromark": "^4.0.1",
65+
"micromark-extension-gfm": "^3.0.0",
6466
"next": "14.2.23",
6567
"next-themes": "^0.2.1",
6668
"nuqs": "^2.2.3",
@@ -71,17 +73,11 @@
7173
"react": "18.3.1",
7274
"react-dom": "18.3.1",
7375
"react-hotkeys-hook": "^4.4.1",
74-
"rehype-sanitize": "^6.0.0",
75-
"rehype-stringify": "^10.0.0",
76-
"remark-gfm": "^4.0.0",
77-
"remark-parse": "^11.0.0",
78-
"remark-rehype": "^11.1.0",
7976
"rison": "^0.1.1",
8077
"server-only": "^0.0.1",
8178
"shiki": "^1.27.2",
8279
"tailwind-merge": "^2.2.0",
8380
"tailwind-shades": "^1.1.2",
84-
"unified": "^11.0.4",
8581
"url-join": "^5.0.0",
8682
"usehooks-ts": "^3.1.0",
8783
},
@@ -207,7 +203,7 @@
207203
},
208204
"packages/react-openapi": {
209205
"name": "@gitbook/react-openapi",
210-
"version": "1.0.0",
206+
"version": "1.0.1",
211207
"dependencies": {
212208
"@gitbook/openapi-parser": "workspace:*",
213209
"@scalar/api-client-react": "1.0.87",
@@ -2210,7 +2206,7 @@
22102206

22112207
"hast-util-sanitize": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "@ungap/structured-clone": "^1.2.0", "unist-util-position": "^5.0.0" } }, "sha512-IGrgWLuip4O2nq5CugXy4GI2V8kx4sFVy5Hd4vF7AR2gxS0N9s7nEAVUyeMtZKZvzrxVsHt73XdTsno1tClIkQ=="],
22122208

2213-
"hast-util-to-html": ["[email protected].3", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^6.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg=="],
2209+
"hast-util-to-html": ["[email protected].4", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^6.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-wxQzXtdbhiwGAUKrnQJXlOPmHnEehzphwkK7aluUPQ+lEc1xefC8pblMgpp2w5ldBTEfveRIrADcrhGIWrlTDA=="],
22142210

22152211
"hast-util-to-parse5": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "property-information": "^6.0.0", "space-separated-tokens": "^2.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0" } }, "sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw=="],
22162212

@@ -2332,7 +2328,7 @@
23322328

23332329
"is-path-inside": ["[email protected]", "", {}, "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ=="],
23342330

2335-
"is-plain-obj": ["is-plain-obj@4.1.0", "", {}, "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="],
2331+
"is-plain-obj": ["is-plain-obj@1.1.0", "", {}, "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg=="],
23362332

23372333
"is-promise": ["[email protected]", "", {}, "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="],
23382334

@@ -2542,7 +2538,7 @@
25422538

25432539
"microdiff": ["[email protected]", "", {}, "sha512-OBKBOa1VBznvLPb/3ljeJaENVe0fO0lnWl77lR4vhPlQD71UpjEoRV5P0KdQkcjbFlBu1Oy2mEUBMU3wxcBAGg=="],
25442540

2545-
"micromark": ["[email protected].0", "", { "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-core-commonmark": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-sanitize-uri": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ=="],
2541+
"micromark": ["[email protected].1", "", { "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-core-commonmark": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-sanitize-uri": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-eBPdkcoCNvYcxQOAKAlceo5SNdzZWfF+FcSupREAzdAh9rRmE239CEQAiTwIgblwnoM8zzj35sZ5ZwvSEOF6Kw=="],
25462542

25472543
"micromark-core-commonmark": ["[email protected]", "", { "dependencies": { "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-factory-destination": "^2.0.0", "micromark-factory-label": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-factory-title": "^2.0.0", "micromark-factory-whitespace": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-html-tag-name": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-CUQyKr1e///ZODyD1U3xit6zXwy1a8q2a1S1HKtIlmgvurrEpaw/Y9y6KSIbF8P59cn/NjzHyO+Q2fAyYLQrAA=="],
25482544

@@ -4292,8 +4288,6 @@
42924288

42934289
"@sentry/webpack-plugin/uuid": ["[email protected]", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA=="],
42944290

4295-
"@shikijs/core/hast-util-to-html": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^6.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-wxQzXtdbhiwGAUKrnQJXlOPmHnEehzphwkK7aluUPQ+lEc1xefC8pblMgpp2w5ldBTEfveRIrADcrhGIWrlTDA=="],
4296-
42974291
"@smithy/abort-controller/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
42984292

42994293
"@smithy/chunked-blob-reader/tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
@@ -4682,6 +4676,8 @@
46824676

46834677
"mdast-util-find-and-replace/escape-string-regexp": ["[email protected]", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
46844678

4679+
"mdast-util-from-markdown/micromark": ["[email protected]", "", { "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "micromark-core-commonmark": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-chunked": "^2.0.0", "micromark-util-combine-extensions": "^2.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-resolve-all": "^2.0.0", "micromark-util-sanitize-uri": "^2.0.0", "micromark-util-subtokenize": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ=="],
4680+
46854681
"mdast-util-gfm/mdast-util-to-markdown": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ=="],
46864682

46874683
"mdast-util-gfm-footnote/mdast-util-to-markdown": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ=="],
@@ -4700,12 +4696,8 @@
47004696

47014697
"micro/content-type": ["[email protected]", "", {}, "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="],
47024698

4703-
"micromark/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ=="],
4704-
47054699
"minimist-options/arrify": ["[email protected]", "", {}, "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA=="],
47064700

4707-
"minimist-options/is-plain-obj": ["[email protected]", "", {}, "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg=="],
4708-
47094701
"minizlib/minipass": ["[email protected]", "", { "dependencies": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } }, "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg=="],
47104702

47114703
"next/@swc/helpers": ["@swc/[email protected]", "", { "dependencies": { "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A=="],
@@ -4760,6 +4752,8 @@
47604752

47614753
"read-yaml-file/pify": ["[email protected]", "", {}, "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="],
47624754

4755+
"rehype-stringify/hast-util-to-html": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^6.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg=="],
4756+
47634757
"remark-stringify/mdast-util-to-markdown": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ=="],
47644758

47654759
"require-in-the-middle/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ=="],
@@ -4814,6 +4808,8 @@
48144808

48154809
"type-is/mime-types": ["[email protected]", "", { "dependencies": { "mime-db": "^1.53.0" } }, "sha512-XqoSHeCGjVClAmoGFG3lVFqQFRIrTVw2OH3axRqAcfaw+gHWIfnASS92AV+Rl/mk0MupgZTRHQOjxY6YVnzK5w=="],
48164810

4811+
"unified/is-plain-obj": ["[email protected]", "", {}, "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="],
4812+
48174813
"unplugin/chokidar": ["[email protected]", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
48184814

48194815
"update-notifier/chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg=="],
@@ -5614,6 +5610,8 @@
56145610

56155611
"gtoken/jws/jwa": ["[email protected]", "", { "dependencies": { "buffer-equal-constant-time": "1.0.1", "ecdsa-sig-formatter": "1.0.11", "safe-buffer": "^5.0.1" } }, "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA=="],
56165612

5613+
"mdast-util-from-markdown/micromark/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ=="],
5614+
56175615
"raw-body/http-errors/depd": ["[email protected]", "", {}, "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ=="],
56185616

56195617
"raw-body/http-errors/inherits": ["[email protected]", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],

packages/gitbook/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"mathjax": "^3.2.2",
4646
"mdast-util-to-markdown": "^2.1.2",
4747
"memoizee": "^0.4.15",
48+
"micromark": "^4.0.1",
49+
"micromark-extension-gfm": "^3.0.0",
4850
"next": "14.2.23",
4951
"next-themes": "^0.2.1",
5052
"nuqs": "^2.2.3",
@@ -55,17 +57,11 @@
5557
"react": "18.3.1",
5658
"react-dom": "18.3.1",
5759
"react-hotkeys-hook": "^4.4.1",
58-
"rehype-sanitize": "^6.0.0",
59-
"rehype-stringify": "^10.0.0",
60-
"remark-gfm": "^4.0.0",
61-
"remark-parse": "^11.0.0",
62-
"remark-rehype": "^11.1.0",
6360
"rison": "^0.1.1",
6461
"server-only": "^0.0.1",
6562
"shiki": "^1.27.2",
6663
"tailwind-merge": "^2.2.0",
6764
"tailwind-shades": "^1.1.2",
68-
"unified": "^11.0.4",
6965
"url-join": "^5.0.0",
7066
"usehooks-ts": "^3.1.0"
7167
},

packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { OpenAPIOperation } from '@gitbook/react-openapi';
44
import React from 'react';
55

66
import { LoadingPane } from '@/components/primitives';
7-
import { fetchOpenAPIBlock } from '@/lib/openapi';
7+
import { fetchOpenAPIBlock } from '@/lib/openapi/fetch';
88
import { tcls } from '@/lib/tailwind';
99

1010
import { BlockProps } from '../Block';
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Bun Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`parseMarkdown should parse a simple table 1`] = `
4+
"<h2>Table</h2>
5+
<table>
6+
<thead>
7+
<tr>
8+
<th>a</th>
9+
<th align="left">b</th>
10+
<th align="right">c</th>
11+
<th align="center">d</th>
12+
</tr>
13+
</thead>
14+
</table>"
15+
`;
16+
17+
exports[`parseMarkdown should parse a complex table 1`] = `
18+
"<p>Returns information for all non-fungible tokens for an account.</p>
19+
<h2>Ordering</h2>
20+
<p>When considering NFTs, their order is governed by a combination of their numerical <strong>token.Id</strong> and <strong>serialnumber</strong> values, with <strong>token.id</strong> being the parent column.
21+
A serialnumbers value governs its order within the given token.id</p>
22+
<p>In that regard, if a user acquired a set of NFTs in the order (2-2, 2-4 1-5, 1-1, 1-3, 3-3, 3-4), the following layouts illustrate the ordering expectations for ownership listing</p>
23+
<ol>
24+
<li><strong>All NFTs in ASC order</strong>: 1-1, 1-3, 1-5, 2-2, 2-4, 3-3, 3-4</li>
25+
<li><strong>All NFTs in DESC order</strong>: 3-4, 3-3, 2-4, 2-2, 1-5, 1-3, 1-1</li>
26+
<li><strong>NFTs above 1-1 in ASC order</strong>: 1-3, 1-5, 2-2, 2-4, 3-3, 3-4</li>
27+
<li><strong>NFTs below 3-3 in ASC order</strong>: 1-1, 1-3, 1-5, 2-2, 2-4</li>
28+
<li><strong>NFTs between 1-3 and 3-3 inclusive in DESC order</strong>: 3-4, 3-3, 2-4, 2-2, 1-5, 1-3</li>
29+
</ol>
30+
<p>Note: The default order for this API is currently DESC</p>
31+
<h2>Filtering</h2>
32+
<p>When filtering there are some restrictions enforced to ensure correctness and scalability.</p>
33+
<p><strong>The table below defines the restrictions and support for the NFT ownership endpoint</strong></p>
34+
<table>
35+
<thead>
36+
<tr>
37+
<th>Query Param</th>
38+
<th>Comparison Operator</th>
39+
<th>Support</th>
40+
<th>Description</th>
41+
<th>Example</th>
42+
</tr>
43+
</thead>
44+
<tbody>
45+
<tr>
46+
<td>token.id</td>
47+
<td>eq</td>
48+
<td>Y</td>
49+
<td>Single occurrence only.</td>
50+
<td>?token.id=X</td>
51+
</tr>
52+
<tr>
53+
<td></td>
54+
<td>ne</td>
55+
<td>N</td>
56+
<td></td>
57+
<td></td>
58+
</tr>
59+
<tr>
60+
<td></td>
61+
<td>lt(e)</td>
62+
<td>Y</td>
63+
<td>Single occurrence only.</td>
64+
<td>?token.id=lte:X</td>
65+
</tr>
66+
<tr>
67+
<td></td>
68+
<td>gt(e)</td>
69+
<td>Y</td>
70+
<td>Single occurrence only.</td>
71+
<td>?token.id=gte:X</td>
72+
</tr>
73+
<tr>
74+
<td>serialnumber</td>
75+
<td>eq</td>
76+
<td>Y</td>
77+
<td>Single occurrence only. Requires the presence of a <strong>token.id</strong> query</td>
78+
<td>?serialnumber=Y</td>
79+
</tr>
80+
<tr>
81+
<td></td>
82+
<td>ne</td>
83+
<td>N</td>
84+
<td></td>
85+
<td></td>
86+
</tr>
87+
<tr>
88+
<td></td>
89+
<td>lt(e)</td>
90+
<td>Y</td>
91+
<td>Single occurrence only. Requires the presence of an <strong>lte</strong> or <strong>eq</strong> <strong>token.id</strong> query</td>
92+
<td>?token.id=lte:X&amp;serialnumber=lt:Y</td>
93+
</tr>
94+
<tr>
95+
<td></td>
96+
<td>gt(e)</td>
97+
<td>Y</td>
98+
<td>Single occurrence only. Requires the presence of an <strong>gte</strong> or <strong>eq</strong> <strong>token.id</strong> query</td>
99+
<td>?token.id=gte:X&amp;serialnumber=gt:Y</td>
100+
</tr>
101+
<tr>
102+
<td>spender.id</td>
103+
<td>eq</td>
104+
<td>Y</td>
105+
<td></td>
106+
<td>?spender.id=Z</td>
107+
</tr>
108+
<tr>
109+
<td></td>
110+
<td>ne</td>
111+
<td>N</td>
112+
<td></td>
113+
<td></td>
114+
</tr>
115+
<tr>
116+
<td></td>
117+
<td>lt(e)</td>
118+
<td>Y</td>
119+
<td></td>
120+
<td>?spender.id=lt:Z</td>
121+
</tr>
122+
<tr>
123+
<td></td>
124+
<td>gt(e)</td>
125+
<td>Y</td>
126+
<td></td>
127+
<td>?spender.id=gt:Z</td>
128+
</tr>
129+
</tbody>
130+
</table>
131+
<p>Note: When searching across a range for individual NFTs a <strong>serialnumber</strong> with an additional <strong>token.id</strong> query filter must be provided.
132+
Both filters must be a single occurrence of <strong>gt(e)</strong> or <strong>lt(e)</strong> which provide a lower and or upper boundary for search.</p>"
133+
`;

packages/gitbook/src/lib/document-sections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { JSONDocument, ContentRef } from '@gitbook/api';
22

33
import { getNodeText } from './document';
4-
import { fetchOpenAPIBlock } from './openapi';
4+
import { fetchOpenAPIBlock } from './openapi/fetch';
55
import { ResolvedContentRef } from './references';
66

77
export interface DocumentSection {

packages/gitbook/src/lib/markdown.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('parseMarkdown', () => {
99
| a | b | c | d |
1010
| - | :- | -: | :-: |`);
1111

12-
expect(result).toContain('<table>');
12+
expect(result).toMatchSnapshot();
1313
});
1414

1515
it('should parse a complex table', async () => {
@@ -52,6 +52,6 @@ When filtering there are some restrictions enforced to ensure correctness and sc
5252
Note: When searching across a range for individual NFTs a **serialnumber** with an additional **token.id** query filter must be provided.
5353
Both filters must be a single occurrence of **gt(e)** or **lt(e)** which provide a lower and or upper boundary for search.`);
5454

55-
expect(result).toContain('<table>');
55+
expect(result).toMatchSnapshot();
5656
});
5757
});

0 commit comments

Comments
 (0)