| 1 : |
pazsan
|
1.1
|
\ wiki forth |
| 2 : |
|
|
|
| 3 : |
anton
|
1.41
|
\ Copyright (C) 2003,2004,2005 Free Software Foundation, Inc. |
| 4 : |
anton
|
1.19
|
|
| 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 : |
pazsan
|
1.1
|
require string.fs |
| 22 : |
|
|
|
| 23 : |
pazsan
|
1.25
|
\ basic stuff |
| 24 : |
|
|
|
| 25 : |
pazsan
|
1.11
|
: -scan ( addr u char -- addr' u' ) |
| 26 : |
|
|
>r BEGIN dup WHILE 1- 2dup + c@ r@ = UNTIL THEN |
| 27 : |
|
|
rdrop ; |
| 28 : |
|
|
: -$split ( addr u char -- addr1 u1 addr2 u2 ) |
| 29 : |
|
|
>r 2dup r@ -scan 2dup + c@ r> = negate over + >r |
| 30 : |
|
|
2swap r> /string ; |
| 31 : |
pazsan
|
1.23
|
: parse" ( -- addr u ) '" parse 2drop '" parse ; |
| 32 : |
pazsan
|
1.1
|
: .' '' parse postpone SLiteral postpone type ; immediate |
| 33 : |
pazsan
|
1.3
|
: s' '' parse postpone SLiteral ; immediate |
| 34 : |
pazsan
|
1.1
|
|
| 35 : |
pazsan
|
1.25
|
\ character recoding |
| 36 : |
pazsan
|
1.3
|
|
| 37 : |
pazsan
|
1.31
|
[IFDEF] maxascii $100 to maxascii 8-bit-io [THEN] |
| 38 : |
pazsan
|
1.29
|
\ UTF-8 IO fails with .type: |
| 39 : |
|
|
|
| 40 : |
pazsan
|
1.24
|
: .type ( addr u -- ) |
| 41 : |
|
|
bounds ?DO I c@ |
| 42 : |
|
|
case |
| 43 : |
|
|
'& of ." &" endof |
| 44 : |
|
|
'< of ." <" endof |
| 45 : |
pazsan
|
1.39
|
\ '¤ of ." €" endof |
| 46 : |
pazsan
|
1.24
|
dup emit |
| 47 : |
|
|
endcase |
| 48 : |
|
|
LOOP ; |
| 49 : |
|
|
|
| 50 : |
pazsan
|
1.25
|
\ tag handling |
| 51 : |
|
|
|
| 52 : |
|
|
Variable indentlevel |
| 53 : |
|
|
Variable tag-option |
| 54 : |
pazsan
|
1.29
|
Variable tag-class |
| 55 : |
pazsan
|
1.35
|
Variable default-class |
| 56 : |
pazsan
|
1.25
|
s" " tag-option $! |
| 57 : |
pazsan
|
1.29
|
s" " tag-class $! |
| 58 : |
pazsan
|
1.35
|
s" " default-class $! |
| 59 : |
pazsan
|
1.25
|
|
| 60 : |
pazsan
|
1.29
|
: tag ( addr u -- ) '< emit type |
| 61 : |
|
|
tag-class $@len IF .\" class=\"" tag-class $@ type '" emit THEN |
| 62 : |
|
|
tag-option $@ type |
| 63 : |
|
|
'> emit |
| 64 : |
pazsan
|
1.35
|
s" " tag-option $! default-class $@ tag-class $! ; |
| 65 : |
pazsan
|
1.21
|
: tag/ ( addr u -- ) s" /" tag-option $+! tag ; |
| 66 : |
pazsan
|
1.1
|
: /tag ( addr u -- ) '< emit '/ emit type '> emit ; |
| 67 : |
pazsan
|
1.24
|
: tagged ( addr1 u1 addr2 u2 -- ) 2dup 2>r tag .type 2r> /tag ; |
| 68 : |
pazsan
|
1.1
|
|
| 69 : |
pazsan
|
1.3
|
: opt ( addr u opt u -- ) s" " tag-option $+! |
| 70 : |
|
|
tag-option $+! s' ="' tag-option $+! tag-option $+! |
| 71 : |
|
|
s' "' tag-option $+! ; |
| 72 : |
pazsan
|
1.25
|
: n>string ( n -- addr u ) 0 <# #S #> ; |
| 73 : |
pazsan
|
1.29
|
: xy>string ( x y -- ) swap 0 <# #S 'x hold 2drop 0 #S 's hold #> ; |
| 74 : |
pazsan
|
1.25
|
: opt# ( n opt u -- ) rot n>string 2swap opt ; |
| 75 : |
pazsan
|
1.3
|
: href= ( addr u -- ) s" href" opt ; |
| 76 : |
pazsan
|
1.21
|
: id= ( addr u -- ) s" id" opt ; |
| 77 : |
pazsan
|
1.3
|
: src= ( addr u -- ) s" src" opt ; |
| 78 : |
pazsan
|
1.4
|
: alt= ( addr u -- ) s" alt" opt ; |
| 79 : |
pazsan
|
1.25
|
: width= ( n -- ) s" width" opt# ; |
| 80 : |
|
|
: height= ( n -- ) s" height" opt# ; |
| 81 : |
pazsan
|
1.3
|
: align= ( addr u -- ) s" align" opt ; |
| 82 : |
pazsan
|
1.29
|
: class= ( addr u -- ) |
| 83 : |
|
|
tag-class $@len IF s" " tag-class $+! THEN |
| 84 : |
|
|
tag-class $+! ; |
| 85 : |
pazsan
|
1.35
|
: dclass= ( addr u -- ) 2dup class= |
| 86 : |
|
|
default-class $! ; |
| 87 : |
pazsan
|
1.21
|
: indent= ( -- ) |
| 88 : |
|
|
indentlevel @ 0 <# #S 'p hold #> class= ; |
| 89 : |
pazsan
|
1.3
|
: mailto: ( addr u -- ) s' href="mailto:' tag-option $+! |
| 90 : |
|
|
tag-option $+! s' "' tag-option $+! ; |
| 91 : |
|
|
|
| 92 : |
pazsan
|
1.1
|
\ environment handling |
| 93 : |
|
|
|
| 94 : |
pazsan
|
1.11
|
Variable end-sec |
| 95 : |
pazsan
|
1.1
|
Variable oldenv |
| 96 : |
pazsan
|
1.10
|
Variable envs 30 0 [DO] 0 , [LOOP] |
| 97 : |
pazsan
|
1.1
|
|
| 98 : |
|
|
: env$ ( -- addr ) envs dup @ 1+ cells + ; |
| 99 : |
|
|
: env ( addr u -- ) env$ $! ; |
| 100 : |
pazsan
|
1.34
|
: env? ( -- ) envs @ oldenv @ over oldenv ! |
| 101 : |
pazsan
|
1.1
|
2dup > IF env$ $@ tag THEN |
| 102 : |
|
|
2dup < IF env$ cell+ $@ /tag env$ cell+ $off THEN |
| 103 : |
pazsan
|
1.34
|
2drop ; |
| 104 : |
pazsan
|
1.1
|
: +env 1 envs +! ; |
| 105 : |
pazsan
|
1.34
|
: -env end-sec @ envs @ 1 > or IF -1 envs +! env? THEN ; |
| 106 : |
pazsan
|
1.1
|
: -envs envs @ 0 ?DO -env cr LOOP ; |
| 107 : |
pazsan
|
1.34
|
: -tenvs envs @ 1 ?DO -env cr LOOP ; |
| 108 : |
pazsan
|
1.2
|
: >env ( addr u -- ) +env env env? ; |
| 109 : |
pazsan
|
1.1
|
|
| 110 : |
pazsan
|
1.6
|
\ alignment |
| 111 : |
|
|
|
| 112 : |
pazsan
|
1.12
|
Variable table-format |
| 113 : |
|
|
Variable table# |
| 114 : |
pazsan
|
1.25
|
Create table-starts &10 0 [DO] 0 c, 0 c, [LOOP] |
| 115 : |
|
|
Variable taligned |
| 116 : |
pazsan
|
1.12
|
|
| 117 : |
pazsan
|
1.6
|
: >align ( c -- ) |
| 118 : |
|
|
CASE |
| 119 : |
pazsan
|
1.21
|
'l OF s" left" class= ENDOF |
| 120 : |
|
|
'r OF s" right" class= ENDOF |
| 121 : |
pazsan
|
1.25
|
'c OF s" center" class= ENDOF |
| 122 : |
pazsan
|
1.21
|
'< OF s" left" class= ENDOF |
| 123 : |
|
|
'> OF s" right" class= ENDOF |
| 124 : |
pazsan
|
1.25
|
'= OF s" center" class= ENDOF |
| 125 : |
|
|
'~ OF s" middle" class= ENDOF |
| 126 : |
pazsan
|
1.13
|
ENDCASE ; |
| 127 : |
|
|
|
| 128 : |
|
|
: >talign ( c -- ) |
| 129 : |
|
|
CASE |
| 130 : |
pazsan
|
1.6
|
'l OF s" left" align= ENDOF |
| 131 : |
|
|
'r OF s" right" align= ENDOF |
| 132 : |
|
|
'c OF s" center" align= ENDOF |
| 133 : |
|
|
'< OF s" left" align= ENDOF |
| 134 : |
|
|
'> OF s" right" align= ENDOF |
| 135 : |
pazsan
|
1.11
|
'= OF s" center" align= ENDOF |
| 136 : |
pazsan
|
1.25
|
ENDCASE taligned on ; |
| 137 : |
pazsan
|
1.6
|
|
| 138 : |
pazsan
|
1.10
|
: >border ( c -- ) |
| 139 : |
|
|
case |
| 140 : |
pazsan
|
1.21
|
'- of s" border0" class= endof |
| 141 : |
|
|
'+ of s" border1" class= endof |
| 142 : |
pazsan
|
1.10
|
endcase ; |
| 143 : |
|
|
|
| 144 : |
pazsan
|
1.7
|
\ image handling |
| 145 : |
|
|
|
| 146 : |
pazsan
|
1.29
|
wordlist Constant img-sizes |
| 147 : |
|
|
|
| 148 : |
pazsan
|
1.7
|
Create imgbuf $20 allot |
| 149 : |
|
|
|
| 150 : |
|
|
Create pngsig $89 c, $50 c, $4E c, $47 c, $0D c, $0A c, $1A c, $0A c, |
| 151 : |
|
|
Create jfif $FF c, $D8 c, $FF c, $E0 c, $00 c, $10 c, $4A c, $46 c, |
| 152 : |
|
|
$49 c, $46 c, |
| 153 : |
|
|
|
| 154 : |
|
|
: b@ ( addr -- x ) 0 swap 4 bounds ?DO 8 lshift I c@ + LOOP ; |
| 155 : |
|
|
: bw@ ( addr -- x ) 0 swap 2 bounds ?DO 8 lshift I c@ + LOOP ; |
| 156 : |
|
|
|
| 157 : |
|
|
: gif? ( -- flag ) |
| 158 : |
anton
|
1.16
|
s" GIF89a" imgbuf over str= |
| 159 : |
|
|
s" GIF87a" imgbuf over str= or ; |
| 160 : |
pazsan
|
1.7
|
: gif-size ( -- w h ) |
| 161 : |
pazsan
|
1.10
|
imgbuf 8 + c@ imgbuf 9 + c@ 8 lshift + |
| 162 : |
|
|
imgbuf 6 + c@ imgbuf 7 + c@ 8 lshift + ; |
| 163 : |
pazsan
|
1.7
|
|
| 164 : |
|
|
: png? ( -- flag ) |
| 165 : |
anton
|
1.16
|
pngsig 8 imgbuf over str= ; |
| 166 : |
pazsan
|
1.7
|
: png-size ( -- w h ) |
| 167 : |
pazsan
|
1.10
|
imgbuf $14 + b@ imgbuf $10 + b@ ; |
| 168 : |
pazsan
|
1.7
|
|
| 169 : |
|
|
: jpg? ( -- flag ) |
| 170 : |
anton
|
1.16
|
jfif 10 imgbuf over str= ; |
| 171 : |
pazsan
|
1.7
|
: jpg-size ( fd -- w h ) >r |
| 172 : |
|
|
2. BEGIN |
| 173 : |
|
|
2dup r@ reposition-file throw |
| 174 : |
|
|
imgbuf $10 r@ read-file throw 0<> |
| 175 : |
pazsan
|
1.8
|
imgbuf bw@ $FFC0 $FFD0 within 0= and WHILE |
| 176 : |
pazsan
|
1.7
|
imgbuf 2 + bw@ 2 + 0 d+ REPEAT |
| 177 : |
|
|
2drop imgbuf 5 + bw@ imgbuf 7 + bw@ rdrop ; |
| 178 : |
|
|
|
| 179 : |
|
|
: img-size ( fd -- w h ) >r |
| 180 : |
|
|
gif? IF gif-size rdrop EXIT THEN |
| 181 : |
|
|
jpg? IF r> jpg-size EXIT THEN |
| 182 : |
|
|
png? IF png-size rdrop EXIT THEN |
| 183 : |
pazsan
|
1.28
|
0 0 rdrop ; |
| 184 : |
pazsan
|
1.7
|
|
| 185 : |
pazsan
|
1.29
|
3 set-precision |
| 186 : |
|
|
|
| 187 : |
|
|
: f.size ( r -- ) |
| 188 : |
|
|
f$ dup >r 0<= |
| 189 : |
|
|
IF '0 emit |
| 190 : |
|
|
ELSE scratch r@ min type r@ precision - zeros THEN |
| 191 : |
pazsan
|
1.34
|
r@ negate zeros |
| 192 : |
|
|
scratch r> 0 max /string 0 max -zeros |
| 193 : |
|
|
dup IF '. emit THEN type ; |
| 194 : |
pazsan
|
1.29
|
|
| 195 : |
pazsan
|
1.37
|
12.9e FConstant pixels |
| 196 : |
pazsan
|
1.39
|
FVariable factor 1e factor f! |
| 197 : |
pazsan
|
1.37
|
|
| 198 : |
pazsan
|
1.29
|
: size-does> ( -- ) DOES> ( -- ) |
| 199 : |
|
|
." img." dup body> >name .name |
| 200 : |
|
|
2@ ." { width: " |
| 201 : |
pazsan
|
1.37
|
s>d d>f pixels f/ f.size ." em; height: " |
| 202 : |
|
|
s>d d>f pixels f/ f.size ." em; }" cr ; |
| 203 : |
pazsan
|
1.29
|
|
| 204 : |
|
|
: size-css ( file< > -- ) |
| 205 : |
|
|
outfile-id >r |
| 206 : |
|
|
bl sword r/w create-file throw to outfile-id |
| 207 : |
|
|
img-sizes wordlist-id |
| 208 : |
|
|
BEGIN @ dup WHILE |
| 209 : |
|
|
dup name>int execute |
| 210 : |
|
|
REPEAT drop |
| 211 : |
|
|
outfile-id close-file throw |
| 212 : |
|
|
r> to outfile-id |
| 213 : |
|
|
dup 0< IF throw ELSE drop THEN ; |
| 214 : |
|
|
|
| 215 : |
|
|
: size-class ( x y addr u -- x y ) |
| 216 : |
|
|
2dup class= |
| 217 : |
|
|
2dup img-sizes search-wordlist IF drop 2drop |
| 218 : |
|
|
ELSE |
| 219 : |
|
|
get-current >r img-sizes set-current |
| 220 : |
pazsan
|
1.39
|
nextname Create 2dup |
| 221 : |
|
|
s>d d>f factor f@ f* f>d d>s , |
| 222 : |
|
|
s>d d>f factor f@ f* f>d d>s , |
| 223 : |
|
|
size-does> |
| 224 : |
pazsan
|
1.29
|
r> set-current |
| 225 : |
|
|
THEN ; |
| 226 : |
|
|
|
| 227 : |
pazsan
|
1.7
|
: .img-size ( addr u -- ) |
| 228 : |
pazsan
|
1.10
|
r/o open-file IF drop EXIT THEN >r |
| 229 : |
pazsan
|
1.7
|
imgbuf $20 r@ read-file throw drop |
| 230 : |
|
|
r@ img-size |
| 231 : |
|
|
r> close-file throw |
| 232 : |
pazsan
|
1.29
|
2dup or IF 2dup xy>string size-class THEN |
| 233 : |
pazsan
|
1.25
|
?dup IF width= THEN |
| 234 : |
pazsan
|
1.29
|
?dup IF height= THEN |
| 235 : |
|
|
; |
| 236 : |
pazsan
|
1.7
|
|
| 237 : |
pazsan
|
1.1
|
\ link creation |
| 238 : |
|
|
|
| 239 : |
|
|
Variable link |
| 240 : |
pazsan
|
1.10
|
Variable link-sig |
| 241 : |
pazsan
|
1.1
|
Variable link-suffix |
| 242 : |
pazsan
|
1.3
|
Variable iconpath |
| 243 : |
pazsan
|
1.27
|
Variable icon-prefix |
| 244 : |
|
|
Variable icon-tmp |
| 245 : |
pazsan
|
1.1
|
|
| 246 : |
pazsan
|
1.2
|
Variable do-size |
| 247 : |
pazsan
|
1.9
|
Variable do-icon |
| 248 : |
pazsan
|
1.32
|
Variable do-expand |
| 249 : |
pazsan
|
1.2
|
|
| 250 : |
pazsan
|
1.8
|
Defer parse-line |
| 251 : |
|
|
|
| 252 : |
pazsan
|
1.27
|
: .img ( addr u -- ) |
| 253 : |
|
|
dup >r '@ -$split dup r> = IF 2swap 2drop |
| 254 : |
|
|
ELSE 2swap icon-tmp $! icon-prefix $@ icon-tmp $+! icon-tmp $+! |
| 255 : |
|
|
icon-tmp $@ THEN |
| 256 : |
|
|
dup >r '| -$split dup r> = IF 2swap THEN |
| 257 : |
pazsan
|
1.11
|
dup IF 2swap alt= ELSE 2drop THEN |
| 258 : |
pazsan
|
1.29
|
tag-class $@len >r over c@ >align tag-class $@len r> = 1+ /string |
| 259 : |
|
|
tag-class $@len >r over c@ >border tag-class $@len r> = 1+ /string |
| 260 : |
pazsan
|
1.21
|
2dup .img-size src= s" img" tag/ ; |
| 261 : |
pazsan
|
1.11
|
: >img ( -- ) '{ parse type '} parse .img ; |
| 262 : |
|
|
|
| 263 : |
pazsan
|
1.7
|
: alt-suffix ( -- ) |
| 264 : |
|
|
link-suffix $@len 2 - link-suffix $!len |
| 265 : |
|
|
s" [" link-suffix 0 $ins |
| 266 : |
|
|
s" ]" link-suffix $+! |
| 267 : |
|
|
link-suffix $@ alt= ; |
| 268 : |
|
|
|
| 269 : |
pazsan
|
1.6
|
: get-icon ( addr u -- ) iconpath @ IF 2drop EXIT THEN |
| 270 : |
|
|
link-suffix $! s" .*" link-suffix $+! |
| 271 : |
pazsan
|
1.27
|
icon-prefix $@ open-dir throw >r |
| 272 : |
pazsan
|
1.1
|
BEGIN |
| 273 : |
|
|
pad $100 r@ read-dir throw WHILE |
| 274 : |
|
|
pad swap 2dup link-suffix $@ filename-match |
| 275 : |
pazsan
|
1.27
|
IF icon-prefix $@ iconpath $! s" /" iconpath $+! iconpath $+! |
| 276 : |
pazsan
|
1.10
|
iconpath $@ 2dup .img-size src= '- >border |
| 277 : |
pazsan
|
1.21
|
alt-suffix s" img" tag/ true |
| 278 : |
pazsan
|
1.1
|
ELSE 2drop false THEN |
| 279 : |
pazsan
|
1.6
|
UNTIL ELSE drop THEN |
| 280 : |
pazsan
|
1.1
|
r> close-dir throw ; |
| 281 : |
|
|
|
| 282 : |
pazsan
|
1.9
|
: link-icon? ( -- ) do-icon @ 0= ?EXIT |
| 283 : |
|
|
iconpath @ IF iconpath $off THEN |
| 284 : |
|
|
link $@ + 1- c@ '/ = IF s" index.html" ELSE link $@ THEN |
| 285 : |
pazsan
|
1.20
|
'# $split 2drop |
| 286 : |
pazsan
|
1.8
|
BEGIN '. $split 2swap 2drop dup WHILE |
| 287 : |
|
|
2dup get-icon REPEAT 2drop ; |
| 288 : |
pazsan
|
1.6
|
|
| 289 : |
pazsan
|
1.2
|
: link-size? ( -- ) do-size @ 0= ?EXIT |
| 290 : |
pazsan
|
1.1
|
link $@ r/o open-file IF drop EXIT THEN >r |
| 291 : |
pazsan
|
1.25
|
r@ file-size throw $400 um/mod nip |
| 292 : |
|
|
dup $800 < IF ." (" 0 u.r ." k)" |
| 293 : |
|
|
ELSE $400 / ." (" 0 u.r ." M)" THEN |
| 294 : |
pazsan
|
1.1
|
r> close-file throw ; |
| 295 : |
|
|
|
| 296 : |
pazsan
|
1.10
|
: link-sig? ( -- ) |
| 297 : |
|
|
link $@ link-sig $! s" .sig" link-sig $+! |
| 298 : |
|
|
link-sig $@ r/o open-file IF drop EXIT THEN |
| 299 : |
|
|
close-file throw |
| 300 : |
|
|
." (" link-sig $@ href= s" a" tag |
| 301 : |
pazsan
|
1.27
|
s" |-@/sig.gif" .img ." sig" s" /a" tag ." )" ; |
| 302 : |
pazsan
|
1.10
|
|
| 303 : |
pazsan
|
1.25
|
: link-warn? ( -- ) \ local links only |
| 304 : |
|
|
link $@ ': scan nip ?EXIT |
| 305 : |
pazsan
|
1.33
|
link $@ '# $split 2drop dup IF |
| 306 : |
|
|
r/o open-file nip IF |
| 307 : |
|
|
s" Dead Link '" stderr write-file throw |
| 308 : |
|
|
link $@ stderr write-file throw |
| 309 : |
|
|
s\" ' !!!\n" stderr write-file throw |
| 310 : |
|
|
THEN |
| 311 : |
|
|
ELSE 2drop THEN ; |
| 312 : |
pazsan
|
1.25
|
|
| 313 : |
pazsan
|
1.2
|
: link-options ( addr u -- addr' u' ) |
| 314 : |
pazsan
|
1.32
|
do-size off do-icon on do-expand off |
| 315 : |
|
|
over c@ '% = over 0> and IF do-size on 1 /string THEN |
| 316 : |
|
|
over c@ '\ = over 0> and IF do-icon off 1 /string THEN |
| 317 : |
|
|
over c@ '* = over 0> and IF do-expand on 1 /string THEN ; |
| 318 : |
pazsan
|
1.2
|
|
| 319 : |
anton
|
1.16
|
s" Gforth" environment? [IF] s" 0.5.0" str= [IF] |
| 320 : |
pazsan
|
1.15
|
: parse-string ( c-addr u -- ) \ core,block |
| 321 : |
anton
|
1.18
|
s" *evaluated string*" loadfilename>r |
| 322 : |
pazsan
|
1.15
|
push-file #tib ! >tib ! |
| 323 : |
|
|
>in off blk off loadfile off -1 loadline ! |
| 324 : |
|
|
['] parse-line catch |
| 325 : |
anton
|
1.18
|
pop-file r>loadfilename throw ; |
| 326 : |
pazsan
|
1.15
|
[ELSE] |
| 327 : |
pazsan
|
1.8
|
: parse-string ( addr u -- ) |
| 328 : |
|
|
evaluate-input cell new-tib #tib ! tib ! |
| 329 : |
|
|
['] parse-line catch pop-file throw ; |
| 330 : |
pazsan
|
1.15
|
[THEN] [THEN] |
| 331 : |
pazsan
|
1.8
|
|
| 332 : |
pazsan
|
1.32
|
Variable expand-link |
| 333 : |
|
|
Variable expand-prefix |
| 334 : |
|
|
Variable expand-postfix |
| 335 : |
|
|
|
| 336 : |
|
|
: ?expand ( addr u -- ) expand-link $! |
| 337 : |
|
|
do-expand @ IF |
| 338 : |
|
|
expand-prefix $@ expand-link 0 $ins |
| 339 : |
|
|
expand-postfix $@ expand-link $+! THEN |
| 340 : |
|
|
expand-link $@ ; |
| 341 : |
|
|
|
| 342 : |
pazsan
|
1.11
|
: .link ( addr u -- ) dup >r '| -$split dup r> = IF 2swap THEN |
| 343 : |
pazsan
|
1.2
|
link-options link $! |
| 344 : |
pazsan
|
1.20
|
link $@len 0= IF 2dup link $! ( s" .html" link $+! ) THEN |
| 345 : |
pazsan
|
1.32
|
link $@ ?expand |
| 346 : |
|
|
href= s" a" tag link-icon? |
| 347 : |
pazsan
|
1.25
|
parse-string s" a" /tag link-size? link-sig? link-warn? ; |
| 348 : |
pazsan
|
1.9
|
: >link ( -- ) '[ parse type '] parse .link ; |
| 349 : |
pazsan
|
1.1
|
|
| 350 : |
|
|
\ line handling |
| 351 : |
|
|
|
| 352 : |
pazsan
|
1.4
|
: char? ( -- c ) >in @ char swap >in ! ; |
| 353 : |
pazsan
|
1.24
|
|
| 354 : |
pazsan
|
1.1
|
: parse-tag ( addr u char -- ) |
| 355 : |
pazsan
|
1.24
|
>r r@ parse .type |
| 356 : |
pazsan
|
1.2
|
r> parse 2swap tagged ; |
| 357 : |
pazsan
|
1.1
|
|
| 358 : |
pazsan
|
1.6
|
: .text ( -- ) >in @ >r char drop |
| 359 : |
pazsan
|
1.24
|
source r@ /string >in @ r> - nip .type ; |
| 360 : |
pazsan
|
1.6
|
|
| 361 : |
|
|
Create do-words $100 0 [DO] ' .text , [LOOP] |
| 362 : |
|
|
|
| 363 : |
pazsan
|
1.9
|
:noname '( emit 1 >in +! ; '( cells do-words + ! |
| 364 : |
|
|
|
| 365 : |
pazsan
|
1.6
|
: bind-char ( xt -- ) char cells do-words + ! ; |
| 366 : |
|
|
|
| 367 : |
|
|
: char>tag ( -- ) char >r |
| 368 : |
|
|
:noname bl sword postpone SLiteral r@ postpone Literal |
| 369 : |
|
|
postpone parse-tag postpone ; r> cells do-words + ! ; |
| 370 : |
pazsan
|
1.1
|
|
| 371 : |
pazsan
|
1.12
|
: >tag '\ parse type '\ parse tag ; |
| 372 : |
|
|
|
| 373 : |
pazsan
|
1.6
|
char>tag * b |
| 374 : |
|
|
char>tag _ em |
| 375 : |
|
|
char>tag # code |
| 376 : |
pazsan
|
1.25
|
:noname '~ parse .type '~ parse .type ; '~ cells do-words + ! |
| 377 : |
pazsan
|
1.6
|
|
| 378 : |
pazsan
|
1.9
|
' >link bind-char [ |
| 379 : |
|
|
' >img bind-char { |
| 380 : |
pazsan
|
1.12
|
' >tag bind-char \ |
| 381 : |
pazsan
|
1.6
|
|
| 382 : |
|
|
: do-word ( char -- ) cells do-words + perform ; |
| 383 : |
pazsan
|
1.4
|
|
| 384 : |
pazsan
|
1.9
|
: word? ( -- addr u ) >in @ >r bl sword r> >in ! ; |
| 385 : |
|
|
|
| 386 : |
|
|
wordlist Constant autoreplacements |
| 387 : |
|
|
|
| 388 : |
pazsan
|
1.8
|
:noname ( -- ) |
| 389 : |
pazsan
|
1.9
|
BEGIN char? do-word source nip >in @ = UNTIL ; is parse-line |
| 390 : |
|
|
|
| 391 : |
|
|
: parse-line+ ( -- ) |
| 392 : |
|
|
BEGIN |
| 393 : |
|
|
word? autoreplacements search-wordlist |
| 394 : |
|
|
IF execute bl sword 2drop |
| 395 : |
|
|
source >in @ 1- /string drop c@ bl = >in +! |
| 396 : |
|
|
ELSE char? do-word THEN |
| 397 : |
|
|
source nip >in @ = UNTIL ; |
| 398 : |
pazsan
|
1.4
|
|
| 399 : |
|
|
: parse-to ( char -- ) >r |
| 400 : |
pazsan
|
1.25
|
BEGIN |
| 401 : |
|
|
word? autoreplacements search-wordlist |
| 402 : |
|
|
IF execute bl sword 2drop |
| 403 : |
|
|
source >in @ 1- /string drop c@ bl = >in +! bl true |
| 404 : |
|
|
ELSE char? dup r@ <> THEN WHILE |
| 405 : |
pazsan
|
1.4
|
do-word source nip >in @ = UNTIL ELSE drop THEN |
| 406 : |
|
|
r> parse type ; |
| 407 : |
pazsan
|
1.1
|
|
| 408 : |
pazsan
|
1.9
|
\ autoreplace |
| 409 : |
|
|
|
| 410 : |
|
|
: autoreplace ( <[string|url]> -- ) |
| 411 : |
|
|
get-current autoreplacements set-current |
| 412 : |
|
|
Create set-current |
| 413 : |
|
|
here 0 , '[ parse 2drop '] parse rot $! |
| 414 : |
|
|
DOES> $@ .link ; |
| 415 : |
|
|
|
| 416 : |
pazsan
|
1.1
|
\ paragraph handling |
| 417 : |
|
|
|
| 418 : |
|
|
: parse-par ( -- ) |
| 419 : |
pazsan
|
1.31
|
BEGIN |
| 420 : |
|
|
parse-line+ cr refill WHILE |
| 421 : |
pazsan
|
1.1
|
source nip 0= UNTIL THEN ; |
| 422 : |
|
|
|
| 423 : |
pazsan
|
1.25
|
: par ( addr u -- ) env? |
| 424 : |
pazsan
|
1.21
|
2dup tag parse-par /tag cr cr ; |
| 425 : |
pazsan
|
1.1
|
|
| 426 : |
pazsan
|
1.10
|
\ scan strings |
| 427 : |
|
|
|
| 428 : |
|
|
: get-rest ( addr -- ) 0 parse -trailing rot $! ; |
| 429 : |
|
|
Create $lf 1 c, #lf c, |
| 430 : |
|
|
: get-par ( addr -- ) >r s" " r@ $+! |
| 431 : |
anton
|
1.16
|
BEGIN 0 parse 2dup s" ." str= 0= WHILE |
| 432 : |
pazsan
|
1.10
|
r@ $@len IF $lf count r@ $+! THEN r@ $+! |
| 433 : |
|
|
refill 0= UNTIL ELSE 2drop THEN |
| 434 : |
|
|
rdrop ; |
| 435 : |
|
|
|
| 436 : |
|
|
\ toc handling |
| 437 : |
|
|
|
| 438 : |
|
|
Variable toc-link |
| 439 : |
|
|
|
| 440 : |
|
|
: >last ( addr link -- link' ) |
| 441 : |
|
|
BEGIN dup @ WHILE @ REPEAT ! 0 ; |
| 442 : |
|
|
|
| 443 : |
pazsan
|
1.14
|
Variable create-navs |
| 444 : |
|
|
Variable nav$ |
| 445 : |
|
|
Variable nav-name |
| 446 : |
|
|
Variable nav-file |
| 447 : |
|
|
Create nav-buf 0 c, |
| 448 : |
|
|
: nav+ ( char -- ) nav-buf c! nav-buf 1 nav-file $+! ; |
| 449 : |
|
|
|
| 450 : |
pazsan
|
1.25
|
: filenamize ( addr u -- ) |
| 451 : |
|
|
bounds ?DO |
| 452 : |
|
|
I c@ dup 'A 'Z 1+ within IF bl + nav+ |
| 453 : |
|
|
ELSE dup 'a 'z 1+ within IF nav+ |
| 454 : |
|
|
ELSE dup '0 '9 1+ within IF nav+ |
| 455 : |
|
|
ELSE dup bl = swap '- = or IF '- nav+ |
| 456 : |
|
|
THEN THEN THEN THEN |
| 457 : |
|
|
LOOP ; |
| 458 : |
pazsan
|
1.14
|
: >nav ( addr u -- addr' u' ) |
| 459 : |
|
|
nav-name $! create-navs @ 0= |
| 460 : |
|
|
IF s" navigate/nav.scm" r/w create-file throw create-navs ! THEN |
| 461 : |
|
|
s' (script-fu-nav-file "' nav$ $! nav-name $@ nav$ $+! |
| 462 : |
|
|
s' " "./navigate/' nav$ $+! s" " nav-file $! |
| 463 : |
pazsan
|
1.25
|
nav-name $@ filenamize |
| 464 : |
pazsan
|
1.14
|
nav-file $@ nav$ $+! s' .jpg")' nav$ $+! |
| 465 : |
|
|
nav$ $@ create-navs @ write-line throw |
| 466 : |
|
|
s" [" nav$ $! nav-name $@ nav$ $+! |
| 467 : |
|
|
s" |-navigate/" nav$ $+! nav-file $@ nav$ $+! s" .jpg" nav$ $+! |
| 468 : |
|
|
nav$ $@ ; |
| 469 : |
|
|
|
| 470 : |
|
|
: toc, ( n -- ) , '| parse >nav here 0 , $! 0 parse here 0 , $! ; |
| 471 : |
pazsan
|
1.10
|
: up-toc align here toc-link >last , 0 toc, ; |
| 472 : |
|
|
: top-toc align here toc-link >last , 1 toc, ; |
| 473 : |
|
|
: this-toc align here toc-link >last , 2 toc, ; |
| 474 : |
|
|
: sub-toc align here toc-link >last , 3 toc, ; |
| 475 : |
pazsan
|
1.12
|
: new-toc toc-link off ; |
| 476 : |
pazsan
|
1.10
|
|
| 477 : |
|
|
Variable toc-name |
| 478 : |
pazsan
|
1.22
|
Variable toc-index |
| 479 : |
|
|
6 Value /toc-line |
| 480 : |
pazsan
|
1.36
|
true Value toc-image |
| 481 : |
pazsan
|
1.10
|
|
| 482 : |
|
|
: .toc-entry ( toc flag -- ) |
| 483 : |
pazsan
|
1.36
|
swap cell+ dup @ swap cell+ dup cell+ $@ 2dup href= |
| 484 : |
pazsan
|
1.11
|
'# scan 1 /string toc-name $@ compare >r |
| 485 : |
pazsan
|
1.36
|
$@ toc-image IF s" a" tag .img swap |
| 486 : |
|
|
IF |
| 487 : |
|
|
case |
| 488 : |
|
|
2 of s" ^]|-@/arrow_up.jpg" .img endof |
| 489 : |
|
|
3 of |
| 490 : |
|
|
r@ 0= IF s" *]|-@/circle.jpg" |
| 491 : |
pazsan
|
1.27
|
ELSE s" v]|-@/arrow_down.jpg" THEN .img endof |
| 492 : |
pazsan
|
1.36
|
endcase |
| 493 : |
|
|
ELSE |
| 494 : |
|
|
case |
| 495 : |
|
|
0 of s" ^]|-@/arrow_up.jpg" .img endof |
| 496 : |
|
|
1 of s" >]|-@/arrow_right.jpg" .img endof |
| 497 : |
|
|
2 of s" *]|-@/circle.jpg" .img endof |
| 498 : |
|
|
3 of s" v]|-@/arrow_down.jpg" .img endof |
| 499 : |
|
|
endcase |
| 500 : |
|
|
THEN |
| 501 : |
|
|
s" a" /tag ." <!--" cr ." -->" |
| 502 : |
pazsan
|
1.10
|
ELSE |
| 503 : |
pazsan
|
1.36
|
'[ skip 2dup '| scan nip - 2swap swap |
| 504 : |
|
|
IF |
| 505 : |
|
|
CASE |
| 506 : |
|
|
2 OF s" up" class= ENDOF |
| 507 : |
|
|
3 OF r@ 0= IF s" circle" ELSE s" down" THEN class= ENDOF |
| 508 : |
|
|
ENDCASE |
| 509 : |
|
|
ELSE |
| 510 : |
|
|
CASE |
| 511 : |
|
|
0 OF s" up" class= ENDOF |
| 512 : |
|
|
1 OF s" right" class= ENDOF |
| 513 : |
|
|
2 OF s" circle" class= ENDOF |
| 514 : |
|
|
3 OF s" down" class= ENDOF |
| 515 : |
|
|
ENDCASE |
| 516 : |
|
|
THEN |
| 517 : |
pazsan
|
1.38
|
s" a" tag parse-string s" a" /tag |
| 518 : |
pazsan
|
1.10
|
THEN |
| 519 : |
pazsan
|
1.36
|
rdrop |
| 520 : |
pazsan
|
1.22
|
1 toc-index +! toc-index @ /toc-line mod 0= |
| 521 : |
pazsan
|
1.36
|
IF -env cr s" p" >env THEN ; |
| 522 : |
pazsan
|
1.22
|
|
| 523 : |
pazsan
|
1.36
|
: print-toc ( -- ) toc-index off cr |
| 524 : |
|
|
toc-image IF s" img-menu" ELSE s" menu" THEN id= |
| 525 : |
|
|
s" div" >env cr s" p" >env |
| 526 : |
pazsan
|
1.22
|
0 parse |
| 527 : |
pazsan
|
1.10
|
dup 0= IF toc-name $! 0 ELSE |
| 528 : |
pazsan
|
1.21
|
toc-name $! toc-name $@ id= s" " s" a" tagged 2 |
| 529 : |
pazsan
|
1.10
|
THEN >r |
| 530 : |
|
|
toc-link BEGIN @ dup WHILE |
| 531 : |
pazsan
|
1.21
|
dup cell+ @ 3 = r@ 0= and IF rdrop 1 >r ( s" br" tag/ cr ) THEN |
| 532 : |
pazsan
|
1.10
|
dup cell+ @ r@ >= IF dup r@ 2 = .toc-entry THEN |
| 533 : |
pazsan
|
1.22
|
dup cell+ @ 2 = r@ 2 = and IF s" br" tag/ toc-index off THEN |
| 534 : |
pazsan
|
1.36
|
REPEAT drop rdrop -env -env cr ; |
| 535 : |
pazsan
|
1.10
|
|
| 536 : |
pazsan
|
1.1
|
\ handle global tags |
| 537 : |
|
|
|
| 538 : |
pazsan
|
1.21
|
: indent ( n -- ) |
| 539 : |
pazsan
|
1.22
|
indentlevel @ over |
| 540 : |
pazsan
|
1.21
|
indentlevel ! |
| 541 : |
pazsan
|
1.25
|
2dup < IF swap DO -env LOOP EXIT THEN |
| 542 : |
|
|
2dup > IF DO s" div" >env LOOP EXIT THEN |
| 543 : |
|
|
2dup = IF drop IF -env s" div" >env THEN THEN |
| 544 : |
pazsan
|
1.21
|
; |
| 545 : |
|
|
: +indent ( -- ) |
| 546 : |
pazsan
|
1.25
|
indentlevel @ IF -env indent= s" div" >env THEN |
| 547 : |
pazsan
|
1.21
|
; |
| 548 : |
pazsan
|
1.8
|
|
| 549 : |
pazsan
|
1.1
|
wordlist constant longtags |
| 550 : |
|
|
|
| 551 : |
pazsan
|
1.21
|
Variable divs |
| 552 : |
|
|
|
| 553 : |
pazsan
|
1.1
|
longtags set-current |
| 554 : |
|
|
|
| 555 : |
pazsan
|
1.25
|
: --- 0 indent cr s" hr" tag/ cr ; |
| 556 : |
pazsan
|
1.35
|
: * 1 indent s" h1" dclass= s" h1" par +indent s" " dclass= ; |
| 557 : |
|
|
: ** 1 indent s" h2" dclass= s" h2" par +indent s" " dclass= ; |
| 558 : |
|
|
: *** 2 indent s" h3" dclass= s" h3" par +indent s" " dclass= ; |
| 559 : |
pazsan
|
1.25
|
: -- 0 indent cr print-toc ; |
| 560 : |
|
|
: && 0 parse id= ; |
| 561 : |
|
|
: - s" ul" env s" li" par ; |
| 562 : |
|
|
: + s" ol" env s" li" par ; |
| 563 : |
|
|
: ? s" dl" env s" dt" par ; |
| 564 : |
|
|
: : s" dl" env s" dd" par ; |
| 565 : |
|
|
: -<< s" ul" env env? s" li" >env ; |
| 566 : |
|
|
: +<< s" ol" env env? s" li" >env ; |
| 567 : |
pazsan
|
1.34
|
\ : ?<< s" dl" env env? s" dt" >env ; \ not allowed |
| 568 : |
pazsan
|
1.25
|
: :<< s" dl" env env? s" dd" >env ; |
| 569 : |
|
|
: p<< s" p" >env ; |
| 570 : |
|
|
: << +env ; |
| 571 : |
|
|
: <* s" center" class= ; |
| 572 : |
pazsan
|
1.34
|
: <red s" p" >env s" #ff0000" s" color" opt s" font" >env parse-par ; |
| 573 : |
|
|
: red> -env -env ; |
| 574 : |
pazsan
|
1.25
|
: >> -env ; |
| 575 : |
pazsan
|
1.23
|
: *> ; |
| 576 : |
pazsan
|
1.25
|
: :: interpret ; |
| 577 : |
|
|
: . end-sec on 0 indent ; |
| 578 : |
|
|
: :code s" pre" >env |
| 579 : |
pazsan
|
1.34
|
BEGIN source >in @ /string .type cr refill WHILE |
| 580 : |
anton
|
1.16
|
source s" :endcode" str= UNTIL THEN |
| 581 : |
pazsan
|
1.23
|
-env ; |
| 582 : |
pazsan
|
1.25
|
: :code-file s" pre" >env |
| 583 : |
|
|
parse" slurp-file type -env ; |
| 584 : |
|
|
: \ postpone \ ; |
| 585 : |
pazsan
|
1.1
|
|
| 586 : |
|
|
definitions |
| 587 : |
pazsan
|
1.25
|
|
| 588 : |
|
|
: LT get-order longtags swap 1+ set-order |
| 589 : |
|
|
bl sword parser previous ; immediate |
| 590 : |
|
|
|
| 591 : |
pazsan
|
1.3
|
\ Table |
| 592 : |
|
|
|
| 593 : |
pazsan
|
1.5
|
: next-char ( -- char ) source drop >in @ + c@ ; |
| 594 : |
pazsan
|
1.25
|
: next-table ( -- ) |
| 595 : |
|
|
BEGIN |
| 596 : |
|
|
table-starts table# @ 2* + dup c@ dup |
| 597 : |
|
|
IF 1- over c! 1+ c@ 1+ ELSE swap 1+ c! 0 THEN |
| 598 : |
|
|
dup WHILE table# +! REPEAT drop |
| 599 : |
|
|
table-format $@ table# @ /string drop c@ taligned ! ; |
| 600 : |
|
|
: next>align ( -- ) |
| 601 : |
|
|
next-char dup bl <> over '\ <> and |
| 602 : |
|
|
IF taligned ! 1 >in +! ELSE drop THEN ; |
| 603 : |
|
|
|
| 604 : |
|
|
: |tag ( addr u -- ) |
| 605 : |
|
|
next-table |
| 606 : |
|
|
next-char '/ = IF 1 >in +! |
| 607 : |
|
|
next-char digit? IF |
| 608 : |
|
|
dup 1- table-starts table# @ 2* + c! |
| 609 : |
|
|
s" rowspan" opt# 1 >in +! THEN |
| 610 : |
|
|
next>align |
| 611 : |
|
|
THEN |
| 612 : |
|
|
next-char '\ = IF 1 >in +! |
| 613 : |
|
|
next-char digit? IF |
| 614 : |
|
|
dup 1- table-starts table# @ 2* + 1+ c! |
| 615 : |
|
|
dup 1- table# +! |
| 616 : |
|
|
s" colspan" opt# 1 >in +! THEN |
| 617 : |
|
|
next>align |
| 618 : |
|
|
THEN |
| 619 : |
|
|
taligned @ >talign >env |
| 620 : |
|
|
1 table# +! ; |
| 621 : |
|
|
: |d table# @ 0> IF -env THEN s" td" |tag ; |
| 622 : |
|
|
: |h table# @ 0> IF -env THEN s" th" |tag ; |
| 623 : |
|
|
: |line s" tr" >env table# off ; |
| 624 : |
|
|
: line| 1 >in +! -env -env cr ; |
| 625 : |
pazsan
|
1.5
|
|
| 626 : |
pazsan
|
1.3
|
longtags set-current |
| 627 : |
|
|
|
| 628 : |
pazsan
|
1.25
|
: <| ( -- ) table-starts &20 erase |
| 629 : |
|
|
s" table" class= s" div" >env |
| 630 : |
|
|
bl sword table-format $! bl sword |
| 631 : |
|
|
dup IF s" border" opt ELSE 2drop THEN |
| 632 : |
|
|
s" table" >env ; |
| 633 : |
pazsan
|
1.12
|
: |> -env -env cr cr ; |
| 634 : |
pazsan
|
1.25
|
: +| ( -- ) |
| 635 : |
|
|
|line BEGIN |h '| parse-to next-char '+ = UNTIL line| ; |
| 636 : |
|
|
: -| ( -- ) |
| 637 : |
|
|
|line BEGIN |d '| parse-to next-char '- = UNTIL line| ; |
| 638 : |
|
|
: =| ( -- ) |
| 639 : |
|
|
|line |h '| parse-to |
| 640 : |
|
|
BEGIN |d '| parse-to next-char '= = UNTIL line| ; |
| 641 : |
pazsan
|
1.3
|
|
| 642 : |
|
|
definitions |
| 643 : |
pazsan
|
1.1
|
|
| 644 : |
|
|
\ parse a section |
| 645 : |
|
|
|
| 646 : |
pazsan
|
1.25
|
: section-par ( -- ) >in off |
| 647 : |
pazsan
|
1.9
|
bl sword longtags search-wordlist |
| 648 : |
|
|
IF execute |
| 649 : |
pazsan
|
1.8
|
ELSE source nip IF >in off s" p" par THEN THEN ; |
| 650 : |
pazsan
|
1.25
|
: parse-section ( -- ) end-sec off |
| 651 : |
pazsan
|
1.8
|
BEGIN refill WHILE |
| 652 : |
pazsan
|
1.34
|
section-par end-sec @ UNTIL THEN end-sec off ; |
| 653 : |
pazsan
|
1.1
|
|
| 654 : |
|
|
\ HTML head |
| 655 : |
|
|
|
| 656 : |
pazsan
|
1.21
|
Variable css-file |
| 657 : |
pazsan
|
1.42
|
Variable print-file |
| 658 : |
pazsan
|
1.34
|
Variable content |
| 659 : |
pazsan
|
1.40
|
Variable _lang |
| 660 : |
|
|
Variable _favicon |
| 661 : |
pazsan
|
1.21
|
|
| 662 : |
pazsan
|
1.34
|
: lang@ ( -- addr u ) |
| 663 : |
pazsan
|
1.40
|
_lang @ IF _lang $@ ELSE s" en" THEN ; |
| 664 : |
pazsan
|
1.34
|
: .css ( -- ) |
| 665 : |
|
|
css-file @ IF css-file $@len IF |
| 666 : |
|
|
s" StyleSheet" s" rel" opt |
| 667 : |
pazsan
|
1.42
|
css-file $@ href= s" screen" s" media" opt |
| 668 : |
|
|
s" text/css" s" type" opt s" link" tag/ cr |
| 669 : |
|
|
THEN THEN ; |
| 670 : |
|
|
: .print ( -- ) |
| 671 : |
|
|
print-file @ IF print-file $@len IF |
| 672 : |
|
|
s" StyleSheet" s" rel" opt |
| 673 : |
|
|
print-file $@ href= s" print" s" media" opt |
| 674 : |
pazsan
|
1.34
|
s" text/css" s" type" opt s" link" tag/ cr |
| 675 : |
|
|
THEN THEN ; |
| 676 : |
|
|
: .title ( addr u -- ) 1 envs ! oldenv off |
| 677 : |
|
|
.' <!DOCTYPE html' cr |
| 678 : |
|
|
.' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' cr |
| 679 : |
|
|
.' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' cr |
| 680 : |
|
|
s" http://www.w3.org/1999/xhtml" s" xmlns" opt |
| 681 : |
|
|
lang@ s" xml:lang" opt lang@ s" lang" opt |
| 682 : |
|
|
s" html" >env cr s" head" >env cr |
| 683 : |
pazsan
|
1.21
|
s" Content-Type" s" http-equiv" opt |
| 684 : |
pazsan
|
1.34
|
content $@ s" content" opt |
| 685 : |
pazsan
|
1.42
|
s" meta" tag/ cr .css .print |
| 686 : |
pazsan
|
1.40
|
_favicon @ IF |
| 687 : |
|
|
s" shortcut icon" s" rel" opt |
| 688 : |
|
|
_favicon $@ href= |
| 689 : |
|
|
s" image/x-icon" s" type" opt |
| 690 : |
|
|
s" link" tag/ cr THEN |
| 691 : |
pazsan
|
1.2
|
s" title" tagged cr |
| 692 : |
pazsan
|
1.1
|
-env ; |
| 693 : |
|
|
|
| 694 : |
|
|
\ HTML trailer |
| 695 : |
|
|
|
| 696 : |
pazsan
|
1.29
|
Variable public-key |
| 697 : |
pazsan
|
1.1
|
Variable mail |
| 698 : |
|
|
Variable mail-name |
| 699 : |
pazsan
|
1.12
|
Variable orig-date |
| 700 : |
pazsan
|
1.1
|
|
| 701 : |
pazsan
|
1.20
|
: .lastmod |
| 702 : |
|
|
." Last modified: " time&date rot 0 u.r swap 1- |
| 703 : |
|
|
s" janfebmaraprmayjunjulaugsepoctnovdec" rot 3 * /string 3 min type |
| 704 : |
|
|
0 u.r ; |
| 705 : |
|
|
|
| 706 : |
pazsan
|
1.1
|
: .trailer |
| 707 : |
pazsan
|
1.21
|
s" center" class= s" address" >env |
| 708 : |
pazsan
|
1.12
|
orig-date @ IF ." Created " orig-date $@ type ." . " THEN |
| 709 : |
pazsan
|
1.20
|
.lastmod |
| 710 : |
|
|
." by " |
| 711 : |
pazsan
|
1.27
|
s" Mail|@/mail.gif" .img mail $@ mailto: mail-name $@ s" a" tagged |
| 712 : |
pazsan
|
1.29
|
public-key @ IF |
| 713 : |
|
|
public-key $@ href= s" a" tag |
| 714 : |
pazsan
|
1.36
|
s" PGP key|-@/gpg.asc.gif" .img s" a" /tag |
| 715 : |
pazsan
|
1.29
|
THEN |
| 716 : |
pazsan
|
1.1
|
-envs ; |
| 717 : |
|
|
|
| 718 : |
|
|
\ top word |
| 719 : |
pazsan
|
1.6
|
|
| 720 : |
pazsan
|
1.12
|
: maintainer ( -- ) |
| 721 : |
pazsan
|
1.25
|
'< sword -trailing mail-name $! '> sword mail $! ; |
| 722 : |
pazsan
|
1.29
|
: pgp-key ( -- ) |
| 723 : |
|
|
bl sword -trailing public-key $! ; |
| 724 : |
pazsan
|
1.34
|
: charset ( -- ) s" text/xhtml; charset=" content $! |
| 725 : |
|
|
bl sword -trailing content $+! ; |
| 726 : |
|
|
|
| 727 : |
|
|
charset iso-8859-1 |
| 728 : |
|
|
|
| 729 : |
pazsan
|
1.12
|
: created ( -- ) |
| 730 : |
|
|
bl sword orig-date $! ; |
| 731 : |
pazsan
|
1.27
|
: icons |
| 732 : |
|
|
bl sword icon-prefix $! ; |
| 733 : |
pazsan
|
1.34
|
: lang |
| 734 : |
pazsan
|
1.40
|
bl sword _lang $! ; |
| 735 : |
|
|
: favicon |
| 736 : |
|
|
bl sword _favicon $! ; |
| 737 : |
pazsan
|
1.32
|
: expands '# sword expand-prefix $! bl sword expand-postfix $! ; |
| 738 : |
|
|
|
| 739 : |
pazsan
|
1.27
|
icons icons |
| 740 : |
pazsan
|
1.6
|
|
| 741 : |
|
|
Variable style$ |
| 742 : |
|
|
: style> style$ @ 0= IF s" " style$ $! THEN style$ $@ tag-option $! ; |
| 743 : |
|
|
: >style tag-option $@ style$ $! s" " tag-option $! ; |
| 744 : |
|
|
|
| 745 : |
|
|
: style style> opt >style ; |
| 746 : |
|
|
: background ( -- ) parse" s" background" style ; |
| 747 : |
|
|
: text ( -- ) parse" s" text" style ; |
| 748 : |
|
|
warnings @ warnings off |
| 749 : |
|
|
: link ( -- ) parse" s" link" style ; |
| 750 : |
|
|
warnings ! |
| 751 : |
|
|
: vlink ( -- ) parse" s" vlink" style ; |
| 752 : |
|
|
: marginheight ( -- ) parse" s" marginheight" style ; |
| 753 : |
pazsan
|
1.21
|
: css ( -- ) parse" css-file $! ; |
| 754 : |
pazsan
|
1.42
|
: print-css ( -- ) parse" print-file $! ; |
| 755 : |
pazsan
|
1.1
|
|
| 756 : |
|
|
: wf ( -- ) |
| 757 : |
|
|
outfile-id >r |
| 758 : |
|
|
bl sword r/w create-file throw to outfile-id |
| 759 : |
pazsan
|
1.6
|
parse" .title |
| 760 : |
|
|
+env style> s" body" env env? |
| 761 : |
pazsan
|
1.1
|
['] parse-section catch .trailer |
| 762 : |
|
|
outfile-id close-file throw |
| 763 : |
|
|
r> to outfile-id |
| 764 : |
|
|
dup 0< IF throw ELSE drop THEN ; |
| 765 : |
|
|
|
| 766 : |
pazsan
|
1.8
|
: eval-par ( addr u -- ) |
| 767 : |
|
|
s" wf-temp.wf" r/w create-file throw >r |
| 768 : |
|
|
r@ write-file r> close-file throw |
| 769 : |
|
|
push-file s" wf-temp.wf" r/o open-file throw loadfile ! |
| 770 : |
pazsan
|
1.34
|
parse-par -env parse-section |
| 771 : |
pazsan
|
1.8
|
loadfile @ close-file swap 2dup or |
| 772 : |
|
|
pop-file drop throw throw |
| 773 : |
|
|
s" wf-temp.wf" delete-file throw ; |
| 774 : |
|
|
|
| 775 : |
pazsan
|
1.2
|
\ simple text data base |
| 776 : |
|
|
|
| 777 : |
|
|
Variable last-entry |
| 778 : |
|
|
Variable field# |
| 779 : |
|
|
|
| 780 : |
pazsan
|
1.25
|
: table: ( xt n -- ) Create 0 , ['] type , , , 1 field# ! |
| 781 : |
|
|
DOES> 2 cells + 2@ >in @ >r longtags set-current |
| 782 : |
pazsan
|
1.2
|
Create definitions swap , r> >in ! |
| 783 : |
|
|
here last-entry ! |
| 784 : |
|
|
dup 0 DO 0 , LOOP |
| 785 : |
|
|
1 DO s" " last-entry @ I cells + $! LOOP |
| 786 : |
|
|
last-entry @ get-rest |
| 787 : |
|
|
DOES> dup cell+ swap perform ; |
| 788 : |
|
|
|
| 789 : |
pazsan
|
1.25
|
: field: Create field# @ , ['] type , 1 field# +! |
| 790 : |
pazsan
|
1.2
|
DOES> @ cells last-entry @ + get-rest ; |
| 791 : |
pazsan
|
1.25
|
: par: Create field# @ , ['] eval-par , 1 field# +! |
| 792 : |
pazsan
|
1.8
|
DOES> @ cells last-entry @ + get-par ; |
| 793 : |
pazsan
|
1.3
|
|
| 794 : |
pazsan
|
1.25
|
: >field-rest >body @ cells postpone Literal postpone + ; |
| 795 : |
|
|
: >field ' >field-rest ; immediate |
| 796 : |
|
|
|
| 797 : |
|
|
: db-line ( -- ) |
| 798 : |
|
|
BEGIN |
| 799 : |
|
|
source >in @ /string nip WHILE |
| 800 : |
|
|
'% parse postpone SLiteral postpone type |
| 801 : |
|
|
'% parse dup IF |
| 802 : |
|
|
'| $split 2swap |
| 803 : |
|
|
sfind 0= abort" Field not found" |
| 804 : |
|
|
dup postpone r@ >field-rest postpone $@ |
| 805 : |
|
|
over IF drop evaluate ELSE |
| 806 : |
|
|
nip nip >body cell+ @ compile, |
| 807 : |
|
|
THEN |
| 808 : |
|
|
ELSE 2drop postpone cr THEN |
| 809 : |
|
|
REPEAT ; |
| 810 : |
|
|
|
| 811 : |
|
|
: db-par ( -- ) LT postpone p<< postpone >r |
| 812 : |
|
|
BEGIN db-line refill WHILE next-char '. = UNTIL 1 >in +! THEN |
| 813 : |
pazsan
|
1.34
|
postpone rdrop ( LT postpone >> ) ; immediate |