Posted By

tprimke on 06/28/10


Tagged

newLISP newLISPwiki


Versions (?)

Update the TOC context


 / Published in: Lisp
 

  1. ;; checks the given line and updates TOC data
  2. (define (update-toc line)
  3.  
  4. (define (append-toc content level)
  5. (unless (> level SETUP:toc-level)
  6. (while (> level TOC:lvl)
  7. (push "<ul>" TOC:toc)
  8. (++ TOC:lvl))
  9. (while (< level TOC:lvl)
  10. (push "</ul>" TOC:toc)
  11. (-- TOC:lvl))
  12. (push (append SETUP:toc-elm-start {<a href="#a} (string TOC:anchor) {">} content {</a>} SETUP:toc-elm-end) TOC:toc)))
  13.  
  14. (cond
  15. ((find "======(.*)======" line 512) (append-toc $1 5))
  16. ((find "=====(.*)=====" line 512) (append-toc $1 4))
  17. ((find "====(.*)====" line 512) (append-toc $1 3))
  18. ((find "===(.*)===" line 512) (append-toc $1 2))
  19. ((find "==(.*)==" line 512) (append-toc $1 1))
  20. ((find {\[toc\]} line 512) (set 'TOC:found true)) ))

Report this snippet  

You need to login to post a comment.