--- gforth/wf.fs 2004/12/31 13:23:58 1.30 +++ gforth/wf.fs 2005/01/22 16:39:58 1.33 @@ -34,7 +34,7 @@ require string.fs \ character recoding -[IFDEF] 8-bit-io 8-bit-io [THEN] +[IFDEF] maxascii $100 to maxascii 8-bit-io [THEN] \ UTF-8 IO fails with .type: : .type ( addr u -- ) @@ -232,6 +232,7 @@ Variable icon-tmp Variable do-size Variable do-icon +Variable do-expand Defer parse-line @@ -288,16 +289,19 @@ Defer parse-line : link-warn? ( -- ) \ local links only link $@ ': scan nip ?EXIT - link $@ '# $split 2drop r/o open-file nip IF - s" Dead Link '" stderr write-file throw - link $@ stderr write-file throw - s\" ' !!!\n" stderr write-file throw - THEN ; + link $@ '# $split 2drop dup IF + r/o open-file nip IF + s" Dead Link '" stderr write-file throw + link $@ stderr write-file throw + s\" ' !!!\n" stderr write-file throw + THEN + ELSE 2drop THEN ; : link-options ( addr u -- addr' u' ) - do-size off do-icon on - over c@ '% = over 0> and IF do-size on 1 /string THEN - over c@ '\ = over 0> and IF do-icon off 1 /string THEN ; + do-size off do-icon on do-expand off + over c@ '% = over 0> and IF do-size on 1 /string THEN + over c@ '\ = over 0> and IF do-icon off 1 /string THEN + over c@ '* = over 0> and IF do-expand on 1 /string THEN ; s" Gforth" environment? [IF] s" 0.5.0" str= [IF] : parse-string ( c-addr u -- ) \ core,block @@ -312,10 +316,21 @@ s" Gforth" environment? [IF] s" 0.5.0" s ['] parse-line catch pop-file throw ; [THEN] [THEN] +Variable expand-link +Variable expand-prefix +Variable expand-postfix + +: ?expand ( addr u -- ) expand-link $! + do-expand @ IF + expand-prefix $@ expand-link 0 $ins + expand-postfix $@ expand-link $+! THEN + expand-link $@ ; + : .link ( addr u -- ) dup >r '| -$split dup r> = IF 2swap THEN link-options link $! link $@len 0= IF 2dup link $! ( s" .html" link $+! ) THEN - link $@ href= s" a" tag link-icon? + link $@ ?expand + href= s" a" tag link-icon? parse-string s" a" /tag link-size? link-sig? link-warn? ; : >link ( -- ) '[ parse type '] parse .link ; @@ -388,7 +403,8 @@ wordlist Constant autoreplacements \ paragraph handling : parse-par ( -- ) - BEGIN parse-line+ cr refill WHILE + BEGIN + parse-line+ cr refill WHILE source nip 0= UNTIL THEN ; : par ( addr u -- ) env? @@ -599,7 +615,7 @@ definitions ELSE source nip IF >in off s" p" par THEN THEN ; : parse-section ( -- ) end-sec off BEGIN refill WHILE - section-par end-sec @ UNTIL THEN ; + section-par end-sec @ UNTIL THEN ; \ HTML head @@ -653,6 +669,8 @@ Variable orig-date bl sword orig-date $! ; : icons bl sword icon-prefix $! ; +: expands '# sword expand-prefix $! bl sword expand-postfix $! ; + icons icons Variable style$