mirror of
https://github.com/danbulant/node-html-parser
synced 2026-05-19 04:18:52 +00:00
Merge pull request #10 from gauntface/picture-element
Adding LICENSE and support for picture element
This commit is contained in:
commit
3618d68f01
4 changed files with 1194 additions and 2222 deletions
7
LICENSE
Normal file
7
LICENSE
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2019 Tao Qiufeng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
3394
package-lock.json
generated
3394
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -702,7 +702,8 @@ const kSelfClosingElements = {
|
|||
img: true,
|
||||
input: true,
|
||||
link: true,
|
||||
meta: true
|
||||
meta: true,
|
||||
source: true
|
||||
};
|
||||
const kElementsClosedByOpening = {
|
||||
li: { li: true },
|
||||
|
|
|
|||
12
test/html.js
12
test/html.js
|
|
@ -97,6 +97,18 @@ describe('HTML Parser', function () {
|
|||
|
||||
});
|
||||
|
||||
it('should parse picture element', function () {
|
||||
|
||||
var root = parseHTML('<picture><source srcset="/images/example-1.jpg 1200w, /images/example-2.jpg 1600w" sizes="100vw"><img src="/images/example.jpg" alt="Example"/></picture>');
|
||||
|
||||
var picture = new HTMLElement('picture', {}, '');
|
||||
var source = picture.appendChild(new HTMLElement('source', {}, 'srcset="/images/example-1.jpg 1200w, /images/example-2.jpg 1600w" sizes="100vw"'));
|
||||
var img = picture.appendChild(new HTMLElement('img', {}, 'src="/images/example.jpg" alt="Example"'));
|
||||
|
||||
root.firstChild.should.eql(picture);
|
||||
|
||||
});
|
||||
|
||||
it('should not extract text in script and style by default', function () {
|
||||
|
||||
var root = parseHTML('<script>1</script><style>2</style>');
|
||||
|
|
|
|||
Loading…
Reference in a new issue