Skip to content

Experimental language parsing #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ Parser.prototype = {
}
delete uf.altValue;

value = domUtils.getAttribute(dom, node, 'lang');
if (value) {
uf.lang = value;
}

},


Expand Down Expand Up @@ -966,6 +971,11 @@ Parser.prototype = {
//out.html = domUtils.innerHTML(dom, node);
out.html = html.parse(dom, node);

var lang = domUtils.getAttribute(dom, node, 'lang');
if (lang) {
out.lang = lang;
}

return out;
},

Expand Down
20 changes: 20 additions & 0 deletions test/mf-v2-h-entry-lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Microformats Test Suite - Downloaded from github repo: glennjones/tests version v0.1.17
Mocha integration test from: microformats-v2/h-entry/justaname
The test was built on Sun Jun 14 2015 10:55:15 GMT+0100 (BST)
*/

var chai = require('chai'),
assert = chai.assert,
helper = require('../test/helper.js');


describe('h-entry', function() {
var htmlFragment = "<p class=\"h-entry\" lang=\"se\"><div class=\"e-content\" lang=\"en\">microformats.org at 7</div></p>";
var found = helper.parseHTML(htmlFragment,'http://example.com/');
var expected = {"items":[{"type":["h-entry"],"lang":"se","properties":{"content":[{"lang":"en","value":"microformats.org at 7","html":"microformats.org at 7"}],"name":["microformats.org at 7"]}}],"rels":{},"rel-urls":{}};

it('lang', function(){
assert.deepEqual(found, expected);
});
});