@@ -34,6 +34,7 @@ const formatterOptions = {
3434 indent_empty_lines : false
3535} ;
3636
37+
3738/**
3839 * Extract target attributes
3940 *
@@ -86,13 +87,13 @@ const getStyleContents = function (styleElements) {
8687} ;
8788
8889/**
89- * Parse given HTML content as JSON
90+ * Filter given HTML content as JSON
9091 *
9192 * @param {string } htmlJson
9293 *
9394 * @returns Object
9495 */
95- const parseHtmlJson = function ( htmlJson ) {
96+ const filterHtmlData = function ( htmlJson ) {
9697 if ( htmlJson && Array . isArray ( htmlJson ) ) {
9798 var _data = htmlJson . filter ( ( x ) => x . type == 'element' && x . tagName != 'style' ) ,
9899 styleElements = htmlJson . filter ( ( x ) => x . tagName == 'style' ) ,
@@ -104,7 +105,7 @@ const parseHtmlJson = function (htmlJson) {
104105
105106 var elementList = _data . map ( ( node ) => {
106107 if ( Array . isArray ( node . children ) ) {
107- let children = parseHtmlJson ( node . children ) ;
108+ let children = filterHtmlData ( node . children ) ;
108109
109110 // find text nodes and merge
110111 node . text = children . filter ( ( x ) => x . type == 'text' ) . map ( ( x ) => {
@@ -199,6 +200,7 @@ const getSassTree = function (nodeTree, count = 0) {
199200 return '' ;
200201} ;
201202
203+
202204module . exports = {
203205 /**
204206 * Convert HMTL to SASS generic method
@@ -211,7 +213,8 @@ module.exports = {
211213 convertToSass : function ( html , options = defaultOptions ) {
212214 if ( html && html . length ) {
213215 const htmlJson = parse . parse ( utils . cleanText ( html ) ) ,
214- sassTreeResult = getSassTree ( parseHtmlJson ( htmlJson ) ) ;
216+ filteredHtmlData = filterHtmlData ( htmlJson ) ,
217+ sassTreeResult = getSassTree ( filteredHtmlData ) ;
215218
216219 if ( options && options . formatOutput === true ) {
217220 var _formatterOptions = { } ;
0 commit comments