diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index ddc4fceb9619a6c97e0086e23a252a43d03d995e..451511f162b33fea42e94103b3d1f9b7378a5b20 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -369,6 +369,9 @@ function BodyReader(options) { "w:footnoteReference": noteReferenceReader("footnote"), "w:endnoteReference": noteReferenceReader("endnote"), "w:commentReference": readCommentReference, + "w:cr": function() { + return elementResult(documents.lineBreak); + }, "w:br": function(element) { var breakType = element.attributes["w:type"]; if (breakType == null || breakType === "textWrapping") { diff --git a/lib/raw-text.js b/lib/raw-text.js index 138b73c9c5a4830625d94e9df8fa437f27dbe57c..37e631b6727aab74790b164410d59b15c49480f6 100644 --- a/lib/raw-text.js +++ b/lib/raw-text.js @@ -5,6 +5,8 @@ function convertElementToRawText(element) { return element.value; } else if (element.type === documents.types.tab) { return "\t"; + } else if (element.type === documents.types["break"] && element.breakType === "line") { + return "\n"; } else { var tail = element.type === "paragraph" ? "\n\n" : ""; return (element.children || []).map(convertElementToRawText).join("") + tail; diff --git a/mammoth.browser.js b/mammoth.browser.js index 74d66684379be46bf9e14dda407d2129430ad14f..42c3084561b2b3a6ba284c892702632a9bd160a2 100644 --- a/mammoth.browser.js +++ b/mammoth.browser.js @@ -1168,6 +1168,9 @@ function BodyReader(options) { "w:footnoteReference": noteReferenceReader("footnote"), "w:endnoteReference": noteReferenceReader("endnote"), "w:commentReference": readCommentReference, + "w:cr": function() { + return elementResult(documents.lineBreak); + }, "w:br": function(element) { var breakType = element.attributes["w:type"]; if (breakType == null || breakType === "textWrapping") { @@ -3052,6 +3055,8 @@ function convertElementToRawText(element) { return element.value; } else if (element.type === documents.types.tab) { return "\t"; + } else if (element.type === documents.types["break"] && element.breakType === "line") { + return "\n"; } else { var tail = element.type === "paragraph" ? "\n\n" : ""; return (element.children || []).map(convertElementToRawText).join("") + tail;