]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Generate the TOC in a more reasonable and sophisticated way.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 15 Apr 2002 10:21:24 +0000 (10:21 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 15 Apr 2002 10:21:24 +0000 (10:21 +0000)
git-svn-id: https://svn.dealii.org/trunk@5653 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/tutorial/chapter-2.step-by-step/Makefile
deal.II/doc/tutorial/chapter-2.step-by-step/head.html
deal.II/doc/tutorial/chapter-2.step-by-step/program2toc [new file with mode: 0644]

index 4d386c386f869e9d56a547186347625ed8762936..3a357bf9af0b8e079b05614d843c59ff784db60f 100644 (file)
@@ -15,9 +15,7 @@ all: $(example-htmls)
 $(example-htmls):
        @echo ================== Assembling $@
        @TOC=`cat $D/examples/$(@:.html=)/$(@:.html=.cc) \
-         | grep "@sect" \
-         | perl -pi -e 's/.*\{(.*)\}.*/\1/; $$n=$$1; $$nn=$$1; \
-           $$nn=~s/\s/_/g; $$_="<li><a href=\"#$$nn\">$$n</a></li>\n";' \
+         | perl program2toc \
          | perl -pi -e 's/\"/\\\"/g;'` ; \
         cat head.html \
          | perl -pi -e '$$step="$@";                     \
index 6e5cab2015a4b9dbe0b31bb178447863b593a57b..9d958c364a7d11d9a5b1ca84b064c107b5fc991a 100644 (file)
@@ -21,9 +21,7 @@
 <ol>
   <li> <a href="#Intro">Introduction</a>
   <li> <a href="#CommProg">The commented program</a>
-       <ul>
-       TOC
-       </ul>
+TOC
   <li> <a href="#Results">Results</a>
   <li> <a href="#PlainProg">The plain program</a>
 </ol>
diff --git a/deal.II/doc/tutorial/chapter-2.step-by-step/program2toc b/deal.II/doc/tutorial/chapter-2.step-by-step/program2toc
new file mode 100644 (file)
index 0000000..26b94bd
--- /dev/null
@@ -0,0 +1,34 @@
+print "    <ul>\n";
+
+$level = 3;
+while (<>) {
+    if ( /\@sect(.)\{(.*)\}/ ) {
+       $newlevel = $1;
+       $text = $2;
+       
+       # only allow header levels 3 and 4, since higher ones are
+       # reserved for top-level document headers
+       if (! ($newlevel =~ /[34]/)) {
+           print STDERR "Only header levels 3 and 4 are allowed.\n";
+           print STDERR "You had $newlevel.\n";
+           die;
+       }
+
+       if ($newlevel > $level) {
+           print "      <ul>\n";
+       } elsif ($newlevel < $level) {
+           print "      </ul>\n";
+       }
+
+       $reftext = $text;
+       $reftext =~ s/\s/_/g;
+       print "        <li><a href=\"#$reftext\">$text</a>\n";
+
+       $level = $newlevel;
+    } 
+}
+
+if ( $level == 4) {
+    print "      </ul>\n";
+}
+print "    </ul>\n";

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.