/ Published in: Lisp
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
;; checks the given line and updates TOC data (define (update-toc line) (define (append-toc content level) (unless (> level SETUP:toc-level) (while (> level TOC:lvl) (push "<ul>" TOC:toc) (++ TOC:lvl)) (while (< level TOC:lvl) (push "</ul>" TOC:toc) (-- TOC:lvl)) (push (append SETUP:toc-elm-start {<a href="#a} (string TOC:anchor) {">} content {</a>} SETUP:toc-elm-end) TOC:toc))) (cond ((find "======(.*)======" line 512) (append-toc $1 5)) ((find "=====(.*)=====" line 512) (append-toc $1 4)) ((find "====(.*)====" line 512) (append-toc $1 3)) ((find "===(.*)===" line 512) (append-toc $1 2)) ((find "==(.*)==" line 512) (append-toc $1 1)) ((find {\[toc\]} line 512) (set 'TOC:found true)) ))