Preserve wiki links with aliases in markdown (#19527)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
8 files changed
+106
-70
No files matched your search
@@ -0,0 +1,13 @@
|
||||
#### Preserve wiki links with aliases (#19527 by @kovsu)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
[[Foo:Bar]]
|
||||
|
||||
<!-- Prettier stable -->
|
||||
[[Foo]]
|
||||
|
||||
<!-- Prettier main -->
|
||||
[[Foo:Bar]]
|
||||
```
|
||||
@@ -32,6 +32,7 @@
|
||||
"blenda",
|
||||
"Bopomofo",
|
||||
"bottlenecked",
|
||||
"braindb",
|
||||
"Breakell",
|
||||
"Brevik",
|
||||
"bunx",
|
||||
|
||||
+2
-2
@@ -46,6 +46,8 @@
|
||||
"@babel/code-frame": "8.0.0",
|
||||
"@babel/parser": "8.0.0",
|
||||
"@babel/types": "8.0.0",
|
||||
"@braindb/mdast-util-wiki-link": "0.2.0",
|
||||
"@braindb/micromark-extension-wiki-link": "0.1.0",
|
||||
"@glimmer/syntax": "0.95.0",
|
||||
"@prettier/cli": "0.12.0",
|
||||
"@prettier/html-event-attributes": "0.0.2",
|
||||
@@ -92,11 +94,9 @@
|
||||
"mdast-util-from-markdown": "2.0.3",
|
||||
"mdast-util-gfm": "3.1.0",
|
||||
"mdast-util-math": "3.0.0",
|
||||
"mdast-util-wiki-link": "0.1.2",
|
||||
"meriyah": "7.1.1",
|
||||
"micromark-extension-gfm": "3.0.0",
|
||||
"micromark-extension-math": "3.1.0",
|
||||
"micromark-extension-wiki-link": "0.0.4",
|
||||
"micromark-util-character": "2.1.1",
|
||||
"micromark-util-symbol": "2.0.1",
|
||||
"micromark-util-types": "2.0.2",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { fromMarkdown as wikiLinkFromMarkdown } from "@braindb/mdast-util-wiki-link";
|
||||
import { syntax as wikiLinkSyntax } from "@braindb/micromark-extension-wiki-link";
|
||||
import { fromMarkdown } from "mdast-util-from-markdown";
|
||||
import { mathFromMarkdown } from "mdast-util-math";
|
||||
import { fromMarkdown as wikiLinkFromMarkdown } from "mdast-util-wiki-link";
|
||||
import { gfm as gfmSyntax } from "micromark-extension-gfm";
|
||||
import { math as mathSyntax } from "micromark-extension-math";
|
||||
import { syntax as wikiLinkSyntax } from "micromark-extension-wiki-link";
|
||||
import parseFrontMatter from "../../main/front-matter/parse.js";
|
||||
import { gfmFromMarkdown } from "./micromark/mdast-util-gfm.js";
|
||||
import { overrideHtmlTextSyntax } from "./micromark/micromark-extension-html-text.js";
|
||||
@@ -18,7 +18,12 @@ function getMarkdownParseOptions() {
|
||||
extensions: [
|
||||
gfmSyntax(),
|
||||
mathSyntax(),
|
||||
wikiLinkSyntax(),
|
||||
wikiLinkSyntax({
|
||||
// We don't need support alias, use a fake string to bypass
|
||||
// https://github.com/stereobooster/braindb/blob/66d6cf74d0bad43f20924a14e382a432ff81cdfa/packages/micromark-extension-wiki-link/src/syntax.ts#L81
|
||||
// @ts-expect-error -- expected
|
||||
aliasDivider: { charCodeAt: () => Number.NaN },
|
||||
}),
|
||||
liquidSyntax(),
|
||||
overrideHtmlTextSyntax(),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`issue-19525.md format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
[[Foo:Bar]]
|
||||
|
||||
[[Foo:Foo]]
|
||||
|
||||
[[Foo|Bar]]
|
||||
|
||||
[[Foo|Foo]]
|
||||
|
||||
[[slug|Label: with colon]]
|
||||
|
||||
[[slug|A: B: C]]
|
||||
|
||||
[[slug|Label with no colon]]
|
||||
|
||||
[text|Label: with colon]
|
||||
|
||||
=====================================output=====================================
|
||||
[[Foo:Bar]]
|
||||
|
||||
[[Foo:Foo]]
|
||||
|
||||
[[Foo|Bar]]
|
||||
|
||||
[[Foo|Foo]]
|
||||
|
||||
[[slug|Label: with colon]]
|
||||
|
||||
[[slug|A: B: C]]
|
||||
|
||||
[[slug|Label with no colon]]
|
||||
|
||||
[text|Label: with colon]
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
runFormatTest(import.meta, ["markdown"]);
|
||||
@@ -0,0 +1,15 @@
|
||||
[[Foo:Bar]]
|
||||
|
||||
[[Foo:Foo]]
|
||||
|
||||
[[Foo|Bar]]
|
||||
|
||||
[[Foo|Foo]]
|
||||
|
||||
[[slug|Label: with colon]]
|
||||
|
||||
[[slug|A: B: C]]
|
||||
|
||||
[[slug|Label with no colon]]
|
||||
|
||||
[text|Label: with colon]
|
||||
@@ -417,13 +417,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/runtime@npm:^7.12.1":
|
||||
version: 7.29.7
|
||||
resolution: "@babel/runtime@npm:7.29.7"
|
||||
checksum: 10/9883b4951787779fd382b121f22f92966d85f19434841f65fb00b2dfec232107e139683f47c6f252891826ad8ee18317b46c3a0e4819116a9885f47b46d7126a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/template@npm:^7.29.7":
|
||||
version: 7.29.7
|
||||
resolution: "@babel/template@npm:7.29.7"
|
||||
@@ -484,6 +477,26 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@braindb/mdast-util-wiki-link@npm:0.2.0":
|
||||
version: 0.2.0
|
||||
resolution: "@braindb/mdast-util-wiki-link@npm:0.2.0"
|
||||
dependencies:
|
||||
"@types/unist": "npm:^3.0.2"
|
||||
mdast-util-from-markdown: "npm:^2.0.0"
|
||||
mdast-util-to-markdown: "npm:^2.1.0"
|
||||
checksum: 10/0950ec4c0f2432f9eab4df2817dffc7d44360409737ef6f2e519247c8fad286dc6cb4297d3bce884804ac55c0dc4077e727dae65aea17ae4790cefef6886e662
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@braindb/micromark-extension-wiki-link@npm:0.1.0":
|
||||
version: 0.1.0
|
||||
resolution: "@braindb/micromark-extension-wiki-link@npm:0.1.0"
|
||||
dependencies:
|
||||
micromark-util-types: "npm:^2.0.0"
|
||||
checksum: 10/d27d138abe21e08f95673d0927187ddcd3955b5dacc9e84a0f2507881e48f148ea83126e034d8afc859d2cc3f5d2ced3cc040bf38b126e89b4a1b6ed32b79434
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@cacheable/memory@npm:^2.2.0":
|
||||
version: 2.2.0
|
||||
resolution: "@cacheable/memory@npm:2.2.0"
|
||||
@@ -2699,7 +2712,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/unist@npm:*, @types/unist@npm:^3.0.0":
|
||||
"@types/unist@npm:*, @types/unist@npm:^3.0.0, @types/unist@npm:^3.0.2":
|
||||
version: 3.0.3
|
||||
resolution: "@types/unist@npm:3.0.3"
|
||||
checksum: 10/96e6453da9e075aaef1dc22482463898198acdc1eeb99b465e65e34303e2ec1e3b1ed4469a9118275ec284dc98019f63c3f5d49422f0e4ac707e5ab90fb3b71a
|
||||
@@ -6680,13 +6693,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"longest-streak@npm:^2.0.0":
|
||||
version: 2.0.4
|
||||
resolution: "longest-streak@npm:2.0.4"
|
||||
checksum: 10/28b8234a14963002c5c71035dee13a0a11e9e9d18ffa320fdc8796ed7437399204495702ed69cd2a7087b0af041a2a8b562829b7c1e2042e73a3374d1ecf6580
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"longest-streak@npm:^3.0.0":
|
||||
version: 3.1.0
|
||||
resolution: "longest-streak@npm:3.1.0"
|
||||
@@ -6910,20 +6916,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdast-util-to-markdown@npm:^0.6.5":
|
||||
version: 0.6.5
|
||||
resolution: "mdast-util-to-markdown@npm:0.6.5"
|
||||
dependencies:
|
||||
"@types/unist": "npm:^2.0.0"
|
||||
longest-streak: "npm:^2.0.0"
|
||||
mdast-util-to-string: "npm:^2.0.0"
|
||||
parse-entities: "npm:^2.0.0"
|
||||
repeat-string: "npm:^1.0.0"
|
||||
zwitch: "npm:^1.0.0"
|
||||
checksum: 10/e1fdb7a75f59166abe5d9d26fed5e04cd40bc6ab54cba239350f70c92df093106b9462660a1891210e9d52b2729c14fc107605127e25837b0a4ad74fbdfbd328
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdast-util-to-markdown@npm:^2.0.0, mdast-util-to-markdown@npm:^2.1.0":
|
||||
version: 2.1.2
|
||||
resolution: "mdast-util-to-markdown@npm:2.1.2"
|
||||
@@ -6941,13 +6933,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdast-util-to-string@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "mdast-util-to-string@npm:2.0.0"
|
||||
checksum: 10/0b2113ada10e002fbccb014170506dabe2f2ddacaacbe4bc1045c33f986652c5a162732a2c057c5335cdb58419e2ad23e368e5be226855d4d4e280b81c4e9ec2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdast-util-to-string@npm:^4.0.0":
|
||||
version: 4.0.0
|
||||
resolution: "mdast-util-to-string@npm:4.0.0"
|
||||
@@ -6957,16 +6942,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdast-util-wiki-link@npm:0.1.2":
|
||||
version: 0.1.2
|
||||
resolution: "mdast-util-wiki-link@npm:0.1.2"
|
||||
dependencies:
|
||||
"@babel/runtime": "npm:^7.12.1"
|
||||
mdast-util-to-markdown: "npm:^0.6.5"
|
||||
checksum: 10/80a4dd00f412f68d26cb0b23ef6c0efdec9d2b429614dda325eebdffb5c8d91c5c93037965afc29595b02f3fb10b691bd9e65d313a82ccc828074474055610db
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"memorystream@npm:^0.3.1":
|
||||
version: 0.3.1
|
||||
resolution: "memorystream@npm:0.3.1"
|
||||
@@ -7134,15 +7109,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"micromark-extension-wiki-link@npm:0.0.4":
|
||||
version: 0.0.4
|
||||
resolution: "micromark-extension-wiki-link@npm:0.0.4"
|
||||
dependencies:
|
||||
"@babel/runtime": "npm:^7.12.1"
|
||||
checksum: 10/668294fb5069ba869953d05e0cc79029962ba76d068c7288207b6b0ee2273e15059c810d5b7c10f3dcef030f559610ce31aeb4cd6955a0f2f359acdcca719bde
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"micromark-factory-destination@npm:^2.0.0":
|
||||
version: 2.0.1
|
||||
resolution: "micromark-factory-destination@npm:2.0.1"
|
||||
@@ -8229,6 +8195,8 @@ __metadata:
|
||||
"@babel/generator": "npm:8.0.0"
|
||||
"@babel/parser": "npm:8.0.0"
|
||||
"@babel/types": "npm:8.0.0"
|
||||
"@braindb/mdast-util-wiki-link": "npm:0.2.0"
|
||||
"@braindb/micromark-extension-wiki-link": "npm:0.1.0"
|
||||
"@eslint/js": "npm:10.0.1"
|
||||
"@glimmer/syntax": "npm:0.95.0"
|
||||
"@prettier/cli": "npm:0.12.0"
|
||||
@@ -8318,11 +8286,9 @@ __metadata:
|
||||
mdast-util-from-markdown: "npm:2.0.3"
|
||||
mdast-util-gfm: "npm:3.1.0"
|
||||
mdast-util-math: "npm:3.0.0"
|
||||
mdast-util-wiki-link: "npm:0.1.2"
|
||||
meriyah: "npm:7.1.1"
|
||||
micromark-extension-gfm: "npm:3.0.0"
|
||||
micromark-extension-math: "npm:3.1.0"
|
||||
micromark-extension-wiki-link: "npm:0.0.4"
|
||||
micromark-util-character: "npm:2.1.1"
|
||||
micromark-util-symbol: "npm:2.0.1"
|
||||
micromark-util-types: "npm:2.0.2"
|
||||
@@ -8602,7 +8568,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"repeat-string@npm:^1.0.0, repeat-string@npm:^1.5.4":
|
||||
"repeat-string@npm:^1.5.4":
|
||||
version: 1.6.1
|
||||
resolution: "repeat-string@npm:1.6.1"
|
||||
checksum: 10/1b809fc6db97decdc68f5b12c4d1a671c8e3f65ec4a40c238bc5200e44e85bcc52a54f78268ab9c29fcf5fe4f1343e805420056d1f30fa9a9ee4c2d93e3cc6c0
|
||||
@@ -10179,13 +10145,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"zwitch@npm:^1.0.0":
|
||||
version: 1.0.5
|
||||
resolution: "zwitch@npm:1.0.5"
|
||||
checksum: 10/28a1bebacab3bc60150b6b0a2ba1db2ad033f068e81f05e4892ec0ea13ae63f5d140a1d692062ac0657840c8da076f35b94433b5f1c329d7803b247de80f064a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"zwitch@npm:^2.0.0":
|
||||
version: 2.0.4
|
||||
resolution: "zwitch@npm:2.0.4"
|
||||
|
||||
Reference in new issue
Block a user