1. Skribilo User Manual — Getting Started |
In this chapter, the syntax of a Skribilo text is presented informally. In particular, the Skribilo syntax is compared to the HTML syntax. Then, it is presented how one can use Skribilo to make dynamic text (i.e texts which are generated by the system rather than entered-in by hand). Finally, It is also presented how Skribilo source files can be processed.
In this section we show how to produce very simple electronic documents with Skribilo. Suppose that we want to produce the following Web document:
Let us suppose that we want now to colorize and change the face of some words such as:
For large documents there is an obvious need of structure. Skribilo documents may contain chapters, sections, subsections, itemize, ... For instance, if we want to extend our previous example to:
Hello World! 1. A first Section This is a very simple text. 2. A second Section That contains an itemize construction: . first item . second item . third item
(document :title [Hello World!] (chapter :title [A first Section] [This is a ,(bold [very]) ,(it [simple]) ,(color :fg [red] [text]).]) (chapter :title [A second Section] [That section contains an ,(bold [itemize]) construction: ,(itemize (item [first item]) (item [second item]) (item [third item]))]))
A Skribilo document may contain links to chapters, to sections, to other Skribilo documents or web pages. The following Skribilo source code illustrates these various kinds of links:
(document :title [Various Links] (chapter :title [A Section] [The first link points to an external web page. Here we point to a ,(ref :url "http://slashdot.org/" :text [Slashdot]) web page. The second one points to the second ,(ref :chapter "A Second Section" :text [section]) of that document.]) (chapter :title "A Second Section" [The last link points to the first ,(ref :skribe "user.sui" :chapter "Introduction" :text [chapter]) of the Skribilo User Manual.]))
Skribilo comes with extra features bundled in modules.
In fact, anyone can write new modules that extend Skribilo. For example, extra bibliography features are bundled in a module called
(skribilo biblio)
. To use them in a document, that document
the following line must be added at the very beginning of the document,
before the document
markup:
(skribilo package eq)
module. To do that, you can either add another
use-modules
form at the top of the document, or combine both:
The module system described above is actually that of GNU Guile. More information is available in Guile's manual.
Since Skribilo is a programming language, rather than just a markup language, it is easy to use it to generate some parts of a document. This section presents here the kind of documents that can be created with Skribilo.
In this section we present how to introduce a simple computation into a document. For instance, the following sentence
sqrt
to compute the square
root to be inserted in the document. In general, any valid Scheme
expression is authorized inside a ,(...)
construct.Another example of such a computation is given below.
When evaluated, this form produces the following output:When building a document, one often need to generate some repetitive text. Skribilo programming skills can be used to ease the construction of such documents as illustrated below.
In Skribilo, a document is represented by a tree which is available to the user. So, it is easy to perform introspective tasks on the current document. For instance the following code displays as an enumeration the sections titles of the current chapter:
(resolve (lambda (n e env) (let* ((current-chapter (ast-chapter n)) (body (markup-body current-chapter)) (sects (filter (lambda (x) (is-markup? x 'section)) body))) (itemize (map (lambda (x) (item (it (markup-option x :title)))) sects)))))
Without entering too much into the details here, the resolve function is called at the end of the document processing. This function searches the node representing the chapter to which belongs the current node and from it finds all its sections. The titles of these sections are put in italics in an itemize.
The execution of this code yield the following text:
There are several ways to render a Skribilo document. It can be statically compiled by the skribilo compiler to various formats such as HTML, LaTeX, Lout and so on. In this section we only present static ``document compilation''.
Let us suppose a Skribilo text located in a file file.skb. In order to compile to various formats one must type in:
$ skribilo --target=html file.skb -o file.html # This produces an HTML file. $ skribilo -t latex file.skb -o file.tex # This produces a TeX file. $ skribilo -t lout file.skb -o file.lout # This produces a Lout file.