mailparser
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -12,3 +12,2 @@ 'use strict'; | ||
const iconv = require('iconv-lite'); | ||
const marked = require('marked'); | ||
const htmlToText = require('html-to-text'); | ||
@@ -506,9 +505,3 @@ const he = require('he'); | ||
if (!alternative && this.hasHtml) { | ||
html.push(marked(node.textContent, { | ||
breaks: true, | ||
sanitize: true, | ||
gfm: true, | ||
tables: true, | ||
smartypants: true | ||
})); | ||
html.push(textToHtml(node.textContent)); | ||
} | ||
@@ -538,9 +531,3 @@ } else if (node.contentType === 'text/html') { | ||
this.text = response.text = text.join('\n'); | ||
this.textAsHtml = response.textAsHtml = text.map(part => marked(part, { | ||
breaks: true, | ||
sanitize: true, | ||
gfm: true, | ||
tables: true, | ||
smartypants: true | ||
})).join('<br/>\n'); | ||
this.textAsHtml = response.textAsHtml = text.map(part => textToHtml(part)).join('<br/>\n'); | ||
} | ||
@@ -622,3 +609,3 @@ return response; | ||
} else if(node.disposition === 'inline') { | ||
} else if (node.disposition === 'inline') { | ||
let chunks = []; | ||
@@ -798,1 +785,18 @@ let chunklen = 0; | ||
module.exports = MailParser; | ||
function textToHtml(str) { | ||
let text = '<p>' + he. | ||
// encode special chars | ||
encode( | ||
str, { | ||
useNamedReferences: true | ||
}). | ||
replace(/\r?\n/g, '\n').trim(). // normalize line endings | ||
replace(/[ \t]+$/mg, '').trim(). // trim empty line endings | ||
replace(/\n\n+/g, '</p><p>').trim(). // insert <p> to multiple linebreaks | ||
replace(/\n/g, '<br/>') + // insert <br> to single linebreaks | ||
'</p>'; | ||
return text; | ||
} |
{ | ||
"name": "mailparser", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Parse e-mails", | ||
@@ -13,8 +13,7 @@ "main": "index.js", | ||
"addressparser": "1.0.1", | ||
"he": "1.1.1", | ||
"he": "^1.1.1", | ||
"html-to-text": "3.2.0", | ||
"iconv-lite": "0.4.15", | ||
"iconv-lite": "0.4.17", | ||
"libmime": "3.1.0", | ||
"mailsplit": "4.0.2", | ||
"marked": "0.3.6" | ||
"mailsplit": "4.0.2" | ||
}, | ||
@@ -21,0 +20,0 @@ "devDependencies": { |
47167
6
850
+ Addedhe@1.2.0(transitive)
+ Addediconv-lite@0.4.17(transitive)
- Removedmarked@0.3.6
- Removedhe@1.1.1(transitive)
- Removedmarked@0.3.6(transitive)
Updatedhe@^1.1.1
Updatediconv-lite@0.4.17