Return to Snippet

Revision: 27961
at June 28, 2010 18:01 by tprimke


Updated Code
;; 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)) ))

Revision: 27960
at June 28, 2010 17:50 by tprimke


Initial Code
;; checks the given line and updates TOC data
(define (update-toc line)

  (define (append-toc content level)
    (unless (&gt; level SETUP:toc-level)
      (while (&gt; level TOC:lvl)
        (push "&lt;ul&gt;" TOC:toc)
        (++ TOC:lvl))
      (while (&lt; level TOC:lvl)
        (push "&lt;/ul&gt;" TOC:toc)
        (-- TOC:lvl))
      (push (append SETUP:toc-elm-start {&lt;a href="#a} (string TOC:anchor) {"&gt;} content {&lt;/a&gt;} 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)) ))

Initial URL


Initial Description


Initial Title
Update the TOC context

Initial Tags


Initial Language
Lisp