File:  [gforth] / gforth / wf.fs
Revision 1.22: download - view: text, annotated - select for diffs
Sun Dec 7 23:05:30 2003 UTC (15 years, 8 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Added check for -fno-reorder-blocks
Made wf.fs use dd/dl again (margin breaks with Konqueror)

    1: \ wiki forth
    2: 
    3: \ Copyright (C) 2003 Free Software Foundation, Inc.
    4: 
    5: \ This file is part of Gforth.
    6: 
    7: \ Gforth is free software; you can redistribute it and/or
    8: \ modify it under the terms of the GNU General Public License
    9: \ as published by the Free Software Foundation; either version 2
   10: \ of the License, or (at your option) any later version.
   11: 
   12: \ This program is distributed in the hope that it will be useful,
   13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: \ GNU General Public License for more details.
   16: 
   17: \ You should have received a copy of the GNU General Public License
   18: \ along with this program; if not, write to the Free Software
   19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21: require string.fs
   22: 
   23: : -scan ( addr u char -- addr' u' )
   24:   >r  BEGIN  dup  WHILE  1- 2dup + c@ r@ =  UNTIL  THEN
   25:   rdrop ;
   26: : -$split ( addr u char -- addr1 u1 addr2 u2 )
   27:   >r 2dup r@ -scan 2dup + c@ r> = negate over + >r
   28:   2swap r> /string ;
   29: 
   30: \ tag handling
   31: 
   32: : .' '' parse postpone SLiteral postpone type ; immediate
   33: : s' '' parse postpone SLiteral ; immediate
   34: 
   35: Variable indentlevel
   36: Variable tag-option
   37: s" " tag-option $!
   38: 
   39: : tag ( addr u -- ) '< emit type tag-option $@ type '> emit
   40:     s" " tag-option $! ;
   41: : tag/ ( addr u -- )  s"  /" tag-option $+! tag ;
   42: : /tag ( addr u -- ) '< emit '/ emit type '> emit ;
   43: : tagged ( addr1 u1 addr2 u2 -- )  2dup 2>r tag type 2r> /tag ;
   44: 
   45: : opt ( addr u opt u -- )  s"  " tag-option $+!
   46:     tag-option $+! s' ="' tag-option $+! tag-option $+!
   47:     s' "' tag-option $+! ;
   48: : href= ( addr u -- )  s" href" opt ;
   49: : id= ( addr u -- )  s" id" opt ;
   50: : src=  ( addr u -- )  s" src" opt ;
   51: : alt=  ( addr u -- )  s" alt" opt ;
   52: : width=  ( addr u -- )  s" width" opt ;
   53: : height=  ( addr u -- )  s" height" opt ;
   54: : align= ( addr u -- ) s" align" opt ;
   55: : class= ( addr u -- ) s" class" opt ;
   56: : indent= ( -- )
   57:     indentlevel @ 0 <# #S 'p hold #> class= ;
   58: : mailto: ( addr u -- ) s'  href="mailto:' tag-option $+!
   59:     tag-option $+! s' "' tag-option $+! ;
   60: 
   61: \ environment handling
   62: 
   63: Variable end-sec
   64: Variable oldenv
   65: Variable envs 30 0 [DO] 0 , [LOOP]
   66: 
   67: : env$ ( -- addr ) envs dup @ 1+ cells + ;
   68: : env ( addr u -- ) env$ $! ;
   69: : env? ( -- ) envs @ oldenv @
   70:     2dup > IF  env$ $@ tag  THEN
   71:     2dup < IF  env$ cell+ $@ /tag  env$ cell+ $off  THEN
   72:     drop oldenv ! ;
   73: : +env  1 envs +! ;
   74: : -env end-sec @ envs @ 2 > or  IF  -1 envs +! env?  THEN ;
   75: : -envs envs @ 0 ?DO  -env cr  LOOP ;
   76: : >env ( addr u -- ) +env env env? ;
   77: 
   78: \ alignment
   79: 
   80: Variable table-format
   81: Variable table#
   82: Variable table-start
   83: 
   84: : >align ( c -- )
   85:     CASE
   86: 	'l OF  s" left"      class=  ENDOF
   87: 	'r OF  s" right"     class=  ENDOF
   88: 	'c OF  s" center"    class=  ENDOF
   89: 	'< OF  s" left"      class=  ENDOF
   90: 	'> OF  s" right"     class=  ENDOF
   91: 	'= OF  s" center"    class=  ENDOF
   92: 	'~ OF  s" absmiddle" class=  ENDOF
   93:     ENDCASE ;
   94: 
   95: : >talign ( c -- )
   96:     CASE
   97: 	'l OF  s" left"   align=  ENDOF
   98: 	'r OF  s" right"  align=  ENDOF
   99: 	'c OF  s" center" align=  ENDOF
  100: 	'< OF  s" left"   align=  ENDOF
  101: 	'> OF  s" right"  align=  ENDOF
  102: 	'= OF  s" center" align=  ENDOF
  103: 	digit? IF  0 <# #S #> s" rowspan" opt
  104: 	    table# @ 1+ table-start ! THEN 0
  105:     ENDCASE ;
  106: 
  107: : >border ( c -- )
  108:     case
  109: 	'- of  s" border0" class= endof
  110: 	'+ of  s" border1" class= endof
  111:     endcase ;
  112: 
  113: \ image handling
  114: 
  115: Create imgbuf $20 allot
  116: 
  117: Create pngsig $89 c, $50 c, $4E c, $47 c, $0D c, $0A c, $1A c, $0A c,
  118: Create jfif   $FF c, $D8 c, $FF c, $E0 c, $00 c, $10 c, $4A c, $46 c,
  119:               $49 c, $46 c,
  120: 
  121: : b@ ( addr -- x )   0 swap 4 bounds ?DO  8 lshift I c@ +  LOOP ;
  122: : bw@ ( addr -- x )  0 swap 2 bounds ?DO  8 lshift I c@ +  LOOP ;
  123: 
  124: : gif? ( -- flag )
  125:     s" GIF89a" imgbuf over str=
  126:     s" GIF87a" imgbuf over str= or ;
  127: : gif-size ( -- w h )
  128:     imgbuf 8 + c@ imgbuf 9 + c@ 8 lshift +
  129:     imgbuf 6 + c@ imgbuf 7 + c@ 8 lshift + ;
  130: 
  131: : png? ( -- flag )
  132:     pngsig 8 imgbuf over str= ;
  133: : png-size ( -- w h )
  134:     imgbuf $14 + b@ imgbuf $10 + b@ ;
  135: 
  136: : jpg? ( -- flag )
  137:     jfif 10 imgbuf over str= ;
  138: : jpg-size ( fd -- w h )  >r
  139:     2.  BEGIN
  140: 	2dup r@ reposition-file throw
  141: 	imgbuf $10 r@ read-file throw 0<>
  142: 	imgbuf bw@ $FFC0 $FFD0 within 0= and  WHILE
  143: 	imgbuf 2 + bw@ 2 + 0 d+  REPEAT
  144:     2drop imgbuf 5 + bw@ imgbuf 7 + bw@  rdrop ;
  145: 
  146: : img-size ( fd -- w h )  >r
  147:     gif? IF  gif-size  rdrop EXIT  THEN
  148:     jpg? IF  r> jpg-size  EXIT  THEN
  149:     png? IF  png-size  rdrop EXIT  THEN
  150:     0 0 ;
  151: 
  152: : .img-size ( addr u -- )
  153:     r/o open-file IF  drop  EXIT  THEN  >r
  154:     imgbuf $20 r@ read-file throw drop
  155:     r@ img-size
  156:     r> close-file throw
  157:     ?dup IF  0 <# #S #> width=   THEN
  158:     ?dup IF  0 <# #S #> height=  THEN ;
  159: 
  160: \ link creation
  161: 
  162: Variable link
  163: Variable link-sig
  164: Variable link-suffix
  165: Variable iconpath
  166: 
  167: Variable do-size
  168: Variable do-icon
  169: 
  170: Defer parse-line
  171: 
  172: : .img ( addr u -- ) dup >r '| -$split  dup r> = IF  2swap  THEN 
  173:     dup IF  2swap alt=  ELSE  2drop  THEN
  174:     tag-option $@len >r over c@ >align  tag-option $@len r> = 1+ /string
  175:     tag-option $@len >r over c@ >border tag-option $@len r> = 1+ /string
  176:     2dup .img-size src= s" img" tag/ ;
  177: : >img ( -- )   '{ parse type '} parse .img ;
  178: 
  179: : alt-suffix ( -- )
  180:     link-suffix $@len 2 - link-suffix $!len
  181:     s" [" link-suffix 0 $ins
  182:     s" ]" link-suffix $+!
  183:     link-suffix $@ alt= ;
  184: 
  185: : get-icon ( addr u -- )  iconpath @ IF  2drop  EXIT  THEN
  186:     link-suffix $! s" .*" link-suffix $+!
  187:     s" icons" open-dir throw >r
  188:     BEGIN
  189: 	pad $100 r@ read-dir throw  WHILE
  190: 	pad swap 2dup link-suffix $@ filename-match
  191: 	IF  s" icons/" iconpath $! iconpath $+!
  192: 	    iconpath $@ 2dup .img-size src= '- >border
  193: 	    alt-suffix  s" img" tag/ true
  194: 	ELSE  2drop  false  THEN
  195:     UNTIL  ELSE  drop  THEN
  196:     r> close-dir throw ;
  197: 
  198: : link-icon? ( -- )  do-icon @ 0= ?EXIT
  199:     iconpath @  IF  iconpath $off  THEN
  200:     link $@ + 1- c@ '/ = IF  s" index.html"  ELSE  link $@  THEN
  201:     '# $split 2drop
  202:     BEGIN  '. $split 2swap 2drop dup  WHILE
  203: 	2dup get-icon  REPEAT  2drop ;
  204: 
  205: : link-size? ( -- )  do-size @ 0= ?EXIT
  206:     link $@ r/o open-file IF  drop  EXIT  THEN >r
  207:     r@ file-size throw $400 um/mod nip ."  (" 0 u.r ." k)"
  208:     r> close-file throw ;
  209: 
  210: : link-sig? ( -- )
  211:     link $@ link-sig $! s" .sig" link-sig $+!
  212:     link-sig $@ r/o open-file IF  drop  EXIT  THEN
  213:     close-file throw
  214:     ."  (" link-sig $@ href= s" a" tag
  215:     s" |-icons/sig.gif" .img ." sig" s" /a" tag ." )" ;
  216: 
  217: : link-options ( addr u -- addr' u' )
  218:     do-size off  do-icon on
  219:     over c@ '% = over 0> and IF  do-size on  1 /string  THEN
  220:     over c@ '\ = over 0> and IF  do-icon off 1 /string  THEN ;
  221: 
  222: s" Gforth" environment? [IF] s" 0.5.0" str= [IF] 
  223: : parse-string ( c-addr u -- ) \ core,block
  224:     s" *evaluated string*" loadfilename>r
  225:     push-file #tib ! >tib !
  226:     >in off blk off loadfile off -1 loadline !
  227:     ['] parse-line catch
  228:     pop-file r>loadfilename throw ;
  229: [ELSE]
  230: : parse-string ( addr u -- )
  231:     evaluate-input cell new-tib #tib ! tib !
  232:     ['] parse-line catch pop-file throw ;
  233: [THEN] [THEN]
  234: 
  235: : .link ( addr u -- ) dup >r '| -$split  dup r> = IF  2swap  THEN 
  236:     link-options link $!
  237:     link $@len 0= IF  2dup link $! ( s" .html" link $+! ) THEN
  238:     link $@ href= s" a" tag link-icon?
  239:     parse-string s" a" /tag link-size? link-sig? ;
  240: : >link ( -- )  '[ parse type '] parse .link ;
  241: 
  242: \ line handling
  243: 
  244: : char? ( -- c )  >in @ char swap >in ! ;
  245: : parse-tag ( addr u char -- )
  246:     >r r@ parse type
  247:     r> parse 2swap tagged ;
  248: 
  249: : .text ( -- ) 	>in @ >r char drop
  250:     source r@ /string >in @ r> - nip
  251:     bounds ?DO  I c@
  252: 	case
  253: 	    '& of  ." &amp;"  endof
  254: 	    '< of  ." &lt;"   endof
  255: 	    dup emit
  256: 	endcase
  257:     LOOP ;
  258: 
  259: Create do-words  $100 0 [DO] ' .text , [LOOP]
  260: 
  261: :noname '( emit 1 >in +! ; '( cells do-words + !
  262: 
  263: : bind-char ( xt -- )  char cells do-words + ! ;
  264: 
  265: : char>tag ( -- ) char >r
  266: :noname bl sword postpone SLiteral r@ postpone Literal
  267:     postpone parse-tag postpone ; r> cells do-words + ! ;
  268: 
  269: : >tag '\ parse type '\ parse tag ;
  270: 
  271: char>tag * b
  272: char>tag _ em
  273: char>tag # code
  274: 
  275: ' >link bind-char [
  276: ' >img  bind-char {
  277: ' >tag  bind-char \
  278: 
  279: : do-word ( char -- )  cells do-words + perform ;
  280: 
  281: : word? ( -- addr u )  >in @ >r bl sword r> >in ! ;
  282: 
  283: wordlist Constant autoreplacements
  284: 
  285: :noname ( -- )
  286:     BEGIN char? do-word source nip >in @ = UNTIL ; is parse-line
  287: 
  288: : parse-line+ ( -- )
  289:     BEGIN
  290: 	word? autoreplacements search-wordlist
  291: 	IF    execute  bl sword 2drop
  292: 	    source >in @ 1- /string drop c@ bl = >in +!
  293: 	ELSE  char? do-word  THEN
  294: 	source nip >in @ = UNTIL ;
  295: 
  296: : parse-to ( char -- ) >r
  297:     BEGIN  char? dup r@ <> WHILE
  298: 	do-word source nip >in @ = UNTIL  ELSE  drop  THEN
  299:     r> parse type ;
  300: 
  301: \ autoreplace
  302: 
  303: : autoreplace ( <[string|url]> -- )
  304:     get-current autoreplacements set-current
  305:     Create set-current
  306:     here 0 , '[ parse 2drop '] parse rot $!
  307:     DOES> $@ .link ;
  308:     
  309: \ paragraph handling
  310: 
  311: : parse-par ( -- )
  312:     BEGIN  parse-line+ cr refill  WHILE
  313: 	source nip 0= UNTIL  THEN ;
  314: 
  315: : par ( addr u -- ) env? indent=
  316:     2dup tag parse-par /tag cr cr ;
  317: : line ( addr u -- ) env? 2dup tag parse-line+ /tag cr cr ;
  318: 
  319: \ scan strings
  320: 
  321: : get-rest ( addr -- ) 0 parse -trailing rot $! ;
  322: Create $lf 1 c, #lf c,
  323: : get-par ( addr -- )  >r  s" " r@ $+!
  324:     BEGIN  0 parse 2dup s" ." str= 0=  WHILE
  325: 	r@ $@len IF  $lf count r@ $+!  THEN  r@ $+!
  326: 	refill 0= UNTIL  ELSE  2drop  THEN
  327:     rdrop ;
  328: 
  329: \ toc handling
  330: 
  331: Variable toc-link
  332: 
  333: : >last ( addr link -- link' )
  334:     BEGIN  dup @  WHILE  @  REPEAT  ! 0 ;
  335: 
  336: Variable create-navs
  337: Variable nav$
  338: Variable nav-name
  339: Variable nav-file
  340: Create nav-buf 0 c,
  341: : nav+ ( char -- )  nav-buf c! nav-buf 1 nav-file $+! ;
  342: 
  343: : >nav ( addr u -- addr' u' )
  344:     nav-name $!  create-navs @ 0=
  345:     IF  s" navigate/nav.scm" r/w create-file throw create-navs !  THEN
  346:     s' (script-fu-nav-file "' nav$ $! nav-name $@ nav$ $+!
  347:     s' " "./navigate/' nav$ $+!  s" " nav-file $!
  348:     nav-name $@ bounds ?DO
  349: 	I c@  dup 'A 'Z 1+ within IF  bl + nav+
  350: 	ELSE  dup 'a 'z 1+ within IF  nav+
  351: 	ELSE  dup '0 '9 1+ within IF  nav+
  352: 	ELSE  dup  bl = swap '- = or IF  '- nav+
  353: 	THEN  THEN  THEN  THEN
  354: 	LOOP
  355:     nav-file $@ nav$ $+! s' .jpg")' nav$ $+!
  356:     nav$ $@ create-navs @ write-line throw
  357:     s" [" nav$ $! nav-name $@ nav$ $+!
  358:     s" |-navigate/" nav$ $+! nav-file $@ nav$ $+! s" .jpg" nav$ $+!
  359:     nav$ $@ ;
  360: 
  361: : toc, ( n -- ) , '| parse >nav here 0 , $! 0 parse here 0 , $! ;
  362: : up-toc   align here toc-link >last , 0 toc, ;
  363: : top-toc  align here toc-link >last , 1 toc, ;
  364: : this-toc align here toc-link >last , 2 toc, ;
  365: : sub-toc  align here toc-link >last , 3 toc, ;
  366: : new-toc  toc-link off ;
  367: 
  368: Variable toc-name
  369: Variable toc-index
  370: 6 Value /toc-line
  371: 
  372: : .toc-entry ( toc flag -- )
  373:     swap cell+ dup @ swap cell+ dup cell+ $@ 2dup href= s" a" tag
  374:     '# scan 1 /string toc-name $@ compare >r
  375:     $@ .img swap
  376:     IF
  377: 	case
  378: 	    2 of  s" ^]|-icons/arrow_up.jpg" .img  endof
  379: 	    3 of
  380: 		r@ 0= IF s" *]|-icons/circle.jpg"
  381: 		    ELSE s" v]|-icons/arrow_down.jpg"  THEN  .img  endof
  382: 	endcase
  383:     ELSE
  384: 	case
  385: 	    0 of  s" ^]|-icons/arrow_up.jpg" .img  endof
  386: 	    1 of  s" >]|-icons/arrow_right.jpg" .img  endof
  387: 	    2 of  s" *]|-icons/circle.jpg" .img  endof
  388: 	    3 of  s" v]|-icons/arrow_down.jpg" .img  endof
  389: 	endcase
  390:     THEN
  391:     s" a" /tag rdrop ." <!--" cr ." -->"
  392:     1 toc-index +! toc-index @ /toc-line mod 0=
  393:     IF  s" br" tag/ THEN ;
  394: 
  395: : print-toc ( -- ) toc-index off cr s" menu" id= s" div" >env cr
  396:     0 parse
  397:     dup 0= IF  toc-name $! 0  ELSE
  398: 	toc-name $! toc-name $@ id= s" " s" a" tagged  2
  399:     THEN  >r
  400:     toc-link  BEGIN  @ dup  WHILE
  401: 	dup cell+ @ 3 = r@ 0= and IF  rdrop 1 >r ( s" br" tag/ cr )  THEN
  402: 	dup cell+ @ r@ >= IF  dup r@ 2 = .toc-entry  THEN
  403: 	dup cell+ @ 2 = r@ 2 = and IF  s" br" tag/ toc-index off THEN
  404:     REPEAT  drop rdrop -env cr ;
  405: 
  406: \ handle global tags
  407: 
  408: : indent ( n -- )
  409:     indentlevel @ over
  410:     indentlevel !
  411:     2dup < IF swap DO  -env -env  LOOP  EXIT THEN
  412:     2dup > IF      DO  s" dl" >env s" dt" >env  LOOP EXIT THEN
  413:     2dup = IF drop IF  -env  s" dt" >env  THEN THEN
  414: ;
  415: : +indent ( -- )
  416:     indentlevel @ IF  -env s" dd" >env  THEN
  417: ;
  418: 
  419: wordlist constant longtags
  420: 
  421: Variable divs
  422: 
  423: longtags set-current
  424: 
  425: : --- 0 indent cr s" hr" tag/ cr +indent ;
  426: : *   1 indent s" h1" line +indent ;
  427: : **  1 indent s" h2" line +indent ;
  428: : *** 2 indent s" h3" line +indent ;
  429: : -- 0 indent cr print-toc ;
  430: : && ( -- ) divs @ IF  -env  THEN  +env
  431:     0 parse id= s" div" env  divs on ;
  432: : - s" ul" env s" li" par ;
  433: : + s" ol" env s" li" par ;
  434: : << +env ;
  435: : <* s" center" class= s" p" >env ;
  436: : <red  s" #ff0000" s" color" opt s" font" >env ;
  437: : red> -env ;
  438: : >> -env ;
  439: : *> -env ;
  440: : :: interpret ;
  441: : . end-sec on 0 indent ;
  442: : :code indent= s" pre" >env
  443:     BEGIN  source >in @ /string type cr refill  WHILE
  444: 	source s" :endcode" str= UNTIL  THEN
  445:   -env ;
  446: : \ postpone \ ;
  447: 
  448: definitions
  449:     
  450: \ Table
  451: 
  452: : |tag  table-format $@ table# @ /string drop c@ >talign
  453:     >env  1 table# +! ;
  454: : |d  table# @ table-start @ > IF  -env  THEN  s" td" |tag ;
  455: : |h  table# @ table-start @ > IF  -env  THEN  s" th" |tag ;
  456: : |line  s" tr" >env  table-start @ table# ! ;
  457: : line|  -env -env cr ;
  458: 
  459: : next-char ( -- char )  source drop >in @ + c@ ;
  460: 
  461: longtags set-current
  462: 
  463: : <| bl sword table-format $! table-start off bl sword
  464:     dup IF  s" border" opt  ELSE  2drop  THEN s" table" >env ;
  465: : |> -env -env cr cr ;
  466: : +| |line
  467:     BEGIN
  468: 	|h '| parse-to next-char '+ =  UNTIL line| ;
  469: : -| |line
  470:     BEGIN
  471: 	|d '| parse-to next-char '- =  UNTIL line| ;
  472: 
  473: definitions
  474: 
  475: \ parse a section
  476: 
  477: : section-line ( -- )  >in off
  478:     bl sword longtags search-wordlist
  479:     IF    execute
  480:     ELSE  source nip IF  >in off s" p" par  THEN  THEN ;
  481: : refill-loop ( -- )  end-sec off
  482:     BEGIN  refill  WHILE
  483: 	section-line end-sec @ UNTIL  THEN ;
  484: : parse-section ( -- )
  485:     refill-loop ;
  486: 
  487: \ HTML head
  488: 
  489: Variable css-file
  490: 
  491: : .title ( addr u -- )
  492:     .' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' cr
  493:     s" html" >env s" head" >env cr
  494:     s" Content-Type" s" http-equiv" opt
  495:     s" text/xhtml; charset=iso-8859-1" s" content" opt
  496:     s" meta" tag/
  497:     css-file $@len IF
  498: 	s" StyleSheet" s" rel" opt
  499: 	css-file $@ href=
  500: 	s" text/css" s" type" opt s" link" tag/
  501:     THEN
  502:     s" title" tagged cr
  503:     -env ;
  504: 
  505: \ HTML trailer
  506: 
  507: Variable mail
  508: Variable mail-name
  509: Variable orig-date
  510: 
  511: : .lastmod
  512:     ." Last modified: " time&date rot 0 u.r swap 1-
  513:     s" janfebmaraprmayjunjulaugsepoctnovdec" rot 3 * /string 3 min type
  514:     0 u.r ;
  515: 
  516: : .trailer
  517:     s" center" class= s" address" >env
  518:     orig-date @ IF  ." Created " orig-date $@ type ." . "  THEN
  519:     .lastmod
  520:  ."  by "
  521:     s" Mail|icons/mail.gif" .img mail $@ mailto: mail-name $@ s" a" tagged
  522:     -envs ;
  523: 
  524: \ top word
  525: 
  526: : parse" ( -- addr u ) '" parse 2drop '" parse ;
  527: 
  528: : maintainer ( -- )
  529:     bl sword mail $! parse" mail-name $! ;
  530: : created ( -- )
  531:     bl sword orig-date $! ;
  532: 
  533: Variable style$
  534: : style> style$ @ 0= IF  s" " style$ $!  THEN  style$ $@ tag-option $! ;
  535: : >style tag-option $@ style$ $! s" " tag-option $! ;
  536: 
  537: : style  style> opt >style ;
  538: : background ( -- )  parse" s" background" style ;
  539: : text ( -- )  parse" s" text" style ;
  540:     warnings @ warnings off
  541: : link ( -- )  parse" s" link" style ;
  542:     warnings !
  543: : vlink ( -- ) parse" s" vlink" style ;
  544: : marginheight ( -- ) parse" s" marginheight" style ;
  545: : css ( -- ) parse" css-file $! ;
  546: 
  547: : wf ( -- )
  548:     outfile-id >r
  549:     bl sword r/w create-file throw to outfile-id
  550:     parse" .title
  551:     +env style> s" body" env env?
  552:     ['] parse-section catch .trailer
  553:     outfile-id close-file throw
  554:     r> to outfile-id
  555:     dup 0< IF  throw  ELSE  drop  THEN ;
  556: 
  557: : eval-par ( addr u -- )
  558:   s" wf-temp.wf" r/w create-file throw >r
  559:   r@ write-file r> close-file throw
  560:   push-file s" wf-temp.wf" r/o open-file throw loadfile !
  561:   parse-par parse-section
  562:   loadfile @ close-file swap 2dup or
  563:   pop-file  drop throw throw
  564:   s" wf-temp.wf" delete-file throw ;
  565: 
  566: \ simple text data base
  567: 
  568: Variable last-entry
  569: Variable field#
  570: 
  571: : table: ( xt n -- )  Create , ,  1 field# !
  572:     DOES> 2@ >in @ >r longtags set-current
  573:     Create definitions swap , r> >in !
  574:     here last-entry !
  575:     dup 0 DO  0 ,  LOOP
  576:     1 DO  s" " last-entry @ I cells + $!  LOOP
  577:     last-entry @ get-rest
  578:     DOES> dup cell+ swap perform ;
  579: 
  580: : field:  Create field# @ , 1 field# +!
  581: DOES> @ cells last-entry @ + get-rest ;
  582: : par:  Create field# @ , 1 field# +!
  583: DOES> @ cells last-entry @ + get-par ;
  584: 
  585: : >field  ' >body @ cells postpone Literal postpone + ; immediate

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>