\ html5cgi.fs -- Generate HTML5 tags for CGI script \ 2016 David Meyer +JMJ \ Tags are generate with words with format *X*, where X usually corresponds to the \ tag to be generated, and which generally have a stack effect like: \ \ ( c-prefix c-content [c-attrib ...] -- c-result ) \ \ Where: c-prefix is a pointer to a counted string containing the preceding contents \ of the current element; 0 when the current tag will be the first \ contents of the element. \ c-content is a pointer to the contents for the current tag. \ c-attrib points to one or more optional strings for tag attributes. \ c-result points to a string concatenating the prefix contents with the current \ tag (input strings are recycled to the heap). \ Supported tags/structure: \ *http-resp* \ *html* \ *head* \ *title*, *style*, *meta*, *base* \ *body* \ *article*, *aside*, *div*, *header*, *footer*, *nav*, *section* \ *a*, *blockquote* *h1*, *h2*, *h3*, *h4*, *h5*, *h6*, *hr*, *img*, *pre* \ *map* \ *area* \ *p* \ *b*, *br*, *em*, *strong* \ *ol*, *ul* \ *li* \ *dl* \ *dt*, *dd* \ *table* \ *thead*, *tbody* \ *tr* \ *th*, *td* \ *form* \ *input*, *label* include heapstr.fs s" " $alloc constant C-B s" " $alloc constant C-/B s"
" $alloc constant C-BQUOTE s\"
\n" $alloc constant C-/BQUOTE s\" \n" $alloc constant C-BODY s\" \n" $alloc constant C-/BODY s\"
\n" $alloc constant C-BR s" " $alloc constant C-EM s" " $alloc constant C-/EM s"

" $alloc constant C-H1 s\"

\n" $alloc constant C-/H1 s"

" $alloc constant C-H2 s\"

\n" $alloc constant C-/H2 s"

" $alloc constant C-H3 s\"

\n" $alloc constant C-/H3 s"

" $alloc constant C-H4 s\"

\n" $alloc constant C-/H4 s"
" $alloc constant C-H5 s\"
\n" $alloc constant C-/H5 s"
" $alloc constant C-H6 s\"
\n" $alloc constant C-/H6 s\" \n" $alloc constant C-HEAD s\" \n" $alloc constant C-/HEAD s\"
\n" $alloc constant C-HR s\" \n" $alloc constant C-HTML s\" \n" $alloc constant C-/HTML s\" Content-type: text/html\n\n\n" $alloc constant C-HTTP-HTML5 s"
  • " $alloc constant C-LI s\"
  • \n" $alloc constant C-/LI s"
      " $alloc constant C-OL s\"
    \n" $alloc constant C-/OL s"

    " $alloc constant C-P s\"

    \n" $alloc constant C-/P s" " $alloc constant C-STRONG s" " $alloc constant C-/STRONG s" " $alloc constant C-TITLE s\" \n" $alloc constant C-/TITLE s" \n" $alloc constant C-/UL : empty-tag ( c-prefix c-tag -- c-result ) 1 c$catx ; : simple-tag ( c-prefix c-content c-open c-close -- c-result ) \g Generate tag with format: Tag contents rot swap 1 c$catx 2 c$catx over if 0 c$catx else nip then ; : *blockquote* ( c-prefix c-content -- c-result ) C-BQUOTE C-/BQUOTE simple-tag ; : *b* ( c-prefix c-content -- c-result ) C-B C-/B simple-tag ; : *body* ( c-content -- c-body ) C-/BODY 1 c$catx C-BODY swap 2 c$catx ; : *br* ( c-prefix -- c-result ) C-BR empty-tag ; : *em* ( c-prefix c-content -- c-result ) C-EM C-/EM simple-tag ; : *h1* ( c-prefix c-content -- c-result ) C-H1 C-/H1 simple-tag ; : *h2* ( c-prefix c-content -- c-result ) C-H2 C-/H2 simple-tag ; : *h3* ( c-prefix c-content -- c-result ) C-H3 C-/H3 simple-tag ; : *h4* ( c-prefix c-content -- c-result ) C-H4 C-/H4 simple-tag ; : *h5* ( c-prefix c-content -- c-result ) C-H5 C-/H5 simple-tag ; : *h6* ( c-prefix c-content -- c-result ) C-H6 C-/H6 simple-tag ; : *head* ( c-content -- c-result ) C-/HEAD 1 c$catx C-HEAD swap 2 c$catx ; : *hr* ( c-prefix -- c-result ) C-HR empty-tag ; : *html* ( c-head c-body -- c-result ) C-/HTML 1 c$catx 0 c$catx C-HTML swap 2 c$catx ; : *http-html5* ( c-content -- c-result ) C-HTTP-HTML5 swap 2 c$catx ; : *li* ( c-prefix c-content -- c-result ) C-LI C-/LI simple-tag ; : *ol* ( c-prefix c-content -- c-result ) C-OL C-/OL simple-tag ; : *p* ( c-prefix c-content -- c-result ) C-P C-/P simple-tag ; : *strong* ( c-prefix c-content -- c-result ) C-STRONG C-/STRONG simple-tag ; : *title* ( c-prefix c-content -- c-result ) C-TITLE C-/TITLE simple-tag ; : *ul* ( c-prefix c-content -- c-result ) C-UL C-/UL simple-tag ;