HLML is a expirmental new markup language/scripting environment
First, some basic concepts of writing code in a lisp:
- Atoms:
Things like
3"hello"evaluate to themselves, and are basic atoms. - Symbols:
Things written
fare the “symbol”f. Evaluating a symbol causes it to be looked up in the enviornment and replaced with their definiton. - Lists:
Writing
(f 2 3)is the list containing1,2, &3. Evaluating this list causesfto be interpreted as a function, and2,3, to be interpreted as arguments.(f 2 3)is equivalent to writingf(2,3)in most languages.Example:
(+ 1 2)evaluates to3.This means you cannot write the list consisting of 1,2,3 as
(1 2 3), as when evaluated, this will treat1as a function, which it’s not, and will thus cause a type error.If you want to produce a list instead of calling a function, use the
listfunction:(list 1 2 3)evaluates to(1 2 3). - Quoting:
This is were things get lispy. There are is a builtin form called
quotethat prevents its arguments from being evaluated. So evaluating(quote x)getsx, regardless of whatxis defined as, or if it’s defined at all. This can be used to make lists:(quote (1 2 3))is equivalent to(list 1 2 3), as quote stops the evaluation, so1does not get treated as a fucntion. However(quote (1 (+ 1 1) 3))is not equivalent to(list 1 (+ 1 1) 3).quotestops all evaluation, so the former evalutes to(1 (+ 1 1) 3), whereas normal functions evaluate their aguments, producing:(1 2 3).In addition to
quote, there are the formsquasiquoteandunquote, shortcutted to`and,respectivly. These allow you to conditionally resume evaluation. For example:`(1 ,(+ 2 3) 3)evaluates to(1 5 3). - Useful builtins:
define-> Defines a variable:(define x 3) (+ x 2)evaluates to5define-> Define a fucntion(define (add1 x) (+ 1 x)) (add1 3)evaluates to4list-> produce a listmap-> maps a function over a list:(map add1 (list 1 2 3))evaluates to(2 3 4)
HLML looks fairly similar to HTML but using lisp syntax. So to use the b tag, you’d write:
(b Here is my text in bold). Tag attributes are specified by following a tag with the following
list: (attr (name value) ...), for example: (a (attr (href "google.com")) Link to google).
Scripting support is enabled by the script tag. Scripts can create hlml objects by just making
symbols with quote.
An example hlml file is provided in test.hlml
The file hlml.rkt is a prototype implementation of the language.
To use it, run racket hlml.rkt <file>, which will evaluate the script calls and produce the
final hlml represesntation.
Run racket hlml.rkt -o <file> to compile hlml to html, to view in a browser.
Features remaining to implemented:
Mutation, scripts not allowed to mutate the page yet. Big feature.
Attribute syntax: Does this syntax work nicely, or is it annoying?
(Maybe it should be ((a (href "example.com")) click))
CSS?