diff -r c60625d58158 -r 08c9fb6fb017 src/org/sonews/storage/DrupalMessage.java --- a/src/org/sonews/storage/DrupalMessage.java Mon Oct 17 18:14:34 2011 +0200 +++ b/src/org/sonews/storage/DrupalMessage.java Wed Oct 19 17:23:53 2011 +0200 @@ -64,6 +64,7 @@ private static final String CRLF = "\r\n"; public static final String CHARSET = "UTF-8"; private static final String XHTML_CONTENT_TYPE = "text/html; charset=" + CHARSET; + private static final String ZNAKČKA_KONCE_ŘÁDKU = "◆"; private String messageID; /** @@ -198,7 +199,7 @@ * - použít delší zástupný řetězec, ne jen jeden znak * - umísťovat ho jen tam, kde už nějaký text je (ne mezi >\s*<) */ - inputText = inputText.replaceAll("\\n", "◆\n"); + inputText = označKonceŘádků(inputText); Runtime r = Runtime.getRuntime(); Process p = r.exec(new String[]{"tidy", // http://tidy.sourceforge.net @@ -219,12 +220,23 @@ String outputText = streamToString(p.getInputStream()); - outputText = outputText.replaceAll("◆\\n", "\n"); - outputText = outputText.replaceAll("◆", "\n"); + outputText = vraťKonceŘádků(outputText); return outputText; } + private static String označKonceŘádků(String text) { + text = text.replaceAll(">\\s+<", "> <"); + text = text.replaceAll("\\n", ZNAKČKA_KONCE_ŘÁDKU + "\n"); + return text; + } + + private static String vraťKonceŘádků(String text) { + text = text.replaceAll(ZNAKČKA_KONCE_ŘÁDKU + "\\n", "\n"); + text = text.replaceAll(ZNAKČKA_KONCE_ŘÁDKU, "\n"); + return text; + } + /** * TODO: refaktorovat, přesunout */