Page Index Snippet
Creates an index of the headings of the current document. Headings of different levels will have different indents.Code
#set($plaincontent = $doc.getContent())
<%
vcontext=context.get("vcontext");
plaincontent=vcontext.get("plaincontent");
backSubString = plaincontent;
i=0;
sternchen=["*", "**", "***", "****", "*****", "******"]
while (backSubString.matches("(?s).*\\n1(\\.1)* .*")){
level=1;
backSubString = backSubString.split("\\n1", 2)[1];
while (backSubString.matches("(?s)\\.1.*")){
level++;
backSubString=backSubString.split("\\.1", 2)[1];
}
if (! backSubString.matches("(?s)\\..*")) { // is not a List
heading=backSubString.split("[\\n\\r]", 2)[0];
encHeading=URLEncoder.encode(heading, "UTF-8");
encHeading=encHeading.replaceAll("[+%-\\.]", "");
println(sternchen[level-1] + " ["+heading+">#H"+encHeading+"]");
i++;
} else {
backSubString=backSubString.split("\\.(1\\.)*", 2)[1];
}
}
%>
Version 2.1 last modified by VincentMassol on 09/12/2007 at 14:39
Document data
Attachments:
No attachments for this document
Comments: 0