Changeset 14228 for lang/gauche
- Timestamp:
- 06/18/08 23:39:31 (5 months ago)
- Location:
- lang/gauche/oldtype/trunk
- Files:
-
- 2 added
- 5 modified
-
Kahua/oldtype/oldtype/format.scm (modified) (2 diffs)
-
Kahua/oldtype/oldtype/parse.scm (modified) (4 diffs)
-
edit/Sample1.ot (added)
-
edit/Sample2.ot (added)
-
src (modified) (1 prop)
-
src/Makefile (modified) (1 diff)
-
src/oldtype_to (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/format.scm
r13023 r14228 52 52 oldtype:expand-page 53 53 oldtype:format-line-plainly 54 )55 ) 54 oldtype:oldtype-page->plain-text 55 )) 56 56 (select-module oldtype.format) 57 57 … … 65 65 (define (oldtype:calculate-heading-id headings) 66 66 (string-append "H-" (number->string (hash headings) 36))) 67 68 69 (define (oldtype:wikiname->plain wikiname) 70 (let1 m (#/[|](.+)/ wikiname) 71 (if m 72 (rxmatch-substring m 1) 73 wikiname))) 74 75 (define (oldtype:wiki-macro->plain expr) 76 (let ((command (car expr)) 77 (arg ;; symbol list to string list. 78 (map 79 (lambda (x) 80 (if (number? x) 81 (number->string x) 82 (symbol->string x))) 83 (cdr expr))) 84 (len (length (cdr expr)))) 85 (case command 86 ((img) "[img] ") 87 ((todo) "[TODO] ") 88 ((done) "[DONE] ") 89 ((youtube) "[YouTube] ") 90 ((thumb) 91 (if (< 0 len) 92 (let1 _url (car arg) 93 (string-append "[Thumb " _url "] ")) 94 "!!Error : No argument ##(thumb URL) command")) 95 ((amazon) 96 (if (< 0 len) 97 (let* ((_asin (car arg)) 98 (_asin (if (#/^[0-9]+$/ _asin) 99 (format "~10,,,'0@a" _asin) 100 _asin))) 101 (if (#/^[0-9a-zA-Z]+$/ _asin) 102 (format "[Amazon ~a] " _asin) 103 (format "!!Error : ASIN code format error for ##(amazon asin) command \"~a\"!!" _asin))) 104 "!!Error : No argument ##(amazon URL) command")) 105 ;; timestamp 106 ((timestamp) "[timestamp] ") 107 ;; since 108 ((since) "[since] ") 109 ;; download link oldtype-mode.el source code 110 ((download-el) "[Download oldtype-mode.el now]") 111 (else 112 (format "!!Error : no such macro \"~a\"!!" command))))) 113 114 115 (define (oldtype:oldtype-page->plain-text sxmls) 116 (let rec 117 ((sxmls sxmls)) 118 (match sxmls 119 (() '()) 120 (((and (name . _) sxml) . rest) ;; generic node 121 (let1 arg (cdr sxml) 122 (cons 123 (case name 124 ((div) 125 (let* ((param (car arg)) ;; param is assoc-list 126 (lineno (assq-ref param 'lineno))) 127 (rec (cdr arg)))) 128 ((a) 129 (let1 param (car arg) ;; param is assoc-list 130 (rec (cdr arg)))) 131 ((p-normal) (rec arg)) 132 ((pre-quote) (rec arg)) 133 ((pre-verb) (rec arg)) 134 ((pre-ul1) (cons "- " (rec arg))) 135 ((pre-ul2) (cons "-- " (rec arg))) 136 ((pre-ul3) (cons "--- " (rec arg))) 137 ((pre-ol1) (cons "# " (rec arg))) 138 ((pre-ol2) (cons "## " (rec arg))) 139 ((pre-ol3) (cons "### " (rec arg))) 140 ((h1) (cons "[] " (rec (cdr arg)))) 141 ((h2) (cons "* " (rec (cdr arg)))) 142 ((h3) (cons "** " (rec (cdr arg)))) 143 ((h4) (cons "*** " (rec (cdr arg)))) 144 ((h5) (cons "**** " (rec (cdr arg)))) 145 ((h6) (cons "***** " (rec (cdr arg)))) 146 ((wiki-macro) (oldtype:wiki-macro->plain arg)) 147 ((wiki-name) (oldtype:wikiname->plain (car arg))) 148 ((hr) (list "----\n")) 149 (else 150 (format "!!Error : no such tag \"~a\"!!" name))) 151 (rec rest)))) 152 ((other . rest) 153 (cons other (rec rest)))))) 154 155 67 156 68 157 ;; utility : strips wiki markup and returns a plaintext line. -
lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/parse.scm
r7811 r14228 181 181 ((string=? "----" line) '(hr)) 182 182 ((string-prefix? "!" line) `(open-single-verb . ,line)) 183 ((string=? "{{{" line) '(open-verb))184 ((string=? "<<<" line) '(open-quote))185 ((and (string=? ">>>" line)186 (memq 'blockquote ctx)) '(close-quote))187 183 ((string-prefix? " " line) `(pre . ,line)) 188 184 ((rxmatch #/^(\*{1,}) / line) => (cut cons 'heading <>)) … … 212 208 (case (token-type tok) 213 209 ((eof) (reverse! seed)) 214 ((null) (block (next-token ctx) ctx seed))210 ((null) (block (next-token ctx) ctx (cons `(div (@@ (lineno ,line-no)) (p-normal "\n")) seed))) 215 211 ((hr) (block (next-token ctx) ctx (cons `(div (@@ (lineno ,line-no)) (hr)) seed))) 216 212 ((open-single-verb) … … 243 239 (pre-verb 244 240 ,@(expand-tab 245 (string-drop (token-value tok) 1)))))) 241 (string-drop (token-value tok) 1)) 242 "\n")))) 246 243 247 244 ;; Verbatim … … 444 441 (cond ((eof-object? line) 445 442 (if (null? r) line (string-concatenate-reverse r))) 446 (verbatim447 (when (string=? "}}}" line) (set! verbatim #f))448 line)449 ((string-prefix? ";;" line)450 (rec (getline) r))451 ((string=? "{{{" line)452 (if (null? r)453 (begin (set! verbatim #t) line)454 (begin (ungetline line) (string-concatenate-reverse r))))455 ((string-prefix? "~" line)456 (rec (getline) (cons (string-drop line 1) r)))457 443 (else 458 444 (if (null? r) 459 (rec (getline) (cons line r))460 (begin (ungetline line) (string-concatenate-reverse r))))445 (rec (getline) (cons line r)) 446 (begin (ungetline line) (string-concatenate-reverse r)))) 461 447 ))) 462 448 ) -
lang/gauche/oldtype/trunk/src
- Property svn:ignore
-
old new 12 12 out.txt 13 13 test.log 14 Sample1.sxml 15 Sample1.txt 16 Sample2.sxml 17 Sample2.txt
-
- Property svn:ignore
-
lang/gauche/oldtype/trunk/src/Makefile
r13389 r14228 3 3 OTSAMPLE='../edit/Test.ot' 4 4 5 all: log.txt Test.ann.txt Entry1.ann.txt Entry2.ann.txt 5 all: log.txt Test.ann.txt Entry1.ann.txt Entry2.ann.txt 6 6 gosh -I ../Kahua/oldtype ./oldtype_to internal ../edit/Test.ot log.txt Test.ann.txt > Test.sexp 7 7 gosh -I ../Kahua/oldtype ./oldtype_to internal ../edit/Entry1.ot log.txt Entry1.ann.txt > Entry1.sexp 8 8 gosh -I ../Kahua/oldtype ./oldtype_to internal ../edit/Entry2.ot log.txt Entry2.ann.txt > Entry2.sexp 9 gosh -I ../Kahua/oldtype ./oldtype_to sxml ${OTSAMPLE} > out.sxml 10 gosh -I ../Kahua/oldtype ./oldtype_to plain ${OTSAMPLE} > out.txt 9 gosh -I ../Kahua/oldtype ./oldtype_to sxml ../edit/Sample1.ot > Sample1.sxml 10 gosh -I ../Kahua/oldtype ./oldtype_to sxml ../edit/Sample2.ot > Sample2.sxml 11 gosh -I ../Kahua/oldtype ./oldtype_to plain ../edit/Sample1.ot > Sample1.txt 12 gosh -I ../Kahua/oldtype ./oldtype_to plain ../edit/Sample2.ot > Sample2.txt 11 13 12 14 test: log.txt Test.ann.txt -
lang/gauche/oldtype/trunk/src/oldtype_to
r13237 r14228 158 158 ('plain 159 159 (let* ( 160 (tree (oldtype:format-line-plainly converted-str))) 161 (for-each 162 print 163 tree))) 160 (sxml (oldtype-parse input-port)) 161 (sexp (oldtype:oldtype-page->plain-text sxml))) 162 (print 163 (tree->string 164 sexp)))) 164 165 (else 165 166 (cerr (format "Unsupported type. [~a]" (symbol->string type)))
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)