retroforth/example/strip-html.retro
crc 660e52bdcb rename words in sys: to script: (old names still work in this release, but are deprecated)
FossilOrigin-Name: 1a43743f43076eb087ee4dd7fbfa96b8dfda2aa4ddcff41e6a5a9634ba6e239c
2020-09-14 19:55:02 +00:00

22 lines
803 B
Forth

This is a quick little tool to strip some HTML and leave text behind.
It's not factored, and doesn't filter blocks that don't exactly match
the tags listed in the code. It's still useful for quick looks, and
may serve as a starting point for something more useful later on.
~~~
'Tag d:create #1025 allot
'In-Tag var
#0 script:get-argument file:open-for-reading swap
[ dup file:read
$< [ &Tag buffer:set &In-Tag v:on ] case
$> [ &Tag 'head [ here buffer:set ] s:case
'title [ here buffer:set ] s:case
'script [ here buffer:set ] s:case
'script_type="text/javascript" [ here buffer:set ] s:case
'style [ here buffer:set ] s:case
drop &In-Tag v:off ] case
@In-Tag [ buffer:add ] [ c:put ] choose ] times
file:close
~~~