add strip-html example

FossilOrigin-Name: d589c79ef47cf9d0bdd0b8c80f7a51c926ada369a413a1e98b3a10ebcbd6a0e4
This commit is contained in:
crc 2019-03-14 20:01:00 +00:00
parent 547bd93747
commit 85bee2fa76
2 changed files with 23 additions and 0 deletions

View file

@ -169,6 +169,7 @@ June 2019.
- add retro-embedimage.forth
- add SaveAndRestoreStack.forth
- add share.forth and shared.forth
- add strip-html.forth
- add TokiPona-Translate.forth
- add uuencode.forth
- add uudecode.forth

22
example/strip-html.forth Normal file
View file

@ -0,0 +1,22 @@
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 sys:argv 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
~~~