new example: html generation using combinators
FossilOrigin-Name: 88a6e16492d1df45f275965cce9c0ff45f63a388fb10c15da065bdd78a2a6489
This commit is contained in:
parent
ef3aec5283
commit
6490155945
3 changed files with 28 additions and 2 deletions
|
@ -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
|
||||
|
|
24
example/HTML.forth
Normal file
24
example/HTML.forth
Normal file
|
@ -0,0 +1,24 @@
|
|||
# HTML Generation
|
||||
|
||||
This is a little experiment in combinator-driven HTML generation.
|
||||
|
||||
~~~
|
||||
:a:href (ss-) '<a_href=" s:put s:put '"> s:put s:put '</a> s:put ;
|
||||
:p (q-) '<p> s:put call '</p> s:put nl ;
|
||||
:strong (q-) '<strong> s:put call '</strong> s:put nl ;
|
||||
:em (q-) '<em> s:put call '</em> s:put nl ;
|
||||
:h1 (s-) '<h1> s:put s:put '</h1> s:put nl ;
|
||||
:div (q-) '<div> s:put call '</div> s:put nl ;
|
||||
:body (q-) '<body> s:put call '</body> 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
|
||||
```
|
|
@ -584,8 +584,8 @@ to use.
|
|||
'__interface
|
||||
'--------------------------------
|
||||
'Export_Formats:
|
||||
'__glossary
|
||||
'__tsv
|
||||
'__glossary____concise
|
||||
'__tsv_________concise-stack
|
||||
'--------------------------------
|
||||
} [ s:put nl ] set:for-each ;
|
||||
~~~
|
||||
|
|
Loading…
Reference in a new issue