-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): Own parser html ti tree
- Loading branch information
Showing
13 changed files
with
253 additions
and
81 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
coverage | ||
build |
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
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,97 @@ | ||
/* jshint mocha: true, maxlen: false */ | ||
import posthtml from '../index.js'; | ||
import { expect } from 'chai'; | ||
|
||
function test(html, reference, done) { | ||
posthtml().process(html).then(result => { | ||
expect(reference).to.eql(result.html); | ||
done(); | ||
}).catch(error => done(error)); | ||
} | ||
|
||
describe('Parse classes', () => { | ||
it('block', done => { | ||
let html = '<div class="block1">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block_modname', done => { | ||
let html = '<div class="block1 block1_modname">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block_modname_modval', done => { | ||
let html = '<div class="block1 block1_modname_modval">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix blocks', done => { | ||
let html = '<div class="block1 block2">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1 block2_modname', done => { | ||
let html = '<div class="block1 block2 block2_modname">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1_modname block2_modname', done => { | ||
let html = '<div class="block1 block1_modname block2 block2_modname">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1 block2_modname_modval', done => { | ||
let html = '<div class="block1 block2 block2_modname_modval">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1_modval_modname block2_modname_modval', done => { | ||
let html = '<div class="block1 block1_modname_modval block2 block2_modname_modval">text</div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block__elem', done => { | ||
let html = '<div class="block1"><div class="block1__elem">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block__elem_modname', done => { | ||
let html = '<div class="block1"><div class="block1__elem block1__elem_modname">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block__elem_modname_modval', done => { | ||
let html = '<div class="block1"><div class="block1__elem block1__elem_modname_modval">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix elems', done => { | ||
let html = '<div class="block1 block2"><div class="block1__elem block2__elem">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1__elem block2__elem_modname', done => { | ||
let html = '<div class="block1 block2"><div class="block1__elem block2__elem block2__elem_modname">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1__elem_modname block2__elem_modname', done => { | ||
let html = '<div class="block1 block2"><div class="block1__elem block1__elem_modval block2__elem block2__elem_modname">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1__elem block2__elem_modname_modval', done => { | ||
let html = '<div class="block1 block2"><div class="block1__elem block2__elem block2__elem_modname_modval">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('mix block1__elem_modname_modval block2__elem_modname_modval', done => { | ||
let html = '<div class="block1 block2"><div class="block1__elem block1__elem_modname_modval block2__elem block2__elem_modname_modval">text</div></div>'; | ||
test(html, html, done); | ||
}); | ||
|
||
it('block1__elem__elem', done => { | ||
let html = '<div class="block1__elem__elem">text</div>'; | ||
test(html, html, done); | ||
}); | ||
}); |
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,19 @@ | ||
/* jshint mocha: true, maxlen: false */ | ||
import posthtml from '../index.js'; | ||
import { expect } from 'chai'; | ||
import { minifer, file } from '../util/test.js'; | ||
|
||
const comments = minifer(file('templates/comments.html')); | ||
|
||
function test(html, reference, done) { | ||
posthtml().process(html).then(result => { | ||
expect(reference).to.eql(result.html); | ||
done(); | ||
}).catch(error => done(error)); | ||
} | ||
|
||
describe('Parse comments', () => { | ||
it('comments eqval', done => { | ||
test(comments, comments, done); | ||
}); | ||
}); |
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,26 @@ | ||
/* jshint mocha: true, maxlen: false */ | ||
import posthtml from '../index.js'; | ||
import { expect } from 'chai'; | ||
import { minifer, file } from '../util/test.js'; | ||
|
||
const doctype = minifer(file('templates/doctype.html')); | ||
const html = minifer(file('templates/html.html')); | ||
|
||
function test(html, reference, done) { | ||
posthtml().process(html).then(result => { | ||
expect(reference).to.eql(result.html); | ||
done(); | ||
}).catch(error => done(error)); | ||
} | ||
|
||
describe('Parse Doctype', () => { | ||
|
||
it('doctype eqval', done => { | ||
test(doctype, doctype, done); | ||
}); | ||
|
||
it('empty doctype', done => { | ||
test(html, html, done); | ||
}); | ||
|
||
}); |
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,11 @@ | ||
<html> | ||
<head> | ||
<title>Comments</title> | ||
<!-- Comments 1 --> | ||
</head> | ||
<body> | ||
<!-- Comments 2 --> | ||
<p>Lorem ipsum dolor sit amet...</p> | ||
</body> | ||
</html> | ||
<!-- Comments last --> |
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,9 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | ||
<html> | ||
<head> | ||
<title>Doctype</title> | ||
</head> | ||
<body> | ||
<p>Lorem ipsum dolor sit amet...</p> | ||
</body> | ||
</html> |
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,8 @@ | ||
<html> | ||
<head> | ||
<title>Html</title> | ||
</head> | ||
<body> | ||
<p>Lorem ipsum dolor sit amet...</p> | ||
</body> | ||
</html> |
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,18 @@ | ||
/* jshint mocha: true, maxlen: false */ | ||
import posthtml from '../index.js'; | ||
import { expect } from 'chai'; | ||
|
||
const text = 'text'; | ||
|
||
function test(html, reference, done) { | ||
posthtml().process(html).then(result => { | ||
expect(reference).to.eql(result.html); | ||
done(); | ||
}).catch(error => done(error)); | ||
} | ||
|
||
describe('Parse text', () => { | ||
it('Text eqval', done => { | ||
test(text, text, done); | ||
}); | ||
}); |
Oops, something went wrong.