FimfictionApi: improve bbcode description handling
authorNiki Roo <niki@nikiroo.be>
Thu, 13 Jul 2017 16:29:13 +0000 (18:29 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 13 Jul 2017 16:29:13 +0000 (18:29 +0200)
src/be/nikiroo/fanfix/supported/FimfictionApi.java

index 1594d5e18f365d14bfeb227e057bdec07c528bbf..59b593ec7aecedea5cb24c4f91b10f6819b172d6 100644 (file)
@@ -159,7 +159,15 @@ class FimfictionApi extends BasicSupport {
 
        @Override
        protected String getDesc(URL source, InputStream in) {
-               return getKeyJson(json, 0, "type", "story", "description");
+               String desc = getKeyJson(json, 0, "type", "story", "description");
+
+               // TODO: if the description becomes available in html, use it
+               desc = desc.replace("\\r\\n", "<br/>");
+               desc = desc.replace("[i]", "_").replace("[/i]", "_")
+                               .replace("[b]", "*").replace("[/b]", "*");
+               desc = desc.replaceAll("\\[[^\\]]*\\]", "");
+
+               return desc;
        }
 
        @Override