Kurt Nørmark ©
Department of Computer Science
Aalborg University
Denmark
Abstract Index References Contents | In this talk I present LAML. LAML means 'Lisp Abstracted Markup Language'. With LAML it is possible to generate HTML pages from a Scheme document Source. The basic idea is to mirror HTML into a number of Scheme functions. Based on this mirror, a number of document styles, tools, and additional libraries have been built. The talk will discuss and demonstrate a number of styles and tools. |
Background Slide Note Contents Index References | I start with my original need for Lisp in the domain of Internet programming. This was not authoring of static WWW pages, but CGI programming in a better language than Perl |
|
|
|
CGI Programming Slide Note Contents Index References | In order to explore the nature of CGI programming we here take a closer look at the overall CGI scheme |
Figure. The interaction between a browser and a CGI program | ![]() |
|
CGI Programming with Program State Slide Note Contents Index References | In many CGI programs we need to store a 'program state'. Often, data is transferred to and from a database. We modify the previous picture in include this observation. |
Figure. The interaction between a browser and a CGI program, which uses a database for storing the program state | ![]() |
|
CGI Programming in Scheme Slide Note Contents Index References | We now return to CGI programming in Scheme. |
|
|
This conclusion is drawn from a variety of different examples, which we have implemented. Most of the examples have been used to support various aspects of 'Open University' students located off campus. |
|
Programming static WWW pages in Scheme Slide Note Contents Index References | We will now return to the main topic of this talk, namely programming of ordinary, static WWW pages. |
|
We will return to both abstraction and automation later in the presentation. |
This observation is in relation to abstraction. XML supports 'your own' domain-specific tags. However, in relation to automation of routine tasks, XML has nothing to offer. |
LAML: Lisp Abstracted Markup Language Slide Note Contents Index References | We now introduce LAML, which basically is Scheme with access to libraries which mirror HTML. In addition, we support a number of functions which in our experience are very helpful during a typical WWW authoring process. Some of these functions are organized in document styles. |
|
|
HTML mirroring Slide Note Contents Index References |
|
|
|
An LAML Document Example Slide Note Contents Index References | It is now time to study a concrete example of an LAML document |
Program: We see a simple WWW pages written in LAML. The first interesting thing is the function generic-page-1, which generates all the html, body and title stuff, which is found on any WWW pages written in HTML. The con-par function is just a string-append variant, which concatenates paragraphs of text. The functions em and b mirror the similar HTML tags. The table-1 function is one of our convenient abstractions of HTML tables. We make a three column table with given widths, and a border of 2 pixels. The table proper is defined by a list of table rows. Each row is itself a list. The make-color function makes a color from red, green, blue components. | (load (string-append laml-dir "laml.scm")) (laml-style "simple") (generic-page-1 "A simple page" (con-par "This page demonstrates a few of the functions in the HTML library." (em (con-space "This paragraph has been emphasized by means of the" (b "em") "function.")) "Let us also show a simple table, which is one of the real convenient elements in LAML:" (table-1 2 ; border (list 100 200 100) (list red green blue) (list (list "Here" "is" "some") (list "tabular" "text" ""))) (b "This ends this simple page")) (make-color 255 255 191) black blue blue ) (end-laml) |
|
An example of a simple HTML4.0 page Slide Note Contents Index References | We here show a simple LAML page, using HTML mirror functions from the surface mirror. We also link to generated HTML output. This page has been produced by pretty printing the HTML file (using the LAML pretty printer for HTML) followed by a HTML protection of the HTML special characters. Thus, the automatic production of this pages is an excellent example of the power of the LAML approach. |
|
Program: An LAML document using the most advanced mirror. The loading stuff can be seen by browsing to the program below | (load "html4-loading-stuff.scm") (define _ #f) (html-write (html (head (title "Here is the title") ) (body (h1 "A header") (con "Here " (b "comes") " the") (em "document text") _ ", with an " (b "enumeration") _ "." (p) (ul 'type "square" (li "Item 1" _ ";") (li "Item 2" _ ";") (li "Item 3" _ ".") ) (a 'href "../html/goerlitz.html" "A link to the table of contents") _ "." (br) "And finally some more " (kbd "text")_"." ) ) ) |
Program: The loading stuff used by the LAML example above. | (load (string-append laml-dir "laml.scm")) (lib-load "html4.0-loose/basis.scm") (lib-load "html4.0-loose/surface.scm") (lib-load "file-read.scm") (define (html-write html-string) (write-text-file html-string (string-append (startup-directory) (source-filename-without-extension) "." "html") ) ) |
|
Another example page Slide Note Contents Index References |
Program: Another LAML document. | (load "html4-loading-stuff.scm") (html-write (html (head (title "Another LAML Example") ) (body (h1 "Another LAML Example") "Here are some facts about Germany, Denmark, and USA:" (p) (table 'border 1 (tr (th "") (th "Germany") (th "Denmark") (th "USA")) (tr (td "Currency") (td "DMark") (td "Kroner") (td "Dollar")) (tr (td "Size") (td "Large") (td "Small") (td "Huge")) (tr (td "Prime minister") (td "Schröder") (td "Rasmussen") (td "-")) (tr (td "President") (td "??") (td "-") (td "Clinton")) ) (p) (a 'href "../goerlitz.html" "Top level lecture page") ) ) ) |
|
An abstracted version Slide Note Contents Index References |
Program: An abstracted version of the previous example. | (load "html4-extended-loading-stuff.scm") (html-write (html-page "Another LAML Example" (table-by-rows 1 (row "" "Germany" "Denmark" "USA") (row "Currency" "DMark" "Kroner" "Dollar") (row "Prime minister" "Schröder" "Rasmussen" "-") (row "President" "??" "-" "Clinton") ) (p) (a-tag "../goerlitz.html" "Top level lecture page") ) ) |
Program: The loading stuff used by the abstracted LAML example above. | (load (string-append laml-dir "laml.scm")) (lib-load "html4.0-loose/basis.scm") (lib-load "html4.0-loose/surface.scm") (lib-load "html4.0-loose/convenience.scm") (lib-load "file-read.scm") (define (html-write html-string) (write-text-file html-string (string-append (startup-directory) (source-filename-without-extension) "." "html") ) ) (define row list) (define (html-page ttl . body-forms) (html (title ttl) (apply body (cons (h1 ttl) body-forms)))) ; Assume at least one row (define (table-by-rows border . rows) (let ((first-row (car rows)) (other-rows (cdr rows))) (html4:table (string-append (table-row first-row #t) (apply string-append (map (lambda (row) (table-row row #f)) other-rows))) 'border border))) (define (table-row lst header?) (html4:tr (apply string-append (map (lambda (cell) ((if header? html4:th html4:td) (as-string cell))) lst)))) |
Exercise 1.1. A tabular function | Make a WWW page with a table that maps n to fak(n), fib(n), or another similar function for n running from 1 to a constant N. The WWW page should be generated from a Scheme program that uses LAML. Use one of the existing LAML table functions from the HTML4.0 convenience library. Example of a generated WWW page for fak between 1 and 20:
|
Exercise 1.2. A tabular list of input | Read a linear list of data from a file.
You can assume that the data is represented as a Lisp list. Present the data on HTML page using a table in one of the following ways:
You can assume that n is positive integer. Example: If we input the list (1 2 3 4 5 6 7 8) with n = 3 into columns we get the table
You can make your own table function, or you can use one of the table functions from LAML (in the convenience library). The table functions typically require a list of rows. You can program your own functions that make these rows from your input list, or you can use the function sublist-by-rows and sublist-by-columns (from the general library). |
|
Syntactic LAML issues Slide Note Contents Index References | The example from above raises a number of relevant syntactic issues, which we will discuss here and on the next page |
|
Syntax: We show the syntax of a tag application f on some text. The tag application passes the attributes a1 and a2 with given values |
|
Figure. A table shown four possible parameter profiles of HTML mirror functions in Scheme. We use the third possibility in our libraries and in our examples | ![]() |
|
The HTML4.0 Mirror in LAML Slide Note Contents Index References | We will here describe the HTML4.0 loose mirror in LAML |
|
Syntax: We show a contrast between HTML syntax and LAML syntax. The tag application passes the attributes a1 and a2 with given values |
|
|
Semi constant strings in Scheme Slide Note Contents Index References | When we compare an SGML family language with a Lisp family programming language we find some major syntactical differences. The observation about semi-constant strings is one of the most important |
|
Program: This is a typical HTML/XML fragment | <point> A text with a <a href="subsection/sec1.html">link</a> to a <b>subsection</b> </point> |
Program: Here we attempt to use a semi-constant string in Scheme. This does actually not make sense. | (point "A text with a (a "link" 'href "subsection/sec.html") to a (b "subsection") ") |
Program: Here we see the solution we use in all our examples. This uses a plain Scheme programming approach. | (point (string-append "A text with a " (a "link" 'href "subsection/sec.html") " to a " (b "subsection"))) |
|
Abstractions in LAML Slide Note Contents Index References | We now return to one of the main points of the talk, namely how to take advantage of abstraction in an LAML document. Notices that similar things can be done in XML. |
|
Program: A complete LAML WWW page. We have introduced a number of 'ad hoc' abstractions, the implementation of which is shown below. | (load (string-append laml-dir "laml.scm")) (style "simple-html4.0-loose") (load (string-append (startup-directory scheme-system) "functions.scm")) (generic-page-1 "Demonstration of abstractions" (con (standard-intro "My FAQ") (ul-1 (map present-faq-entry (list (faq-entry 'teacher "What is Lisp" "Lisp is a list processing language...") (faq-entry 'student "What is LAML" "LAML is Scheme in which HTML is mirrored...") (faq-entry 'student "What is the main differences between Scheme and Lisp" "Scheme is a relatively small, but powerful Lisp dialect...") ))) (standard-signature) ) white black blue blue ) |
|
Program: The implementation of the abstractions. | ![]() |
|
URL abstraction Slide Note Contents Index References | We will here mention a very useful area of abstraction, namely the possibility to abstracts from part of the details in an URL |
|
|
|
Overview of LAML styles Slide Note Contents Index References | An LAML style represents a collection of related abstractions, which supports authoring of documents in a particular domain. This page gives an overview of existing document styles in LAML |
|
|
|
Example of the manual document style Slide Note Contents Index References | The manual styles is oriented towards documentation of the external and programmatic aspect of a Scheme program |
|
Program: This shows an excerpt of a typical manual style LAML document. Actually, the excerpt is taken from the manual which document the manual facility itself. This is a little circular, but quite realistic. Using the nearby cross reference you can see the resulting WWW page | ; Top level functions (manual-section (section-title "Top level functions") (section-body "The important top level functions are manual-page and manual-section. These are the most important functions from a manual writer's perspective.")) (manual-page 'manual-page (title "manual-page") (form '(manual-page id . elements)) (description "Defines a manual entry.") (parameters (parameter "id" "A symbol identifying the manual page") (parameter "elements" "Zero, one or more title, form, pre-condition, description, parameters, example, or misc elements") ) ) (manual-page 'manual-section (title "manual-section") (form '(manual-section . element)) (description "Defines a new section of a manual. The only forms allowed within a manual section are manual-title and manual-body") (parameters (parameter "elements" "a list of manual-title and manual-body forms") ) ) ; End top level functions |
|
Example of the lecture note document style Slide Note Contents Index References | On this page we show an example of the most substantial LAML document style developed to date. It is called LENO: A lecture note style. The slides you are looking at right now are written in LENO. Therefore we show the underlying LENO source of this page to illustrate our approach. |
|
Program: This is the LAML expression which generates the current slide. You can easily recognize the point clauses above and below. The source-program clause inserts the large middle LAML document excerpt. | (note-page 'leno-ex (title "Example of the lecture note document style" "On this page we show an example of the most substantial LAML document style developed to date. It is called LENO: A lecture note style. The slides you are looking at right now are written in LENO. Therefore we show the underlying LENO source of this page to illustrate our approach." ) (point "These slides are written in LAML by means of the lecture note style" "" ) (source-program "goerlitz.laml" (list "(note-page 'leno-ex" demo-end-mark) (list (list "note-page" "" level-1-color 'bold) (list "title" "" level-2-color 'bold) (list point-form "" level-2-color 'bold 2) (list "source-program" "" level-2-color 'bold) (list index-word-form "" level-2-color 'bold) ) (list 'slide-inline 'book-inline) "This is the LAML expression which generates the current slide. You can easily recognize the point clauses above and below. The source-program clause inserts the large middle LAML document excerpt." ) (point "The program excerpt above is taken directly from the LAML source of these slides" "" ) (index-words "LENO" "Lecture note style (example of)") ) ; end leno-ex |
|
Example of the Elucidator document style Slide Note Contents Index References | As the last LAML document style we take a look at the Scheme Elucidator style. |
|
|
|
Automation with LAML Slide Note Contents Index References | We now turn to the other main point of the LAML approach. This is the possibility to automate routine tasks in the authoring process via programmed solutions. |
|
|
|
Insertion of quotations from external files Slide Note Contents Index References | Here we illustrate how to insert excerpts from external files into a note page (a slide). We have used this facility several times in this set of slides already presented |
|
Program: The application of the Scheme functions which returns a selected part of an external file | (read-text-file-between-marks file-path mark) |
Program: A variant of the function shown above which includes the marks in the extracted text string | (read-text-file-including-marks file-name start-mark end-mark) |
Program: Additional superimposition of colors and fonts, as specified by font-and-color-specification | (colorize-substrings (read-text-file-between-marks file-path mark) font-and-color-specification) |
|
Overview of LAML tools Slide Note Contents Index References |
|
|
|
An example of an LAML tool: SchemeDoc Slide Note Contents Index References | We illustrate the ideal of an LAML with the SchemeDoc tool. This tool is inspired from JavaDoc and similar tools. |
|
|
Figure. This figure illustrates the process implemented by the SchemeDoc tool. The main idea is to translate the lexical Lisp comments to syntactic elements. Given this, it is easy to parse the translated program and to extract the relevant comments | ![]() |
An Emacs-based LAML environment Slide Note Contents Index References | We here briefly discuss an LAML environment in which the Emacs text editor plays an important role |
|
|
|
Conclusions: The LAML approach Slide Note Contents Index References | An finally the conclusions based on or LAML work until now |
|
|
Source files in this lecture Contents Index References | ../../examples/simple-pages/simple-page-1.laml includes/html4-demo.laml includes/html4-loading-stuff.scm includes/html4-another-demo.laml includes/html4-another-demo-abstracted.laml includes/html4-extended-loading-stuff.scm includes/abstraction-demo.laml includes/functions.scm ../../styles/manual/man/manual.laml goerlitz.laml includes/quote-1 includes/quote-3 includes/quote-2 |
LAML
Course home Author home About producing this web Previous lecture (top) Next lecture (top) Previous lecture (bund) Next lecture (bund)
Generated: March 15, 2001, 15:17:24