Skip to content

Commit f1602e2

Browse files
CS-41851- Fixed issue of adding an extra <br/> tag in breaks.
1 parent af573e7 commit f1602e2

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +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", "");
3233
if (nodeText.has("superscript")) {
3334
text = renderOption.renderMark(MarkType.SUPERSCRIPT, text);
3435
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ public String renderOptions(JSONObject embeddedObject, Metadata metadata) {
5454
*/
5555
@Override
5656
public String renderMark(MarkType markType, String text) {
57-
String textContainsBreak = renderHtmlWithLineBreaks(text); // v1.2.5
57+
//String textContainsBreak = renderHtmlWithLineBreaks(text); // v1.2.5
5858
switch (markType) {
5959
case SUPERSCRIPT:
60-
return "<sup>" + textContainsBreak + "</sup>";
60+
return "<sup>" + text + "</sup>";
6161
case SUBSCRIPT:
62-
return "<sub>" + textContainsBreak + "</sub>";
62+
return "<sub>" + text + "</sub>";
6363
case INLINECODE:
64-
return "<span>" + textContainsBreak + "</span>";
64+
return "<span>" + text + "</span>";
6565
case STRIKETHROUGH:
66-
return "<strike>" + textContainsBreak + "</strike>";
66+
return "<strike>" + text + "</strike>";
6767
case UNDERLINE:
68-
return "<u>" + textContainsBreak + "</u>";
68+
return "<u>" + text + "</u>";
6969
case ITALIC:
70-
return "<em>" + textContainsBreak + "</em>";
70+
return "<em>" + text + "</em>";
7171
case BOLD:
72-
return "<strong>" + textContainsBreak + "</strong>";
72+
return "<strong>" + text + "</strong>";
7373
case BREAK:
74-
return "<br />"+text; // v1.2.5
74+
return "<br />" + text; // v1.2.5
7575
default:
76-
return textContainsBreak;
76+
return text;
7777
}
7878
}
7979

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void testAvailableEntryItemTypes() {
9999

100100
@Test
101101
public void testHERFID() throws IOException {
102-
final String rte = "src/test/resources/wallmart/lessthanequalto.json";
102+
final String rte = "src/test/resources/wallmart/jsonviewer.json";
103103
JSONObject theRTE = new ReadResource().readJson(rte);
104104
String result = Utils.jsonToHTML(theRTE, new DefaultOption(), null);
105105
System.out.println(result);

0 commit comments

Comments
 (0)