From 50dc7bb79af62b819648c67c5ccd33b3470e626c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 10 Mar 2018 21:41:36 -0500 Subject: Add Haunt manual. --- manuals/haunt/Reader.html | 179 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 manuals/haunt/Reader.html (limited to 'manuals/haunt/Reader.html') diff --git a/manuals/haunt/Reader.html b/manuals/haunt/Reader.html new file mode 100644 index 0000000..e7a3f1a --- /dev/null +++ b/manuals/haunt/Reader.html @@ -0,0 +1,179 @@ + + + + + + +Reader (Haunt Reference Manual) + + + + + + + + + + + + + + + + + + + +
+

+Next: , Up: Readers   [Contents][Index]

+
+
+ +

5.3.1 Reader

+
+
(use-modules (haunt reader))
+
+ +

The purpose of a reader is to translate the markup within a post file +into an SXML tree representing the HTML structure and associate some +metadata with it. +

+
+
Scheme Procedure: make-reader matcher proc
+

Create a new reader. The reader is to be activated when +matcher, a procedure that accepts a file name as its only +argument, returns #t. When a post file matches, the procedure +proc, which also accepts a file name as its only argument, reads +the contents and returns a post object (see Posts). +

+ +
+
Scheme Procedure: reader? object
+

Return #t if object is a reader. +

+ +
+
Scheme Procedure: reader-matcher reader
+

Return the match procedure for reader. +

+ +
+
Scheme Procedure: reader-proc reader
+

Return the read procedure for reader. +

+ +
+
Scheme Procedure: reader-match? reader file-name
+

Return #t if file-name is a file supported by +reader. +

+ +
+
Scheme Procedure: read-post reader file-name [default-metadata]
+

Read a post object from file-name using reader, merging +its metadata with default-metadata, or the empty list if not +specified. +

+ +
+
Scheme Procedure: read-posts directory keep? readers [default-metadata]
+

Read all of the files in directory that match keep? as +post objects. The readers list must contain a matching reader +for every post. +

+ +
+
Scheme Procedure: make-file-extension-matcher ext
+

Create a procedure that returns #t when a file name ends with +“.ext”. +

+ +
+
Scheme Procedure: sxml-reader
+

A basic reader for posts written as Scheme code that evaluates to an +an association list. The special key content contains the post +body as an SXML tree. +

+

Example: +

+
+
(use-modules (haunt utils))
+
+`((title . "Hello, world!")
+  (date . ,(string->date* "2015-04-10 23:00"))
+  (tags "foo" "bar")
+  (summary . "Just a test")
+  (content
+   ((h2 "Hello!")
+    (p "This is Haunt.  A static site generator for GNU Guile."))))
+
+ +
+ +
+
Scheme Procedure: html-reader
+

A basic reader for posts written in plain ol’ HTML. Metadata is +encoded as the key: value pairs, one per line, at the beginning +of the file. A line with the --- sentinel marks the end of the +metadata section and the rest of the file is encoded as HTML. +

+

Example: +

+
+
title: A Foo Walks Into a Bar
+date: 2015-04-11 20:00
+tags: bar
+---
+<p>
+  This is an example using raw HTML, because Guile doesn't have a
+  Markdown parser.
+</p>
+
+ +
+ +
+
+

+Next: , Up: Readers   [Contents][Index]

+
+ + + + + -- cgit v1.2.3