summaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo.scm6
-rw-r--r--src/guile/skribilo/package/base.scm18
-rw-r--r--src/guile/skribilo/parameters.scm3
-rw-r--r--src/guile/skribilo/sui.scm57
4 files changed, 52 insertions, 32 deletions
diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm
index 44e57e4..d69ae32 100644
--- a/src/guile/skribilo.scm
+++ b/src/guile/skribilo.scm
@@ -74,6 +74,7 @@ specified reader syntax, and produce its output using the specified engine.
-B, --bib-path=DIR Prepend DIR to the bibliography include path.
-S, --source-path=DIR Prepend DIR to the source include path.
-P, --image-path=DIR Prepend DIR to the image include path.
+ -U, --sui-path=DIR Prepend DIR to the Skribe URL Index (SUI) search path.
-b, --base=BASE Strip BASE from all hyperlinks (`html' engine).
-e, --eval=EXPR Prepend EXPR to the list of expressions to be
@@ -182,6 +183,8 @@ Report bugs to <~a>.~%"
(make-path-processor :source-path))
(option '(#\P "image-path") #t #f
(make-path-processor :image-path))
+ (option '(#\U "sui-path") #t #f
+ (make-path-processor :sui-path))
(option '(#\b "base") #t #f
(lambda (opt name arg result)
@@ -238,6 +241,7 @@ Report bugs to <~a>.~%"
(:bib-path ".")
(:source-path ".")
(:image-path ".")
+ (:sui-path ".")
(:watched-symbols)))
(define (parse-args args)
@@ -278,6 +282,7 @@ options."
(bib-path (assoc-ref options :bib-path))
(source-path (assoc-ref options :source-path))
(image-path (assoc-ref options :image-path))
+ (sui-path (assoc-ref options :sui-path))
(compat (assoc-ref options :compat))
(preloads (assoc-ref options :preloads))
;;(variants '()) ;; FIXME: Implement
@@ -301,6 +306,7 @@ options."
(*bib-path* bib-path)
(*source-path* source-path)
(*image-path* image-path)
+ (*sui-path* sui-path)
(*debug* debugging-level)
(*debug-use-colors?* color?)
(*watched-symbols* watched-symbols)
diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm
index 8462e81..fc6abca 100644
--- a/src/guile/skribilo/package/base.scm
+++ b/src/guile/skribilo/package/base.scm
@@ -30,7 +30,7 @@
:autoload (srfi srfi-1) (every any filter)
:autoload (skribilo evaluator) (include-document)
:autoload (skribilo engine) (engine?)
- :autoload (skribilo parameters)(*document-path*)
+ :autoload (skribilo parameters)(*document-path* *sui-path*)
;; optional ``sub-packages''
:autoload (skribilo biblio) (*bib-table* resolve-bib
@@ -1087,15 +1087,13 @@
(options `((kind ,kind) ,@(the-options opts :ident :class)))
(body text))))))
(define (skribe-ref skribe)
- (let ((path (search-path (*document-path*) skribe)))
- (if (not path)
- (unref #f skribe 'sui-file)
- (let* ((sui (load-sui path))
- (os (the-options opts :skribe :class :text))
- (u (sui-ref->url (dirname path) sui ident os)))
- (if (not u)
- (unref #f os 'sui-ref)
- (ref :url u :text text :ident ident :class class))))))
+ (let* ((sui (load-sui skribe))
+ (os (the-options opts :skribe :class :text))
+ (u (sui-ref->url (search-path (*sui-path*) skribe)
+ sui ident os)))
+ (if (not u)
+ (unref #f os 'sui-ref)
+ (ref :url u :text text :ident ident :class class))))
(define (handle-ref text)
(new markup
(markup 'ref)
diff --git a/src/guile/skribilo/parameters.scm b/src/guile/skribilo/parameters.scm
index 5893851..23c2c1a 100644
--- a/src/guile/skribilo/parameters.scm
+++ b/src/guile/skribilo/parameters.scm
@@ -1,6 +1,6 @@
;;; parameters.scm -- Skribilo settings as parameter objects.
;;;
-;;; Copyright 2005 Ludovic Courtès <ludovic.courtes@laas.fr>
+;;; Copyright 2005, 2008 Ludovic Courtès <ludo@gnu.org>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -67,6 +67,7 @@
(define-path-parameter *bib-path*)
(define-path-parameter *source-path*)
(define-path-parameter *image-path*)
+(define-path-parameter *sui-path*)
;;;
diff --git a/src/guile/skribilo/sui.scm b/src/guile/skribilo/sui.scm
index 8dc1a9e..304ae8c 100644
--- a/src/guile/skribilo/sui.scm
+++ b/src/guile/skribilo/sui.scm
@@ -1,7 +1,7 @@
-;;; sui.scm
+;;; sui.scm -- Skribe URL Indices
;;;
+;;; Copyright 2005, 2006, 2007, 2008 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Manuel Serrano
-;;; Copyright 2005, 2006, 2007 Ludovic Courtès <ludovic.courtes@laas.fr>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -22,17 +22,21 @@
(define-module (skribilo sui)
:use-module (skribilo lib)
:use-module (skribilo ast)
- :autoload (skribilo parameters) (*verbose* *destination-file*)
+ :autoload (skribilo parameters) (*verbose* *destination-file*
+ *sui-path*)
:autoload (skribilo reader) (make-reader)
:autoload (skribilo engine) (find-engine)
:autoload (skribilo evaluator) (evaluate-document)
:autoload (skribilo engine html)(html-file)
+ :autoload (skribilo condition) (&file-search-error)
:use-module (skribilo utils strings)
:use-module (skribilo utils syntax)
:use-module (skribilo utils files)
:use-module (ice-9 match)
:use-module (srfi srfi-1)
+ :use-module (srfi srfi-34)
+ :use-module (srfi srfi-35)
:export (load-sui sui-ref->url sui-title sui-file sui-key
sui-find-ref sui-search-ref sui-filter
@@ -40,7 +44,8 @@
(fluid-set! current-reader %skribilo-module-reader)
-;;; Author: Manuel Serrano
+
+;;; Author: Manuel Serrano, Ludovic Courtès
;;; Commentary:
;;;
;;; Library dealing with Skribe URL Indexes (SUI).
@@ -55,6 +60,7 @@
;*---------------------------------------------------------------------*/
;* *sui-table* ... */
;*---------------------------------------------------------------------*/
+;; FIXME: Remove global state.
(define *sui-table* (make-hash-table))
;*---------------------------------------------------------------------*/
@@ -63,29 +69,33 @@
;* Returns a SUI sexp if already loaded. Load it otherwise. */
;* Raise an error if the file cannot be open. */
;*---------------------------------------------------------------------*/
-(define (load-sui path)
- (let ((sexp (hash-ref *sui-table* path)))
- (or sexp
- (begin
- (when (> (*verbose*) 0)
+(define (load-sui file)
+ (let* ((path (search-path (*sui-path*) file))
+ (sexp (and path (hash-ref *sui-table* path))))
+ (if (not path)
+ (raise (condition (&file-search-error (file-name file)
+ (path (*sui-path*)))))
+ (or sexp
+ (begin
+ (when (> (*verbose*) 0)
(format (current-error-port) " [loading sui: ~a]\n" path))
- (let ((p (open-input-file path))
- (read (make-reader 'skribe)))
+ (let ((p (open-input-file path))
+ (read (make-reader 'skribe)))
(if (not (input-port? p))
(skribe-error 'load-sui
"Can't find `Skribe Url Index' file"
path)
(unwind-protect
- (let ((sexp (read p)))
- (match sexp
- (('sui (? string?) . _)
- (hash-set! *sui-table* path sexp))
- (else
- (skribe-error 'load-sui
- "Illegal `Skribe Url Index' file"
- path)))
- sexp)
- (close-input-port p))))))))
+ (let ((sexp (read p)))
+ (match sexp
+ (('sui (? string?) . _)
+ (hash-set! *sui-table* path sexp))
+ (else
+ (skribe-error 'load-sui
+ "Illegal `Skribe Url Index' file"
+ path)))
+ sexp)
+ (close-input-port p)))))))))
;*---------------------------------------------------------------------*/
;* sui-ref->url ... */
@@ -266,3 +276,8 @@
(display ")"))
(container-search-down (lambda (n) (is-markup? n kind)) n))
(display ")\n"))
+
+
+;;; Local Variables:
+;;; coding: latin-1
+;;; End: