Skip to content

Commit 923b16a

Browse files
authored
Merge pull request #19 from posthtml/milestone-0.3.1
Milestone 0.3.1
2 parents ee1f515 + dd11797 commit 923b16a

4 files changed

Lines changed: 2593 additions & 4 deletions

File tree

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var htmlparser = require('htmlparser2');
44
var isObject = require('isobject');
5+
var objectAssign = require('object-assign');
56

67
/**
78
* @see https://github.com/fb55/htmlparser2/wiki/Parser-options
@@ -44,6 +45,17 @@ function postHTMLParser(html, options) {
4445
}
4546
}
4647

48+
function normalizeArributes(attrs) {
49+
var result = {};
50+
Object.keys(attrs).forEach(function(key) {
51+
var obj = {};
52+
obj[key] = attrs[key].replace(/"/g, '"');
53+
objectAssign(result, obj);
54+
});
55+
56+
return result;
57+
}
58+
4759
var parser = new htmlparser.Parser({
4860
onprocessinginstruction: parserDirective,
4961
oncomment: function(data) {
@@ -62,7 +74,7 @@ function postHTMLParser(html, options) {
6274
var buf = { tag: tag };
6375

6476
if (Object.keys(attrs).length) {
65-
buf.attrs = attrs;
77+
buf.attrs = normalizeArributes(attrs);
6678
}
6779

6880
bufArray.push(buf);

0 commit comments

Comments
 (0)