Skip to content

Commit 3a6e77a

Browse files
Merge pull request #40 from contentstack/development
Development : acknowledged inline bug in v1.2.5
2 parents 05f43d1 + b27890d commit 3a6e77a

File tree

13 files changed

+12507
-298
lines changed

13 files changed

+12507
-298
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.contentstack.sdk</groupId>
66
<artifactId>utils</artifactId>
7-
<version>1.2.5</version>
7+
<version>1.2.6-SNAPSHOT</version>
88
<packaging>jar</packaging>
99
<name>Contentstack-utils</name>
1010
<description>Java Utils SDK for Contentstack Content Delivery API, Contentstack is a headless CMS</description>
@@ -230,7 +230,7 @@
230230
<configuration>
231231
<source>1.8</source>
232232
<target>1.8</target>
233-
<!-- <executable>${JAVA_HOME}/bin/javac</executable>-->
233+
<!-- <executable>${JAVA_HOME}/bin/javac</executable>-->
234234
</configuration>
235235
</plugin>
236236
<plugin>

src/main/java/com/contentstack/utils/node/NodeToHTML.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private NodeToHTML() {
2929
*/
3030
public static String textNodeToHTML(JSONObject nodeText, Option renderOption) {
3131
String text = nodeText.optString("text");
32-
text = text.replace("\n", "");
32+
text = text.replace("\n", "<br />");
3333
if (nodeText.has("superscript")) {
3434
text = renderOption.renderMark(MarkType.SUPERSCRIPT, text);
3535
}
@@ -52,7 +52,10 @@ public static String textNodeToHTML(JSONObject nodeText, Option renderOption) {
5252
text = renderOption.renderMark(MarkType.BOLD, text);
5353
}
5454
if (nodeText.has("break")) {
55-
text = renderOption.renderMark(MarkType.BREAK, text);
55+
if (!text.contains("<br />")) {
56+
text = renderOption.renderMark(MarkType.BREAK, text);
57+
}
58+
// text = renderOption.renderMark(MarkType.BREAK, text);
5659
}
5760
return text;
5861
}

src/main/java/com/contentstack/utils/render/DefaultOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public String renderMark(MarkType markType, String text) {
7070
case BOLD:
7171
return "<strong>" + text + "</strong>";
7272
case BREAK:
73-
return "<br />" + text; // v1.2.5
73+
return "<br />" + text.replace("\n", "");
7474
default:
7575
return text;
7676
}

src/test/java/com/contentstack/utils/RTEResult.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ public class RTEResult {
1818
public static String kCodeHtml = "<code>Code template.</code>";
1919
public static String kLinkInPHtml = "<p><strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\">LINK</a></p>";
2020
public static String kEmbedHtml = "<iframe src=\"https://www.youtube.com/watch?v=AOP0yARiW8U\"></iframe>";
21+
public static String kWFSAffectedHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\"><strong>In this article:<br />\t</strong><a target=\"_self\" href=\"#Overview\">Overview</a><br />\t<a target=\"_self\" href=\"#Fulfillment\">Standard Fulfillment</a><br />\t<a target=\"_self\" href=\"#AdditionalFees\">Additional Fees</a><br />\t<a target=\"_self\" href=\"#BigBulkyFulfillment\">Big & Bulky Fulfillment</a><br />\t<a target=\"_self\" href=\"#Storage\">Storage</a><br />\t<a target=\"_self\" href=\"#ProblemInventory\">Problem Inventory</a><br />\t<a target=\"_self\" href=\"#Return\">Return Shipping & Exceptions</a><br />\t<a target=\"_self\" href=\"#DisposalRemoval\">Disposal & Removal</a><br />\t<a target=\"_self\" href=\"#AdditionalPrograms\">Additional WFS Programs</a></p><h2 redactor-attributes=\"{}\" style=\"\" id=\"Overview\" dir=\"ltr\">Overview</h2><p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">Walmart Fulfillment Services is a competitive and cost-effective solution that offers an end-to-end ecommerce fulfillment experience. Our fee structure is simple and straightforward, without signup or monthly subscription fees. You're also free to ship and store any amount of inventory you choose, without minimums or maximums. Use the <a href=\"https://marketplace.walmart.com/walmart-fulfillment-services-pricing/?_gl=1*1t4i6i1*_ga*OTkwMDc3NzQuMTY1MjM3NjY3Nw..*_ga_1LB22TM2MG*MTY1MjcyNDU5My41OS4xLjE2NTI3MjY5NzIuMA..\">WFS Calculator</a> to estimate your fulfillment and storage fees.<br /><br />The following fees are effective as of August 2023 and are subject to change.</p>";
22+
public static String kAnchorHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">This is a paragraph with break true and<br />backslash nThis para has just one line break without any break key<br />Third paragraph with multiple line breaks<br /><br /><br />Fourth paragraph with multiple line breaks and break key<br /><br />Fifth paragraph with multiple only tab \t and this is text after tab<br />\tThis paragraph should start with a tab and should have a break before.</p>";
23+
public static String kWFSFeesHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br /><br /><br />\t\t\t\tUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <br />Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <br />\tExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>";
24+
25+
public static String kONEHtml = "<p redactor-attributes=\"{}\" style=\"\" dir=\"ltr\"><br />A paragraph with break set as trueA paragraph with line break <br /> and \t tab</p>";
2126
}

src/test/java/com/contentstack/utils/TestRte.java

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,58 @@ public void testAvailableEntryItemTypes() {
9999

100100
@Test
101101
public void testHERFID() throws IOException {
102-
final String rte = "src/test/resources/reports/jsonviewer.json";
102+
final String rte = "src/test/resources/reports/wfs_fees.json";
103+
JSONObject theRTE = new ReadResource().readJson(rte);
104+
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
105+
Assert.assertEquals(kWFSFeesHtml, result);
106+
}
107+
108+
109+
110+
@Test
111+
public void testAnchorIssue() throws IOException {
112+
final String rte = "src/test/resources/reports/anchor.json";
113+
JSONObject theRTE = new ReadResource().readJson(rte);
114+
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
115+
Assert.assertEquals(kAnchorHtml, result);
116+
}
117+
118+
@Test
119+
public void testAffectedEntry() throws IOException {
120+
final String rte = "src/test/resources/reports/wfs.json";
103121
JSONObject theRTE = new ReadResource().readJson(rte);
104122
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
105123
System.out.println(result);
124+
Assert.assertEquals(kWFSAffectedHtml, result);
106125
}
126+
127+
128+
@Test
129+
public void testOne() throws IOException {
130+
final String rte = "src/test/resources/reports/one.json";
131+
JSONObject theRTE = new ReadResource().readJson(rte);
132+
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
133+
System.out.println(result);
134+
Assert.assertEquals(kONEHtml, result);
135+
}
136+
137+
@Test
138+
public void testOCT7Issue() throws IOException {
139+
final String rte = "src/test/resources/reports/oct_7.json";
140+
JSONObject theRTE = new ReadResource().readJson(rte);
141+
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
142+
System.out.println(result);
143+
// Assert.assertEquals(kONEHtml, result);
144+
}
145+
146+
@Test
147+
public void testIssueOct() throws IOException {
148+
final String rte = "src/test/resources/reports/issue_oct.json";
149+
JSONObject theRTE = new ReadResource().readJson(rte);
150+
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
151+
System.out.println(result);
152+
// Assert.assertEquals(kONEHtml, result);
153+
}
154+
155+
107156
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"uid": "a59f9108e99747d4b3358d9e22b7c685",
3+
"type": "doc",
4+
"attrs": {
5+
"dirty": true
6+
},
7+
"children": [
8+
{
9+
"type": "p",
10+
"uid": "a3c0687b2f694bd68ec290fd92a62330",
11+
"attrs": {
12+
"style": {},
13+
"redactor-attributes": {},
14+
"dir": "ltr"
15+
},
16+
"children": [
17+
{
18+
"text": "This is a paragraph with break true and"
19+
},
20+
{
21+
"text": "\n",
22+
"break": true
23+
},
24+
{
25+
"text": "backslash n"
26+
},
27+
{
28+
"text": "This para has just one line break without any break key"
29+
},
30+
{
31+
"text": "\n"
32+
},
33+
{
34+
"text": "Third paragraph with multiple line breaks"
35+
},
36+
{
37+
"text": "\n\n\n"
38+
},
39+
{
40+
"text": "Fourth paragraph with multiple line breaks and break key"
41+
},
42+
{
43+
"text": "\n\n",
44+
"break": true
45+
},
46+
{
47+
"text": "Fifth paragraph with multiple only tab \t and this is text after tab"
48+
},
49+
{
50+
"text": "\n\t"
51+
},
52+
{
53+
"text": "This paragraph should start with a tab and should have a break before."
54+
}
55+
]
56+
}
57+
]
58+
}

0 commit comments

Comments
 (0)