Skip to content

Fix(node): fix priority of DecorationNode and String type nodes #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/block/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export const convertToNodes = combineNodeParsers(
CommandLineNodeParser,
FormulaNodeParser,
BlankNodeParser,
DecorationNodeParser,
StrongImageNodeParser,
StrongIconNodeParser,
StrongNodeParser,
DecorationNodeParser,
ImageNodeParser,
ExternalLinkNodeParser,
IconNodeParser,
Expand Down
137 changes: 128 additions & 9 deletions tests/line/__snapshots__/decoration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,26 @@ Array [
"indent": 0,
"nodes": Array [
Object {
"raw": "[! ",
"text": "[! ",
"type": "plain",
},
Object {
"decos": Array [
"!",
],
"nodes": Array [
Object {
"raw": "[[[[a",
"text": "[[[[a",
"raw": "[[[[[",
"text": "[[[[[",
"type": "plain",
},
Object {
"content": "",
"href": "a",
"pathType": "relative",
"raw": "[a]",
"type": "link",
},
],
"raw": "[[[[[[a]]",
"type": "strong",
"raw": "[! [[[[[[a]]",
"rawDecos": "!",
"type": "decoration",
},
],
"type": "line",
Expand Down Expand Up @@ -112,6 +118,119 @@ Array [
]
`;

exports[`decoration Decoration with strong icon notation (it's just icon, not strong): toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
"indent": 0,
"nodes": Array [
Object {
"decos": Array [
"*-1",
],
"nodes": Array [
Object {
"raw": "[",
"text": "[",
"type": "plain",
},
Object {
"content": "",
"href": "progfay.icon",
"pathType": "relative",
"raw": "[progfay.icon]",
"type": "link",
},
],
"raw": "[* [[progfay.icon]]",
"rawDecos": "*",
"type": "decoration",
},
Object {
"raw": "]",
"text": "]",
"type": "plain",
},
],
"type": "line",
},
]
`;

exports[`decoration Decoration with strong image notation (it's just image, not strong): toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
"indent": 0,
"nodes": Array [
Object {
"decos": Array [
"*-1",
],
"nodes": Array [
Object {
"raw": "[",
"text": "[",
"type": "plain",
},
Object {
"link": "",
"raw": "[https://example.com/image.png]",
"src": "https://example.com/image.png",
"type": "image",
},
],
"raw": "[* [[https://example.com/image.png]]",
"rawDecos": "*",
"type": "decoration",
},
Object {
"raw": "]",
"text": "]",
"type": "plain",
},
],
"type": "line",
},
]
`;

exports[`decoration Decoration with strong notation (it's just link): toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
"indent": 0,
"nodes": Array [
Object {
"decos": Array [
"*-1",
],
"nodes": Array [
Object {
"raw": "[",
"text": "[",
"type": "plain",
},
Object {
"content": "",
"href": "link",
"pathType": "relative",
"raw": "[link]",
"type": "link",
},
],
"raw": "[* [[link]]",
"rawDecos": "*",
"type": "decoration",
},
Object {
"raw": "]",
"text": "]",
"type": "plain",
},
],
"type": "line",
},
]
`;

exports[`decoration Simple decoration: toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
Expand Down
36 changes: 36 additions & 0 deletions tests/line/__snapshots__/strong.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,42 @@ Array [
]
`;

exports[`strong Decoration in Strong notation: toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
"indent": 0,
"nodes": Array [
Object {
"raw": "[[",
"text": "[[",
"type": "plain",
},
Object {
"decos": Array [
"!",
],
"nodes": Array [
Object {
"raw": "deco",
"text": "deco",
"type": "plain",
},
],
"raw": "[! deco]",
"rawDecos": "!",
"type": "decoration",
},
Object {
"raw": "]]",
"text": "]]",
"type": "plain",
},
],
"type": "line",
},
]
`;

exports[`strong Simple strong: toMatchSnapshotWhenParsing 1`] = `
Array [
Object {
Expand Down
12 changes: 12 additions & 0 deletions tests/line/decoration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@ describe('decoration', () => {
it('Decoration with many [ and link', () => {
expect('[! [[[[[[a]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})

it("Decoration with strong notation (it's just link)", () => {
expect('[* [[link]]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})

it("Decoration with strong icon notation (it's just icon, not strong)", () => {
expect('[* [[progfay.icon]]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})

it("Decoration with strong image notation (it's just image, not strong)", () => {
expect('[* [[https://example.com/image.png]]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})
})
4 changes: 4 additions & 0 deletions tests/line/strong.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ describe('strong', () => {
it('[[]] is not strong', () => {
expect('[[]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})

it('Decoration in Strong notation', () => {
expect('[[[! deco]]]').toMatchSnapshotWhenParsing({ hasTitle: false })
})
})