Skip to content

Commit

Permalink
Fix #547 quote snbt keys + respect indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Oct 4, 2024
1 parent 23ab957 commit 7757dbc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"deepslate-1.18": "npm:[email protected]",
"deepslate-1.18.2": "npm:[email protected]",
"deepslate-1.20.4": "npm:[email protected]",
"deepslate": "^0.22.2",
"deepslate": "^0.22.3",
"highlight.js": "^11.5.1",
"howler": "^2.2.3",
"js-yaml": "^3.14.1",
Expand Down
8 changes: 7 additions & 1 deletion src/app/services/Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const FORMATS: Record<string, {
},
snbt: {
parse: async (v) => NbtTag.fromString(v).toSimplifiedJson(),
stringify: (v, _i) => jsonToNbt(v).toPrettyString(),
stringify: (v, i) => {
const tag = jsonToNbt(v)
if (i === undefined) {
return tag.toString()
}
return tag.toPrettyString(typeof i === 'number' ? ' '.repeat(i) : i)
},
},
yaml: {
parse: async (v) => yaml.load(v),
Expand Down

0 comments on commit 7757dbc

Please sign in to comment.