Bug fixes + rework of BasicSupport
[gofetch.git] / src / be / nikiroo / gofetch / output / Html.java
index 33c99c81f8874d4a8b249dddee43e0f56ff69a0c..385df8bf8da919416ccf672a623fa9288c0ab585 100644 (file)
@@ -2,7 +2,8 @@ package be.nikiroo.gofetch.output;
 
 import be.nikiroo.gofetch.data.Comment;
 import be.nikiroo.gofetch.data.Story;
-import be.nikiroo.gofetch.support.BasicSupport.Type;
+import be.nikiroo.gofetch.support.Type;
+import be.nikiroo.utils.StringUtils;
 
 public class Html extends Output {
        public Html(Type type, String hostname, String preselector, int port) {
@@ -99,7 +100,8 @@ public class Html extends Output {
                                .append("<div class='comment' style='display: block; margin-left: 80px'>\n");
                builder.append(space).append("  <h2>").append(comment.getTitle())
                                .append("</h2>\n");
-               builder.append(space).append("  <div class='by'>")
+               builder.append(space)
+                               .append("  <div class='by' style='font-style: italic;'>")
                                .append(comment.getAuthor()).append("</div>\n");
                builder.append(space).append("  <div class='comment_content'>");
                for (String line : comment.getContentLines()) {
@@ -120,8 +122,14 @@ public class Html extends Output {
                } else {
                        builder.append("        <h1>" + story.getTitle() + "</h1>\n");
                }
-               builder.append("        <div class='details'>(" + story.getDetails()
-                               + ")</div>\n");
+
+               builder.append("        <div class='details'>");
+               if (story.getDetails() != null && !story.getDetails().isEmpty()) {
+                       builder.append("(")
+                                       .append(StringUtils.xmlEscape(story.getDetails()))
+                                       .append(")");
+               }
+               builder.append("</div>\n");
                builder.append("        <br/>\n");
 
                if (!resume) {
@@ -138,9 +146,13 @@ public class Html extends Output {
 
                builder.append("        <div class='content' style='text-align: justify'>\n");
                if (resume) {
-                       builder.append("                " + story.getContent() + "\n");
+                       builder.append("                " + StringUtils.xmlEscape(story.getContent())
+                                       + "\n");
                } else {
-                       builder.append("                " + story.getFullContent() + "\n");
+                       builder.append("                "
+                                       + StringUtils.xmlEscape(story.getFullContent())
+                                                       .replace("\n", "<br/>").replace("[ ", "<h2>")
+                                                       .replace(" ]", "</h2>") + "\n");
                }
                builder.append("        </div>\n");