Skip to content

Commit 658201e

Browse files
authored
Xml support using html parser (#592)
1 parent 6c63c21 commit 658201e

19 files changed

+446
-0
lines changed

src/languages/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const supportedLanguageIds = [
1616
"scala",
1717
"typescript",
1818
"typescriptreact",
19+
"xml",
1920
] as const;
2021

2122
export type SupportedLanguageId = typeof supportedLanguageIds[number];

src/languages/getNodeMatcher.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const languageMatchers: Record<
6767
scala,
6868
typescript,
6969
typescriptreact: typescript,
70+
xml: html,
7071
};
7172

7273
function matcherIncludeSiblings(matcher: NodeMatcher): NodeMatcher {

src/languages/getTextFragmentExtractor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,8 @@ const textFragmentExtractors: Record<
173173
"typescriptreact",
174174
typescriptStringTextFragmentExtractor
175175
),
176+
xml: constructDefaultTextFragmentExtractor(
177+
"xml",
178+
htmlStringTextFragmentExtractor
179+
),
176180
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear at her then
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: attribute, includeSiblings: false}
9+
initialState:
10+
documentContents: <note bar="back">foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 14}
13+
active: {line: 0, character: 14}
14+
marks: {}
15+
finalState:
16+
documentContents: <note >foo</note>
17+
selections:
18+
- anchor: {line: 0, character: 6}
19+
active: {line: 0, character: 6}
20+
thatMark:
21+
- anchor: {line: 0, character: 6}
22+
active: {line: 0, character: 6}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: attribute, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear core
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: surroundingPair, delimiter: any, delimiterInclusion: interiorOnly}
9+
initialState:
10+
documentContents: <note>foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 13}
13+
active: {line: 0, character: 13}
14+
marks: {}
15+
finalState:
16+
documentContents: <note>foo</>
17+
selections:
18+
- anchor: {line: 0, character: 11}
19+
active: {line: 0, character: 11}
20+
thatMark:
21+
- anchor: {line: 0, character: 11}
22+
active: {line: 0, character: 11}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: surroundingPair, delimiter: any, delimiterInclusion: interiorOnly}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear core
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: surroundingPair, delimiter: any, delimiterInclusion: interiorOnly}
9+
initialState:
10+
documentContents: <note>foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 3}
13+
active: {line: 0, character: 3}
14+
marks: {}
15+
finalState:
16+
documentContents: <>foo</note>
17+
selections:
18+
- anchor: {line: 0, character: 1}
19+
active: {line: 0, character: 1}
20+
thatMark:
21+
- anchor: {line: 0, character: 1}
22+
active: {line: 0, character: 1}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: surroundingPair, delimiter: any, delimiterInclusion: interiorOnly}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear eli
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: xmlElement, includeSiblings: false}
9+
initialState:
10+
documentContents: <note>foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 8}
13+
active: {line: 0, character: 8}
14+
marks: {}
15+
finalState:
16+
documentContents: ""
17+
selections:
18+
- anchor: {line: 0, character: 0}
19+
active: {line: 0, character: 0}
20+
thatMark:
21+
- anchor: {line: 0, character: 0}
22+
active: {line: 0, character: 0}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: xmlElement, includeSiblings: false}, isImplicit: false}]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear end tag
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: xmlEndTag, includeSiblings: false}
9+
initialState:
10+
documentContents: <note>foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 8}
13+
active: {line: 0, character: 8}
14+
marks: {}
15+
finalState:
16+
documentContents: <note>foo
17+
selections:
18+
- anchor: {line: 0, character: 9}
19+
active: {line: 0, character: 9}
20+
thatMark:
21+
- anchor: {line: 0, character: 9}
22+
active: {line: 0, character: 9}
23+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: xmlEndTag, includeSiblings: false}, isImplicit: false}]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear every at her
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: attribute, includeSiblings: true}
9+
initialState:
10+
documentContents: <note bar="back" bongo="badman">foo</note>
11+
selections:
12+
- anchor: {line: 0, character: 26}
13+
active: {line: 0, character: 26}
14+
marks: {}
15+
finalState:
16+
documentContents: <note >foo</note>
17+
selections:
18+
- anchor: {line: 0, character: 6}
19+
active: {line: 0, character: 6}
20+
- anchor: {line: 0, character: 7}
21+
active: {line: 0, character: 7}
22+
thatMark:
23+
- anchor: {line: 0, character: 6}
24+
active: {line: 0, character: 6}
25+
- anchor: {line: 0, character: 7}
26+
active: {line: 0, character: 7}
27+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: attribute, includeSiblings: true}, isImplicit: false}]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
languageId: xml
2+
command:
3+
version: 1
4+
spokenForm: clear every eli
5+
action: clearAndSetSelection
6+
targets:
7+
- type: primitive
8+
modifier: {type: containingScope, scopeType: xmlElement, includeSiblings: true}
9+
initialState:
10+
documentContents: |-
11+
<note>
12+
<to>Tove</to>
13+
<from>Jani</from>
14+
<heading>Reminder</heading>
15+
<body>Don't forget me this weekend!</body>
16+
</note>
17+
selections:
18+
- anchor: {line: 1, character: 10}
19+
active: {line: 1, character: 10}
20+
marks: {}
21+
finalState:
22+
documentContents: |-
23+
<note>
24+
25+
26+
27+
28+
</note>
29+
selections:
30+
- anchor: {line: 1, character: 4}
31+
active: {line: 1, character: 4}
32+
- anchor: {line: 2, character: 4}
33+
active: {line: 2, character: 4}
34+
- anchor: {line: 3, character: 4}
35+
active: {line: 3, character: 4}
36+
- anchor: {line: 4, character: 4}
37+
active: {line: 4, character: 4}
38+
thatMark:
39+
- anchor: {line: 1, character: 4}
40+
active: {line: 1, character: 4}
41+
- anchor: {line: 2, character: 4}
42+
active: {line: 2, character: 4}
43+
- anchor: {line: 3, character: 4}
44+
active: {line: 3, character: 4}
45+
- anchor: {line: 4, character: 4}
46+
active: {line: 4, character: 4}
47+
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: xmlElement, includeSiblings: true}, isImplicit: false}]

0 commit comments

Comments
 (0)