From d3a9ba4ebea136fae676911148509ec3f729abbc Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 24 Apr 2016 15:26:44 -0400 Subject: website: Add copy of HTML manual. --- website/manual/Readers.html | 181 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 website/manual/Readers.html (limited to 'website/manual/Readers.html') diff --git a/website/manual/Readers.html b/website/manual/Readers.html new file mode 100644 index 0000000..b0e2f18 --- /dev/null +++ b/website/manual/Readers.html @@ -0,0 +1,181 @@ + + + + + +Haunt Reference Manual: Readers + + + + + + + + + + + + + + + + + + + + +
+

+Next: , Previous: , Up: Programming Interface   [Contents][Index]

+
+
+ +

5.3 Readers

+ +
+
(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-matcher 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: , Previous: , Up: Programming Interface   [Contents][Index]

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