rtf-parser
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "rtf-parser", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "This is a general RTF parser. It takes a text stream and produces a document object representing the parsed document. In and of itself, this isn't super useful but it's the building block for other tools to convert RTF into other formats.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,6 +49,19 @@ 'use strict' | ||
if (node.content.length) { | ||
node.style = Object.assign({}, node.content[0].style) | ||
node.style.font = this.getFont(node.style.font) | ||
node.style.foreground = this.getColor(node.style.foreground) | ||
node.style.background = this.getColor(node.style.background) | ||
const initialStyle = node.content[0].style | ||
const style = {} | ||
style.font = this.getFont(initialStyle.font) | ||
style.foreground = this.getColor(initialStyle.foreground) | ||
style.background = this.getColor(initialStyle.background) | ||
for (let prop of Object.keys(initialStyle)) { | ||
if (initialStyle[prop] == null) continue | ||
let match = true | ||
for (let span of node.content) { | ||
if (initialStyle[prop] !== span.style[prop]) { | ||
match = false | ||
break | ||
} | ||
} | ||
if (match) style[prop] = initialStyle[prop] | ||
} | ||
node.style = style | ||
} | ||
@@ -55,0 +68,0 @@ } else { |
@@ -43,2 +43,13 @@ 'use strict' | ||
this.doc.addContent(new RTFParagraph()) | ||
const initialStyle = this.doc.content[0].style | ||
for (let prop of Object.keys(this.doc.style)) { | ||
let match = true | ||
for (let para of this.doc.content) { | ||
if (initialStyle[prop] !== para.style[prop]) { | ||
match = false | ||
break | ||
} | ||
} | ||
if (match) this.doc.style[prop] = initialStyle[prop] | ||
} | ||
}) | ||
@@ -45,0 +56,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
648
21033
9