Weave for RISC OS
div span a
Suppose further that you want to call it mypage/html and that it is to get its styles from
a file mystyles/css in the same directory.
Then create a file of type lua (18C) called mypage. Its contents should go like this:
require "xhtml"
do
local BEGIN,END,TAG,link in xhtml
-- define some tags
local DIV = TAG.div [[class="my_div_style"]]
local SPAN = TAG.span [[class="my_span_style"]]
. . . . . . . .
-- define document
local mydoc = BEGIN()
mydoc.STYLE = [[mystyle.css]]
mydoc.BODY = {
-- body of page described as a rope (see below)
-- using the tags defined above
}
-- create the page
END(mydoc)
end
Doubleclicking mypage will create mypage/html. You may find it more convenient for
reading error messages to run the program in a taskwindow by dragging
its icon onto the iconbar icon of !taskw.
The notion of a rope may defined recursively by the
rules that 1) a string is a rope and 2) a list of ropes is a rope.
The xhtml library provides two pseudotables TAG and MONOTAG. We have seen the former in use
above. The expression TAG.div takes a rope
for its argument, and returns a tag with label div and attribute list given by the argument. Remember to use an
empty string if the attribute list is empty. Such a tag, called here DIV, is a function from ropes to ropes. It encloses
its argument in begin- and end-tags. For empty tags, such as img which have no corresponding end-tag, use MONOTAG which returns not a function but a rope.
The function BEGIN takes as argument the
pathname of the page to be created. If no argument is given, it is taken to
be that of the program itself, but with an extender /html added at the end. It returns a document object, called mydoc in the example above. This object has
optional properties whose values are ropes:
mydoc.HEAD -- goes in the header
mydoc.STYLE -- names a style file
mydoc.ATTR -- attributes for the body tag
mydoc.BODY -- contents of the body
The function END takes a document as argument
and writes it out to file. This does all the work.
The function TEXT applied to a rope
converts top-bit-set characters to html entities and converts the
strings '>','<','&&' to '>','<','&' respectively.
The function REM inserts its argument
as an HTML comment.
The function SPACE takes a number as an
argument and returns a string of that many nonblank spaces.
The function link is provided as a
convenience. So the expression link(url) is a function from ropes to ropes that encloses its argument
in anchor tags to the specified url.
Back to RISC OS stuff