}
String startPath = StringUtils.substringBefore( path, "/" );
// replace all links !!
Document document = Jsoup.parse( is, "UTF-8", "" );
Element body = document.body().child( 0 );
Elements links = body.select( "a[href]" );
for ( Element link : links ) {
link.attr( "href", "#" + startPath + "/" + link.attr( "href" ) );
}
Elements codes = body.select( "code" );
for ( Element code : codes ) {
code.attr( "class", code.attr( "class" ) + " nice-code" );
}
//default generated enunciate use h1/h2/h3 which is quite big so transform to h3/h4/h5
Elements headers = body.select( "h1" );
for ( Element header : headers ) {
header.tagName( "h3" );
}
headers = body.select( "h2" );
for ( Element header : headers ) {
header.tagName( "h4" );
}
headers = body.select( "h3" );
for ( Element header : headers ) {
header.tagName( "h5" );
}
Document res = new Document( "" );
res.appendChild( body.select( "div[id=main]" ).first() );
resp.getOutputStream().write( res.outerHtml().getBytes() );
}