lezer-beancount 1.0.0 → 1.1.0

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/dist/index.cjs CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  var lr = require('@lezer/lr');
4
4
  var highlight = require('@lezer/highlight');
5
-
6
- /* Syntax highlighting for Beancount */
7
-
5
+ var language = require('@codemirror/language');
8
6
 
9
7
  const beancountHighlighting = highlight.styleTags({
10
8
  // Comments
@@ -52,12 +50,30 @@ const beancountHighlighting = highlight.styleTags({
52
50
  ":": highlight.tags.punctuation,
53
51
  "@ @@": highlight.tags.operator,
54
52
 
55
- // Org-mode headers
56
53
  OrgHeader: highlight.tags.heading,
57
54
  OrgMarker: highlight.tags.heading,
55
+ });
56
+
57
+ const beancountFolding = language.foldNodeProp.add({
58
+ PostingBlock: language.foldInside,
59
+ MetadataBlock: language.foldInside,
60
+ });
58
61
 
59
- // Indent (for structure)
60
- Indent: highlight.tags.indent,
62
+ const beancountIndentation = language.indentNodeProp.add({
63
+ Transaction: context => context.baseIndent + context.unit,
64
+ PostingBlock: context => context.baseIndent + context.unit,
65
+ MetadataBlock: context => context.baseIndent + context.unit,
66
+ Open: context => context.baseIndent + context.unit,
67
+ Close: context => context.baseIndent + context.unit,
68
+ Balance: context => context.baseIndent + context.unit,
69
+ Pad: context => context.baseIndent + context.unit,
70
+ Note: context => context.baseIndent + context.unit,
71
+ Document: context => context.baseIndent + context.unit,
72
+ Event: context => context.baseIndent + context.unit,
73
+ Price: context => context.baseIndent + context.unit,
74
+ Commodity: context => context.baseIndent + context.unit,
75
+ Query: context => context.baseIndent + context.unit,
76
+ Custom: context => context.baseIndent + context.unit,
61
77
  });
62
78
 
63
79
  // This file was generated by lezer-generator. You probably shouldn't edit it.
@@ -72,7 +88,7 @@ const parser = lr.LRParser.deserialize({
72
88
  nodeProps: [
73
89
  ["isolate", -3,1,8,75,""]
74
90
  ],
75
- propSources: [beancountHighlighting],
91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m:`#m#o9f~:eU#R~}!O9f!Q![9f#R#S9f#T#b9f#b#c:w#c#o9f~;OSU~#R~}!O9f!Q![9f#R#S9f#T#o9f~;aPf~#o#p;d~;iOl~~;nPk~#q#r;q~;vOm~~;{O!O~",
@@ -0,0 +1,3 @@
1
+ import {LRParser} from "@lezer/lr"
2
+
3
+ export const parser: LRParser
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { LRParser } from '@lezer/lr';
2
2
  import { styleTags, tags } from '@lezer/highlight';
3
-
4
- /* Syntax highlighting for Beancount */
5
-
3
+ import { foldNodeProp, foldInside, indentNodeProp } from '@codemirror/language';
6
4
 
7
5
  const beancountHighlighting = styleTags({
8
6
  // Comments
@@ -50,12 +48,30 @@ const beancountHighlighting = styleTags({
50
48
  ":": tags.punctuation,
51
49
  "@ @@": tags.operator,
52
50
 
53
- // Org-mode headers
54
51
  OrgHeader: tags.heading,
55
52
  OrgMarker: tags.heading,
53
+ });
54
+
55
+ const beancountFolding = foldNodeProp.add({
56
+ PostingBlock: foldInside,
57
+ MetadataBlock: foldInside,
58
+ });
56
59
 
57
- // Indent (for structure)
58
- Indent: tags.indent,
60
+ const beancountIndentation = indentNodeProp.add({
61
+ Transaction: context => context.baseIndent + context.unit,
62
+ PostingBlock: context => context.baseIndent + context.unit,
63
+ MetadataBlock: context => context.baseIndent + context.unit,
64
+ Open: context => context.baseIndent + context.unit,
65
+ Close: context => context.baseIndent + context.unit,
66
+ Balance: context => context.baseIndent + context.unit,
67
+ Pad: context => context.baseIndent + context.unit,
68
+ Note: context => context.baseIndent + context.unit,
69
+ Document: context => context.baseIndent + context.unit,
70
+ Event: context => context.baseIndent + context.unit,
71
+ Price: context => context.baseIndent + context.unit,
72
+ Commodity: context => context.baseIndent + context.unit,
73
+ Query: context => context.baseIndent + context.unit,
74
+ Custom: context => context.baseIndent + context.unit,
59
75
  });
60
76
 
61
77
  // This file was generated by lezer-generator. You probably shouldn't edit it.
@@ -70,7 +86,7 @@ const parser = LRParser.deserialize({
70
86
  nodeProps: [
71
87
  ["isolate", -3,1,8,75,""]
72
88
  ],
73
- propSources: [beancountHighlighting],
89
+ propSources: [beancountHighlighting,beancountFolding,beancountIndentation],
74
90
  skippedNodes: [0,1],
75
91
  repeatNodeCount: 7,
76
92
  tokenData: ";{~RtXY#cYZ#n]^#npq#cqr$[rs$ast&|xy'pyz'uz{'z{|)R|})W}!O)]!P!Q)R!Q![*R![!],T!]!^,Y!b!c,q!c!d-O!d!g/b!g!h/{!h!i1t!i!k/b!k!l4v!l!n/b!n!o5|!o!v/b!v!w7f!w!}/b#Q#R8t#T#h9f#h#i9w#i#o9f#o#p;[#q#r;i#r#s;v~#hQ!w~XY#cpq#c~#sS!x~XY$PYZ#n]^#npq$P~$UQ]~XY$Ppq$PQ$aOVQ~$dWpq$aqr$ars$|s#O$a#O#P%R#P;'S$a;'S;=`&v<%lO$a~%ROW~~%UYYZ$ars$a!P!Q$a#O#P$a#U#V$a#Y#Z$a#b#c$a#f#g$a#h#i$a#i#j%t~%wR!Q![&Q!c!i&Q#T#Z&Q~&TR!Q![&^!c!i&^#T#Z&^~&aR!Q![&j!c!i&j#T#Z&j~&mR!Q![$a!c!i$a#T#Z$a~&yP;=`<%l$aX'RR#QW!Q!['[!c!}'[#T#o'[P'aTXP}!O'[!Q!['[!c!}'[#R#S'[#T#o'[~'uOa~~'zOb~_(TRcSiWVQXY(^pq(^z{(uP(cS!mPOY(^Z;'S(^;'S;=`(o<%lO(^P(rP;=`<%l(^P(xRXY(^pq(^z{(uS)WOcS~)]Oj~])bPcS!Q![)eX)jR`X|})e!O!P)s!Q![)eX)vP!Q![)yX*OP`X!Q![)y~*WR`X|})e!O!P)s!Q![*a~*fR`X|})e!O!P)s!Q![*o~*tR`X|})e!O!P)s!Q![*}~+SS`X|})e}!O+`!O!P)s!Q![)e~+cP!Q![+f~+iP!Q![+l~+oP}!O+r~+uP!Q![+x~+{P!Q![,O~,TOS~~,YOt~~,_SP~OY,YZ;'S,Y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S9Q#T#o9Q~9kS#R~}!O9f!Q![9f#R#S9f#T#o9f~9|U#R~}!O9f!Q![9f#R#S9f#T#l9f#l#m:`#m#o9f~:eU#R~}!O9f!Q![9f#R#S9f#T#b9f#b#c:w#c#o9f~;OSU~#R~}!O9f!Q![9f#R#S9f#T#o9f~;aPf~#o#p;d~;iOl~~;nPk~#q#r;q~;vOm~~;{O!O~",
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "lezer-beancount",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "lezer-based Beancount grammar",
5
5
  "license": "MIT",
6
6
  "author": "Robin van der Vleuten <robin@webstronauts.com>",
7
7
  "type": "module",
8
8
  "main": "dist/index.cjs",
9
9
  "module": "dist/index.js",
10
+ "types": "dist/index.d.ts",
10
11
  "exports": {
12
+ "types": "./dist/index.d.ts",
11
13
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
14
+ "require": "./dist/index.cjs",
15
+ "default": "./dist/index.js"
13
16
  },
14
17
  "scripts": {
15
18
  "build": "lezer-generator src/beancount.grammar -o src/parser && rollup -c",
16
19
  "test": "uvu test"
17
20
  },
18
21
  "devDependencies": {
22
+ "@codemirror/language": "^6.10.0",
19
23
  "@lezer/generator": "^1.8.0",
20
24
  "@lezer/highlight": "^1.2.0",
21
25
  "@lezer/lr": "^1.4.0",
@@ -24,6 +28,7 @@
24
28
  "uvu": "^0.5.6"
25
29
  },
26
30
  "peerDependencies": {
31
+ "@codemirror/language": "^6.0.0",
27
32
  "@lezer/highlight": "^1.0.0",
28
33
  "@lezer/lr": "^1.0.0"
29
34
  },