diff --git a/src/index.ts b/src/index.ts index 103d692..a8cee1c 100755 --- a/src/index.ts +++ b/src/index.ts @@ -113,7 +113,13 @@ export function parse(data: string, options = {} as Options) { if (kBlockTextElements[match[2]]) { // a little test to find next or ... const closeMarkup = ''; - const index = data.indexOf(closeMarkup, kMarkupPattern.lastIndex); + const index = (() => { + if (options.lowerCaseTagName) { + return data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex); + } else { + return data.indexOf(closeMarkup, kMarkupPattern.lastIndex); + } + })(); if (options[match[2]]) { let text: string; if (index === -1) { diff --git a/test/html.js b/test/html.js index 0ea581d..054d7cf 100644 --- a/test/html.js +++ b/test/html.js @@ -83,6 +83,18 @@ describe('HTML Parser', function () { }); + it('should deal uppercase', function () { + const html = 'SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'; + + var root = parseHTML(html, { + lowerCaseTagName: true + }); + + root.toString().should.eql('SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'); + // root.toString().firstChild.should.eql(div); + + }); + it('should parse "

" and return root element', function () { var root = parseHTML('

');