Changeset 18010 in project


Ignore:
Timestamp:
05/06/10 21:45:49 (9 years ago)
Author:
zbigniew
Message:

chicken-doc-admin: Handle nowiki tags inside signatures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/chicken-doc-admin/trunk/svnwiki-sxml.scm

    r18006 r18010  
    1010(import extras)
    1111(import (only ports with-input-from-port))
    12 (import (only data-structures string-intersperse string-split))
     12(import (only data-structures string-intersperse string-split
     13              string-translate*))
    1314(import (only srfi-13 string-trim-right string-trim-both
    1415              string-concatenate-reverse))
     
    325326  `(def (sig . ,(definition-sigs))
    326327        . ,(definition-body)))
     328
     329(define de-nowikify
     330  ;; svnwiki processes HTML tags inside procedure tags.  To insert a
     331  ;; literal tag requires <nowiki> + char entity.  Here we convert
     332  ;; critical entities to regular text (without fully parsing as HTML).
     333  (let ((re (irregex '(: "<nowiki>" (submatch (*? any)) "</nowiki>"))))
     334    (define (de-entitize str)
     335      (string-translate* str '(("&lt;" . "<")    ("&gt;" . ">")
     336                               ("&quot;" . "\"") ("&apos;" . "'")
     337                               ("&amp;" . "&"))))
     338    (lambda (s)
     339      (irregex-replace/all
     340       re s
     341       (lambda (m) (de-entitize (irregex-match-substring m 1)))))))
     342
    327343(define (definition-sigs)
    328344  (let ((line (peek-buffered-line)))
     
    334350           => (match-lambda ((_ tag sig)
    335351                        (discard-line)
    336                         (cons `(,(string->symbol tag) ,sig)
     352                        (cons `(,(string->symbol tag)
     353                                ,(de-nowikify sig))   ; gosh i hate svnwiki sometimes
    337354                              (definition-sigs)))))
    338355          (else '()))))
     356
    339357(define (definition-body)
    340358  (let ((line (peek-buffered-line)))
Note: See TracChangeset for help on using the changeset viewer.