private String updateContentLinks()

in src/main/java/org/apache/cxf/cwiki/SiteExporter.java [1140:1161]


    private String updateContentLinks(AbstractPage page, String content,
                                      String id, String divCls) throws Exception {
        XMLReader parser = createTagSoupParser();
        StringWriter w = new StringWriter();
        parser.setContentHandler(createContentHandler(page, w, id, divCls));
        parser.parse(new InputSource(new StringReader(content)));
        content = w.toString();
        
        if (content.indexOf("html>") != -1) {
            content = content.substring("<html><body>".length());
            content = content.substring(0, content.lastIndexOf("</body></html>"));
        }
        
        int idx = content.indexOf('>');
        if (idx != -1
            && content.substring(idx + 1).startsWith("<p></p>")) {
            //new confluence tends to stick an empty paragraph at the beginning for some pages (like Banner)
            //that causes major formatting issues.  Strip it.
            content = content.substring(0, idx + 1) + content.substring(idx + 8);
        }
        return content;
    }