Ticket #1288: section-permalink.patch

File section-permalink.patch, 1.2 KB (added by Vasilij Schneidermann, 8 years ago)
  • qwiki-sxml.scm

    a b  
    241241     (section
    242242      *macro*
    243243      . ,(lambda (tag elems)
    244            (let ((level (car elems))
    245                  (head-word (cadr elems))
    246                  (contents (cddr elems)))
     244           (let* ((level (car elems))
     245                  (head-word (cadr elems))
     246                  (link (internal-link head-word))
     247                  (contents (cddr elems)))
    247248             (cond ((and (integer? level) head-word)
    248                     `((,(string->symbol (string-append "h" (number->string level)))
    249                        (@ (id ,(internal-link head-word)))
    250                        ,head-word ) . ,contents))
     249                    `((a (@ (href (,@(string-append "#" link))))
     250                         (,(string->symbol (string-append "h" (number->string level)))
     251                          (@ (id ,link))
     252                          ,head-word)) . ,contents))
    251253                   (else
    252254                    (error 'html-transformation-rules
    253255                           (conc "section elements must be of the form (section level head-word . contents), got " elems)))))))