Show
Ignore:
Timestamp:
10/24/08 07:06:05 (5 years ago)
Author:
kiyoka
Message:

Supported HTML format for description part of RSS 2.0 feed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/format.scm

    r20419 r22008  
    7373            wikiname))) 
    7474 
    75 (define (oldtype:wiki-macro->plain expr) 
     75(define (oldtype:wiki-macro->plain expr rich-mode) 
    7676  (let ((command (car expr)) 
    7777        (arg  ;; symbol list to string list. 
     
    8484        (len (length (cdr expr)))) 
    8585    (case command 
    86       ((img)        "[img] ") 
     86      ((img img-s img-m) 
     87       (if (and (#/^http:/ (car arg)) rich-mode) 
     88           (string-append "<img src=\"" (car arg) "\"/>") 
     89           "[img] ")) 
    8790      ((todo)       "[TODO] ") 
    8891      ((done)       "[DONE] ") 
    89       ((youtube)    "[YouTube] ") 
     92      ((youtube youtube-s youtube-m) 
     93           (if (< 0 len) 
     94               (let ((_videoid (car arg))) 
     95                 (if (not rich-mode) 
     96                     (format #f "[YouTube ~a] " _videoid) 
     97                     (string-append "<img src=\"" (oldtype:youtube-thumbnail _videoid) "\"" 
     98                                    (case command 
     99                                      ((youtube)   " ") 
     100                                      ((youtube-s) (format #f " height=~a " oldtype:image-height-s)) 
     101                                      ((youtube-m) (format #f " height=~a " oldtype:image-height-m))) 
     102                                    "/>"))) 
     103               "!!Error : No argument ##(youtube VIDEOID) command")) 
    90104      ((thumb) 
    91105       (if (< 0 len) 
     
    93107                 (string-append "[Thumb " _url "] ")) 
    94108           "!!Error : No argument ##(thumb URL) command")) 
    95       ((amazon) 
     109      ((amazon amazon-s amazon-m) 
    96110       (if (< 0 len) 
    97111           (let* ((_asin (car arg)) 
     
    100114                             _asin))) 
    101115             (if (#/^[0-9a-zA-Z]+$/ _asin) 
    102                  (format "[Amazon ~a] " _asin) 
     116                 (if (not rich-mode) 
     117                     (format #f "[Amazon ~a]" _asin) 
     118                     (string-append "<img src=\"" (oldtype:amazon-thumbnail _asin) "\"" 
     119                                    (case command 
     120                                      ((amazon)   " ") 
     121                                      ((amazon-s) (format #f " height=~a " oldtype:image-height-s)) 
     122                                      ((amazon-m) (format #f " height=~a " oldtype:image-height-m))) 
     123                                    "/>")) 
    103124                 (format "!!Error : ASIN code format error for ##(amazon asin) command \"~a\"!!" _asin))) 
    104            "!!Error : No argument ##(amazon URL) command")) 
     125           "!!Error : No argument ##(amazon ASINCODE) command")) 
    105126      ;; timestamp 
    106127      ((timestamp)   "[timestamp] ") 
     
    165186;;   ) 
    166187;; 
    167 (define (oldtype:sxml->plain-text sxmls) 
     188(define (oldtype:sxml->plain-text sxmls rich-mode) 
    168189  (tree->string 
    169190   (let rec 
     
    191212                      ((pre-ol2)     (cons "## "    (rec arg))) 
    192213                      ((pre-ol3)     (cons "### "   (rec arg))) 
    193                       ((h1)          (cons "[] "    (rec arg))) 
    194                       ((h2)          (cons "* "     (rec arg))) 
    195                       ((h3)          (cons "** "    (rec arg))) 
    196                       ((h4)          (cons "*** "   (rec arg))) 
    197                       ((h5)          (cons "**** "  (rec arg))) 
    198                       ((h6)          (cons "***** " (rec arg))) 
    199                       ((wiki-macro)  (oldtype:wiki-macro->plain arg)) 
     214                      ((h1)          (if rich-mode 
     215                                         (list "<h1>"   (rec arg) "</h1>") 
     216                                         (cons "[] "    (rec arg)))) 
     217                      ((h2)          (if rich-mode 
     218                                         (list "<h2>"   (rec arg) "</h2>") 
     219                                         (cons "* "     (rec arg)))) 
     220                      ((h3)          (if rich-mode 
     221                                         (list "<h3>"   (rec arg) "</h3>") 
     222                                         (cons "** "    (rec arg)))) 
     223                      ((h4)          (if rich-mode 
     224                                         (list "<h4>"   (rec arg) "</h4>") 
     225                                         (cons "*** "   (rec arg)))) 
     226                      ((h5)          (if rich-mode 
     227                                         (list "<h5>"   (rec arg) "</h5>") 
     228                                         (cons "**** "  (rec arg)))) 
     229                      ((h6)          (if rich-mode 
     230                                         (list "<h6>"   (rec arg) "</h6>") 
     231                                         (cons "***** " (rec arg)))) 
     232                      ((wiki-macro)  (oldtype:wiki-macro->plain arg rich-mode)) 
    200233                      ((wiki-name)   (oldtype:wikiname->plain (car arg))) 
    201                       ((hr)          (list "----\n")) 
     234                      ((hr)          (if rich-mode 
     235                                         (list "<hr>") 
     236                                         (list "----\n"))) 
    202237                      ((@)           '()) 
    203238                      ((@@)          '())