diff --git a/src/docsSoap.js b/src/docsSoap.js index 0ebf999..ab00519 100644 --- a/src/docsSoap.js +++ b/src/docsSoap.js @@ -106,6 +106,8 @@ const getCleanNode = ( } else if (node.nodeName === 'P') { newWrapper = document.createElement('p'); newNode = applyBlockStyles(node); + } else if (node.nodeName === 'BR') { + newNode = node; } else { newWrapper = document.createElement('span'); newNode = applyInlineStyles(node); diff --git a/test/docsSoapSpec.js b/test/docsSoapSpec.js index 9a2ce3a..1479aab 100644 --- a/test/docsSoapSpec.js +++ b/test/docsSoapSpec.js @@ -106,4 +106,9 @@ describe('Google Docs Converter', () => { expect(doc.querySelectorAll('h3').length).toBe(1); expect(doc.querySelectorAll('h4').length).toBe(1); }); + + it('converts brs properly', () => { + const doc = parseHTML(docsSoap(documents.brs)); + expect(doc.querySelectorAll('br').length).toBe(2); + }); }); diff --git a/test/fixtures/documents.json b/test/fixtures/documents.json index 5328ae9..38b0ec3 100644 --- a/test/fixtures/documents.json +++ b/test/fixtures/documents.json @@ -3,5 +3,6 @@ "inlineStyles": "

Some bold text

Some italicized text

Some underlined text

Some strikethrough text

Some superscript

Some subscript
", "links": "

this is a link

this is a bold link

this is an italicized link

this is a bold, italicized link
", "nestedList": "
  1. Abcd
    1234

    1. In abcd

      1. Some text in italics and underline plus random stuff after

  2. xyz

    1. In xyz

      1. Last of all


Asdfasdf

2. End






  1. Asdfasdfasdf

    1. Asdfasdfasdfasdf

  2. Asdfasdfasdf

    1. asdfasdfasdfasf

Asdfasdf

2. end

  1. end

  2. asdfasdf

  3. s

  4. dfa

  5. sdf

  6. eight

  7. ten


", - "headers": "

This is an H1

This is an H2

This is an H3

This is an H4

" + "headers": "

This is an H1

This is an H2

This is an H3

This is an H4

", + "brs": "

" }