From 64901559458404c7a813135d47f00806b7553212 Mon Sep 17 00:00:00 2001 From: crc Date: Thu, 24 Jan 2019 17:49:29 +0000 Subject: [PATCH] new example: html generation using combinators FossilOrigin-Name: 88a6e16492d1df45f275965cce9c0ff45f63a388fb10c15da065bdd78a2a6489 --- RELEASE_NOTES.md | 2 ++ example/HTML.forth | 24 ++++++++++++++++++++++++ glossary.forth | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 example/HTML.forth diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e788149..50b2a0b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -56,6 +56,7 @@ - refactor glossary tool - add HTML version of the Glossary +- add more concise text copies of the Glossary - add man pages ## Examples @@ -63,6 +64,7 @@ - add Buffer.forth - add CaptureOutput.forth - add DisplayNames.forth +- add HTML.forth - add KeyValueStore.forth - add Marker.forth - add net_fetch.forth diff --git a/example/HTML.forth b/example/HTML.forth new file mode 100644 index 0000000..f72753e --- /dev/null +++ b/example/HTML.forth @@ -0,0 +1,24 @@ +# HTML Generation + +This is a little experiment in combinator-driven HTML generation. + +~~~ +:a:href (ss-) ' s:put s:put ' s:put ; +:p (q-) '

s:put call '

s:put nl ; +:strong (q-) ' s:put call ' s:put nl ; +:em (q-) ' s:put call ' s:put nl ; +:h1 (s-) '

s:put s:put '

s:put nl ; +:div (q-) '
s:put call '
s:put nl ; +:body (q-) ' s:put call ' s:put nl ; +:prefix:" s:keep &s:put compile:call ; immediate +~~~ + +Test case: + +``` +[ 'Hello h1 + [ "This_is_a_test_of_HTML_generation._Please_ + 'follow_the_link 'page2.html a:href ". ] p + [ "This_is_a_second_paragraph ] p +] body +``` diff --git a/glossary.forth b/glossary.forth index 3f6e369..1050653 100755 --- a/glossary.forth +++ b/glossary.forth @@ -584,8 +584,8 @@ to use. '__interface '-------------------------------- 'Export_Formats: - '__glossary - '__tsv + '__glossary____concise + '__tsv_________concise-stack '-------------------------------- } [ s:put nl ] set:for-each ; ~~~