Skip to content

Commit

Permalink
bump ecmarkdown and format valueless attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Apr 7, 2023
1 parent 2054ff8 commit 91cc4e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 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 @@ -49,7 +49,7 @@
"command-line-args": "^5.2.0",
"command-line-usage": "^6.1.1",
"dedent-js": "^1.0.1",
"ecmarkdown": "^8.0.0",
"ecmarkdown": "^8.1.0",
"eslint-formatter-codeframe": "^7.32.1",
"fast-glob": "^3.2.7",
"grammarkdown": "^3.2.0",
Expand Down
4 changes: 3 additions & 1 deletion src/formatter/ecmarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ async function printStep(
output.firstLineIsPartial = false;
output.appendText(item.name === 'ordered-list-item' ? '1. ' : '* ');
if (item.attrs.length > 0) {
const joined = item.attrs.map(({ key, value }) => `${key}=${JSON.stringify(value)}`).join(', ');
const joined = item.attrs
.map(({ key, value }) => (value === '' ? key : `${key}=${JSON.stringify(value)}`))
.join(', ');
output.appendText(`[${joined}] `);
}
const contents = await printFragments(source, item.contents, indent + 1);
Expand Down
4 changes: 2 additions & 2 deletions test/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ describe('algorithm formatting', () => {
1. Step.
1. Another step.
1. A substep.
1. [ x = "a",y="b" ] A step with attributes.
1. [ x = "a",y="b" ,c="",d ] A step with attributes.
1. A step with _vars_, numbers like **10<sup>x</sup>**, records like { [[A]]: 0 }, and fields like _o_.[[field]].
</emu-alg>
`,
Expand All @@ -482,7 +482,7 @@ describe('algorithm formatting', () => {
1. Step.
1. Another step.
1. A substep.
1. [x="a", y="b"] A step with attributes.
1. [x="a", y="b", c, d] A step with attributes.
1. A step with _vars_, numbers like **10<sup>x</sup>**, records like { [[A]]: 0 }, and fields like _o_.[[field]].
</emu-alg>
`
Expand Down

0 comments on commit 91cc4e5

Please sign in to comment.