mirror of
https://github.com/tbluemel/rtf.js.git
synced 2026-11-30 16:47:59 +01:00
Add support for implicitly defined \par (backslash + newline / carriage return)
This commit is contained in:
+9
-4
@@ -776,10 +776,6 @@ var Parser = /** @class */ (function () {
|
||||
// Reset if we unexpectedly encounter a keyword
|
||||
this.parser.state.skipchars = 0;
|
||||
switch (keyword) {
|
||||
case "\n":
|
||||
return "\n";
|
||||
case "\r":
|
||||
return "\r";
|
||||
case "tab":
|
||||
return "\t";
|
||||
case "emdash":
|
||||
@@ -854,6 +850,15 @@ var Parser = /** @class */ (function () {
|
||||
case "ltrch":
|
||||
case "rtlch":
|
||||
return;
|
||||
case "\n":
|
||||
case "\r": {
|
||||
// Carriage return and line feed must be treated like a \par, so we rewrite the keyword
|
||||
// here and then fall through to the default behavior
|
||||
this.parser.line++;
|
||||
this.parser.column = 0;
|
||||
keyword = "par";
|
||||
}
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
default:
|
||||
if (!this.parser.state.skipdestination) {
|
||||
if (first) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -235,10 +235,6 @@ export class Parser {
|
||||
// Reset if we unexpectedly encounter a keyword
|
||||
this.parser.state.skipchars = 0;
|
||||
switch (keyword) {
|
||||
case "\n":
|
||||
return "\n";
|
||||
case "\r":
|
||||
return "\r";
|
||||
case "tab":
|
||||
return "\t";
|
||||
case "emdash":
|
||||
@@ -318,6 +314,16 @@ export class Parser {
|
||||
case "rtlch":
|
||||
return;
|
||||
|
||||
case "\n":
|
||||
case "\r": {
|
||||
// Carriage return and line feed must be treated like a \par, so we rewrite the keyword
|
||||
// here and then fall through to the default behavior
|
||||
this.parser.line++;
|
||||
this.parser.column = 0;
|
||||
|
||||
keyword = "par";
|
||||
}
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
default:
|
||||
if (!this.parser.state.skipdestination) {
|
||||
if (first) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,14 @@
|
||||
<div>
|
||||
<span> LINE1 - APPLE
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span> LINE2 - BANANA
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span> LINE3 - CLEAN
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
{\rtf1\ansi\ansicpg1252
|
||||
LINE1 - APPLE\
|
||||
LINE2 - BANANA\
|
||||
LINE3 - CLEAN\
|
||||
}
|
||||
Reference in New Issue
Block a user