summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Alpha/String.scm7
-rw-r--r--re.scm8
-rw-r--r--z.scm26
3 files changed, 27 insertions, 14 deletions
diff --git a/Alpha/String.scm b/Alpha/String.scm
index c7ad61f..4e32856 100644
--- a/Alpha/String.scm
+++ b/Alpha/String.scm
@@ -1,5 +1,10 @@
(define-module (Alpha String)
- #:export (replace replace-char to-string str capitalize))
+ #:export (replace replace-char to-string str capitalize split))
+
+(define (split s c)
+ (if s
+ (string-split s c)
+ #f))
(define (replace-char s match repl)
(let ((f (lambda (a b)
diff --git a/re.scm b/re.scm
index b4f3dca..f6f4b75 100644
--- a/re.scm
+++ b/re.scm
@@ -1,7 +1,11 @@
#!r6rs
(library (re (0))
- (export match)
+ (export match group)
(import (rnrs base (6))
(ice-9 regex))
(define (match s pat)
- (string-match pat s)))
+ (string-match pat s))
+ (define (group m n)
+ (if m
+ (match:substring m n)
+ #f)))
diff --git a/z.scm b/z.scm
index 6e8972a..c318d9a 100644
--- a/z.scm
+++ b/z.scm
@@ -95,7 +95,7 @@
(define (cat-node id)
(prn (read-node id)))
-;; Indexing
+;; Metadata
(define (get-title id)
(-> id
@@ -103,17 +103,21 @@
(re.match "title: ([^\n]*)")
(match:substring 1)))
-(define (index-titles)
- (fold
- (lambda (node ls) (acons (get-title node) node ls))
- '()
- (list-nodes)))
-
(define (get-by-title title)
(let ([index (index-titles)])
(assoc title index)))
-(comment
- (define index-tags)
- (define index-links)
- )
+(define (get-tags id)
+ (-> id
+ read-node
+ (re.match "tags: ([^\n]*)")
+ (re.group 1)
+ (string.split #\space)))
+
+;; Indexing
+
+(define (index-titles)
+ (fold
+ (/. node ls (acons (get-title node) node ls))
+ '()
+ (list-nodes)))