# sample.hsrc # # this is a sample HSRC file for use with gen_html.sh; # # of course, this scheme shines more if used with multiple pages that # share characteristics, and for sucking in info from the environment # and/or from external commands and scripts; # # # here's some ordinary start-of-doc stuff # begin_doc begin_head -t "This is a sample HSRC page" -b "/your/base/href/here" end_head begin_body -bg beige -text maroon # # a page title # do_break 2 begin_center heading 2 "This Is A Web Page Generated From The Sample HSRC File" end_center do_break 2 do_last_update do_hrule -s 3 2 do_break # # intro: centered paragraph # paragraph -C " This page is a sample of how to set up a `code .hsrc` file for producing a `code .html` file via the `code gen_html.sh` script described in the articles. We'll just be playing around with some of the available features here. " do_hrule -s 3 do_break # # wrappers # WRAP='head_wrap() { begin_table -b 1 -cp 7 table_data "`begin_font -s +1``bold \"$*\"``end_font`" end_table do_break }' eval "$WRAP" head_wrap "Wrappers" paragraph " These boxed headings are examples of wrapper routines. They can be used to combine features, and provide for easy replication of style elements. " paragraph " This wrapper looks like this: " preformatted "$WRAP" paragraph " And is called with something like: " preformatted "head_wrap \"A Nested List\"" do_break # # nested lists # #heading 3 "A Nested List" head_wrap "A Nested List" begin_list -u -ut circle list_item "This is an `bold unordered` list using circle bullets" list_item "Next is a nested `bold definition` list" list_item "\ `begin_list -c list_item \"Here's the \`bold term\` part\" list_item -d \"And here's the \`bold definition\` part\" list_item \"Here's another term part\" list_item -d \"And another definition part\" end_list`" list_item "And this is another item in the outer list" end_list do_break # # table # #heading 3 "A Table with 2 Levels of Nesting" head_wrap "A Table with 2 Levels of Nesting" begin_center begin_table -cols 4 -cap "`begin_font -s +2` This is the caption of the outer table. `end_font`" -b 1 -cp 5 -cs 10 table_data "here's some data" table_data "here's some data" table_data "here's some data" table_data "here's some data" table_data "here's some data" table_data -cspan 2 -rspan 2 "\ `begin_table -b 1 -cols 2 -cap \"This an embedded table\" table_data \"embedded data 1\" table_data \"embedded data 2\" table_data \"\`begin_table -b 1 -cols 2 -cap \\\"This an embedded-embedded table\\\" table_data \\\"embedded data 1\\\" table_data \\\"embedded data 2\\\" table_data \\\"embedded data 3\\\" end_table\`\" table_data \"embedded data 4\" table_data \"embedded data 5\" end_table`" table_data "here's some data" table_data "here's some data" table_data "here's some data" table_data "here's some more data" table_data "here's some more data" table_data -br "here's a data cell using the -br option" table_data "here's some more data" table_data "here's some more data" table_data "here's some more data" table_data "this row is going to end prematurely" new_table_row table_data "here's some more data" end_table end_center # here's another way you could do nesting... #T="`begin_table -b 1 -cols 2 -cap \"This an embedded table\" #table_data \"embedded data 1\" #table_data \"embedded data 2\" #table_data \"embedded data 3\" #end_table`" # then, include "$T" as a table_data argument do_break 3 # # using double quotes # #heading 3 "Double Quotes" head_wrap "Double Quotes" paragraph "It can be nice to have `dquote text in double quotes,` if you know what I mean." do_break # # an URL # #heading 3 "An Anchor" head_wrap "An Anchor" html "Sometimes we want to have " do_anchor -t "advisory title" "http://www.cs.duke.edu/~des/toolman.html" "links" html " to other places." do_break 3 # # Let's say you want a more stylized list; # you can write a wrapper routine; # you could do the same thing with tables... # #heading 3 "You can create your own wrappers for the routines" head_wrap "You can create your own wrappers for the routines" paragraph " This can be useful with long lists, where you want the options and formats to be consistent. You can make the changes in one place. " # here's how we want to make our list(s): begin_my_list() { html "
" begin_list -d } end_my_list() { end_list html "
" } my_dt() { begin_font -s +2 -c green list_item "$@" end_font } my_dd() { #emphasize `list_item -d "$1" \`do_break\` "$2"` _dd=`begin_list -u; list_item -t disc "$1"; list_item "$2"; end_list` emphasize `list_item "$_dd"` } # and here's a list: begin_my_list my_dt "Orange" my_dd "A round friut" "Semi-edible rind" my_dt "Pear" my_dd "A pear-shaped friut" "Edible rind" end_my_list paragraph " If you were going to need this in multiple source files, the way to go would be to put the wrapper routines and any environment variables into a `dquote style` file, then use a command like: `blockquote \`keyboard ./gen_html -s stylefile.sh webpage.hsrc\`` " do_break # # address block # #heading 3 "Send comments to:" head_wrap "Send comments to:" address "\ Daniel E. Singer <des@cs.duke.edu>" do_break bold `small \(That was an ADDRESS block.\)` do_break 2 do_hrule -s 3 3 # # regular end-of-doc stuff # #BASE_HREF="http://oz/" BASE_HREF="http://www.cs.duke.edu/~des/scripts/" do_footer end_body end_doc