+ final static int BR_LENGTH = "<br/>".length();
+
+ public String readSimpleHtml(Item item) {
+ String raw = raw(item);
+ // FIXME the saved data should be corrected instead.
+ if (raw.indexOf('&') >= 0) {
+ raw = raw.replace("&", "&");
+ }
+ if (raw.indexOf('<') >= 0) {
+ raw = raw.replace("<", "<");
+ }
+ if (raw.indexOf('>') >= 0) {
+ raw = raw.replace(">", ">");
+ }
+ if (raw.indexOf('\"') >= 0) {
+ raw = raw.replace("\"", """);
+ }
+ if (raw.indexOf('\'') >= 0) {
+ raw = raw.replace("\'", "'");
+ }
+// raw = "<span style='text-align:justify'>" + raw + "</span>";
+ if (raw.length() == 0)
+ return raw;
+ try (StringReader reader = new StringReader(raw)) {
+ List<String> lines = IOUtils.readLines(reader);
+ if (lines.size() == 1)
+ return lines.get(0);
+ StringBuilder sb = new StringBuilder(raw.length() + lines.size() * BR_LENGTH);
+ for (int i = 0; i < lines.size(); i++) {
+ if (i != 0)
+ sb.append("<br/>");
+ sb.append(lines.get(i));
+ }
+ return sb.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+// String[] lines = raw.split("[\r\n]+");
+// if (lines.length == 1)
+// return lines[0];
+// StringBuilder sb = new StringBuilder(raw.length() + lines.length * BR_LENGTH);
+// for (int i = 0; i < lines.length; i++) {
+// if (i != 0)
+// sb.append("<br/>");
+// sb.append(lines[i]);
+// }
+// return sb.toString();
+ }
+