forked from tc39/ecmarkup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect and warn when duplicate ids exist and --verbose flag is present.
Fixes tc39gh-138
- Loading branch information
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<pre class=metadata> | ||
toc: false | ||
copyright: false | ||
assets: none | ||
</pre> | ||
<emu-clause id="sec-a"> | ||
<h1>A</h1> | ||
<emu-clause id="sec-a"> | ||
<h1>Sub A</h1> | ||
|
||
<emu-example id="an-example" caption="An example"> | ||
Multiple examples are numbered similar to notes | ||
</emu-example> | ||
</emu-clause> | ||
</emu-clause> | ||
<emu-clause id="sec-a"> | ||
<h1>Section A: Extras</h1> | ||
<emu-table id="table-of-stuff" caption="A Table Of Stuff" informative> | ||
<table> | ||
<tr><th>Column 1</th><th>Column 2</th></tr> | ||
<tr><td>Value</td><td>Value 2</td></tr> | ||
</table> | ||
</emu-table> | ||
</emu-clause> | ||
<emu-clause id="sec-a"> | ||
<h1>Section A: Extras</h1> | ||
<emu-table id="table-of-stuff" caption="A Table Of Stuff" informative> | ||
<table> | ||
<tr><th>Column 1</th><th>Column 2</th></tr> | ||
<tr><td>Value</td><td>Value 2</td></tr> | ||
</table> | ||
</emu-table> | ||
<emu-example id="an-example" caption="An example"> | ||
Multiple examples are numbered similar to notes | ||
</emu-example> | ||
</emu-clause> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<head><meta charset="utf-8"></head><body><div id="spec-container"> | ||
<emu-clause id="sec-a"> | ||
<h1 class="first"><span class="secnum">1</span>A</h1> | ||
<emu-clause id="sec-a"> | ||
<h1><span class="secnum">1.1</span>Sub A</h1> | ||
|
||
<emu-example id="an-example" caption="An example"><figure><figcaption>Example (Informative): An example</figcaption> | ||
Multiple examples are numbered similar to notes | ||
|
||
</figure></emu-example> | ||
</emu-clause> | ||
</emu-clause> | ||
<emu-clause id="sec-a"> | ||
<h1><span class="secnum">2</span>Section A: Extras</h1> | ||
<emu-table id="table-of-stuff" caption="A Table Of Stuff" informative=""><figure><figcaption>Table 1 (Informative): A Table Of Stuff</figcaption> | ||
<table> | ||
<tbody><tr><th>Column 1</th><th>Column 2</th></tr> | ||
<tr><td>Value</td><td>Value 2</td></tr> | ||
</tbody></table> | ||
</figure></emu-table> | ||
</emu-clause> | ||
<emu-clause id="sec-a"> | ||
<h1><span class="secnum">3</span>Section A: Extras</h1> | ||
<emu-table id="table-of-stuff" caption="A Table Of Stuff" informative=""><figure><figcaption>Table 2 (Informative): A Table Of Stuff</figcaption> | ||
<table> | ||
<tbody><tr><th>Column 1</th><th>Column 2</th></tr> | ||
<tr><td>Value</td><td>Value 2</td></tr> | ||
</tbody></table> | ||
</figure></emu-table> | ||
<emu-example id="an-example" caption="An example"><figure><figcaption>Example (Informative): An example</figcaption> | ||
Multiple examples are numbered similar to notes | ||
|
||
</figure></emu-example> | ||
</emu-clause> | ||
</div></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
const cp = require('child_process'); | ||
const assert = require('assert'); | ||
|
||
describe('detecting duplicate ids', () => { | ||
it('reports when --verbose flag is present', (done) => { | ||
cp.exec('./bin/ecmarkup.js --verbose test/duplicate-ids.html', (error, result) => { | ||
if (error) { | ||
assert.fail(error); | ||
done(); | ||
return; | ||
} | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), true); | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), true); | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), true); | ||
assert.equal(result.includes('<emu-table> has duplicate id: table-of-stuff'), true); | ||
assert.equal(result.includes('<emu-example> has duplicate id: an-example'), true); | ||
done(); | ||
}); | ||
}); | ||
it('does not report when --verbose flag is not present', (done) => { | ||
cp.exec('./bin/ecmarkup.js test/duplicate-ids.html', (error, result) => { | ||
if (error) { | ||
assert.fail(error); | ||
done(); | ||
return; | ||
} | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), false); | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), false); | ||
assert.equal(result.includes('<emu-clause> has duplicate id: sec-a'), false); | ||
assert.equal(result.includes('<emu-table> has duplicate id: table-of-stuff'), false); | ||
assert.equal(result.includes('<emu-example> has duplicate id: an-example'), false); | ||
done(); | ||
}); | ||
}); | ||
}); |