PreviousUpNext

15.4.814  src/lib/html/make-html.pkg

## make-html.pkg
#
# This is a collection of constructors for building
# some of the common kinds of HTML elements.

# Compiled by:
#     src/lib/html/html.lib


stipulate
    package has =  html_abstract_syntax;                                                        # html_abstract_syntax                  is from   src/lib/html/html-abstract-syntax.pkg
herein

    package make_html: (weak) 
      api {

         block_list:   List( has::Block ) -> has::Block;
         text_list:    List( has::Text  ) -> has::Text;

         make_h:  ((Int, has::Pcdata)) -> has::Block;

         make_p:  has::Text -> has::Block;
         make_ul:   List( has::List_Item ) -> has::Block;
         make_ol:   List( has::List_Item ) -> has::Block;
         make_dl:   List { dt:  List( has::Text ), dd:  has::Block } -> has::Block;
         hr:  has::Block;
         br:  has::Text;

         make_li:  has::Block -> has::List_Item;

         make_a_href:  { href:  has::Url, content:  has::Text } -> has::Text;
         make_a_name:  { name:  has::Cdata, content:  has::Text } -> has::Text;

         make_tr:   List( has::Table_Cell ) -> has::Tr;
         make_th:  has::Block -> has::Table_Cell;
         make_th_colspan:  { colspan:  Int, content:  has::Block } -> has::Table_Cell;
         make_td:  has::Block -> has::Table_Cell;
         make_td_colspan:  { colspan:  Int, content:  has::Block } -> has::Table_Cell;

      }
    {
        fun block_list [b] => b;
            block_list bl  => has::BLOCK_LIST bl;
        end;

        fun text_list [t] => t;
            text_list tl  => has::TEXT_LIST tl;
        end;

        fun make_h (n, header)
            =
            has::HN { n, align=>NULL, content=>has::PCDATA header };

        fun make_p content
            =
            has::PP { align=>NULL, content };

        fun make_ul items
            =
            has::UL { compact=>FALSE, type=>NULL, content=>items };

        fun make_ol items
            =
            has::OL { compact=>FALSE, type=>NULL, start => NULL, content=>items };

        fun make_dl items
            =
            has::DL { compact=>FALSE, content=>items };

        hr = has::HR { align=>NULL, noshade=>FALSE, size=>NULL, width=>NULL };

        br = has::BR { clear => NULL };

        fun make_li blk
            =
            has::LI { type=>NULL, value=>NULL, content=>blk };

        fun make_a_href { href, content }
            =
            has::AX {
                href => THE href,
                title => NULL,
                name => NULL,
                rel => NULL,
                reverse => NULL,
                content
              };

        fun make_a_name { name, content }
            =
            has::AX {
                href => NULL,
                title => NULL,
                name => THE name,
                rel => NULL,
                reverse => NULL,
                content
              };

        fun make_tr content
            =
            has::TR {
                align => NULL,
                valign => NULL,
                content
              };

        fun make_th content
            =
            has::TH {
                nowrap => FALSE,
                rowspan => NULL,
                colspan => NULL,
                align => NULL,
                valign => NULL,
                width => NULL,
                height => NULL,
                content
              };

        fun make_th_colspan { colspan, content }
            =
            has::TH {
                nowrap => FALSE,
                rowspan => NULL,
                colspan => THE colspan,
                align => NULL,
                valign => NULL,
                width => NULL,
                height => NULL,
                content
              };

        fun make_td content
            =
            has::TD {
                nowrap => FALSE,
                rowspan => NULL,
                colspan => NULL,
                align => NULL,
                valign => NULL,
                width => NULL,
                height => NULL,
                content
              };

        fun make_td_colspan { colspan, content }
            =
            has::TD {
                nowrap => FALSE,
                rowspan => NULL,
                colspan => THE colspan,
                align => NULL,
                valign => NULL,
                width => NULL,
                height => NULL,
                content
              };
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext