Skip to content

Commit 71ca17c

Browse files
authored
Merge pull request #27 from bit-docs/skiped-items
Allow ignoring elements
2 parents d75642e + 52efcf1 commit 71ca17c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

make-tree.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ function makeTreeData(elements) {
6161
var ids = {};
6262
var map = [].map;
6363

64+
// Get elements without [data-skip] attribute only
65+
elements = elements.filter(function(element) {
66+
// check if element has attributes (for testing)
67+
if (element.attributes) {
68+
return !element.attributes['data-skip'];
69+
}
70+
return true;
71+
});
72+
6473
return map.call(elements, function(element) {
6574
var text = element.textContent;
6675
var id = element.id || makeHeadingId(text);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"jshint": "^2.9.4",
3939
"steal": "^0.16.41",
4040
"steal-mocha": "0.0.3",
41-
"testee": "^0.3.0-pre.2"
41+
"testee": "^0.9.1"
4242
}
4343
}

test/make-tree-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,16 @@ describe("makeTree", function() {
5656
{ id: "writing-modules", level: 2, text: "Writing Modules", children: [] }
5757
]);
5858
});
59+
60+
it("allows ignoring elements with data-skip attribute", function() {
61+
var elements = [
62+
{ tagName: "h2", textContent: "new MyType", attributes: {} },
63+
{ tagName: "h3", textContent: "Parameters", attributes: { 'data-skip': {} } },
64+
{ tagName: "h2", textContent: "Configure", attributes: {} }
65+
];
66+
assert.deepEqual(makeTree(elements), [
67+
{id: "new-mytype", level: 2, text: "new MyType", children: []},
68+
{ id: "configure", level: 2, text: "Configure", children: [] }
69+
]);
70+
});
5971
});

0 commit comments

Comments
 (0)