2019-01-24 18:49:29 +01:00
|
|
|
# HTML Generation
|
|
|
|
|
|
|
|
This is a little experiment in combinator-driven HTML generation.
|
|
|
|
|
|
|
|
~~~
|
2019-12-30 16:34:24 +01:00
|
|
|
:a:href (ss-) '<a_href=' s:put s:put ''> s:put s:put '</a> s:put ;
|
2019-01-24 18:49:29 +01:00
|
|
|
: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 ;
|
2021-03-30 13:58:25 +02:00
|
|
|
:sigil:" s:keep &s:put compile:call ; immediate
|
2019-01-24 18:49:29 +01:00
|
|
|
~~~
|
|
|
|
|
|
|
|
Test case:
|
|
|
|
|
|
|
|
```
|
|
|
|
[ 'Hello h1
|
2019-12-30 16:34:24 +01:00
|
|
|
[ 'This_is_a_test_of_HTML_generation._Please_
|
|
|
|
'follow_the_link 'page2.html a:href '. ] p
|
|
|
|
[ 'This_is_a_second_paragraph ] p
|
2019-01-24 18:49:29 +01:00
|
|
|
] body
|
|
|
|
```
|