mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-14 18:42:24 +03:00
add eslint, travis config, test tasks
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package-lock.json
|
||||
coverage
|
||||
dist
|
||||
@@ -0,0 +1,5 @@
|
||||
package-lock.json
|
||||
coverage
|
||||
src
|
||||
dist
|
||||
!lib
|
||||
@@ -0,0 +1,2 @@
|
||||
# bbob-render
|
||||
Converts bbob-parser AST tree to html
|
||||
@@ -0,0 +1,35 @@
|
||||
function render(tree, options) {
|
||||
|
||||
}
|
||||
|
||||
function attrs(obj) {
|
||||
let attr = '';
|
||||
|
||||
Object.keys(obj).forEach((key) => {
|
||||
if (typeof obj[key] === 'boolean' && obj[key]) {
|
||||
attr += ` ${key}`;
|
||||
} else if (typeof obj[key] === 'number') {
|
||||
attr += ` ${key}="${obj[key]}"`;
|
||||
} else if (typeof obj[key] === 'string') {
|
||||
attr += ` ${key}="${obj[key].replace(/"/g, '"')}"`;
|
||||
}
|
||||
});
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
function traverse(tree, cb) {
|
||||
if (Array.isArray(tree)) {
|
||||
let i = 0,
|
||||
length = tree.length;
|
||||
for (; i < length; i++) {
|
||||
traverse(cb(tree[i]), cb);
|
||||
}
|
||||
} else if (typeof tree === 'object' && tree.hasOwnProperty('content')) {
|
||||
traverse(tree.content, cb);
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
module.exports = render;
|
||||
Reference in New Issue
Block a user