cogCreates an index of the headings of the current document
Developed by

xwiki:XWiki.FriedemannLoew

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

There's now a TOC Macro.
#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];
  }
}
%>

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags:
Created by FriedemannLoew on 2007/02/27 17:35
     

Get Connected