From 272de5b9dc48596d0c3776cf3e9e7acf49655136 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Fri, 21 Jul 2006 13:33:30 +0000 Subject: Added support for the `:keywords' option of `document' (Lout + HTML). * NEWS: Mention it. * doc/user/document.skb: Document it. * doc/user/user.skb (document): Added keywords. Slightly modified the introduction. * src/guile/skribilo/engine/html.scm (document): Added `:keywords' to the list of supported options. (&html-head): Reformatted. (&html-meta): New. (&html-generic-document): Use it. * src/guile/skribilo/engine/lout.scm: Document `pdf-keywords' as deprecated. (lout-pdf-docinfo): Check the `:keywords' option. (document): Mention it as supported. * src/guile/skribilo/skribe/api.scm (document): Added the `keywords' option. (keyword-list->comma-separated): New (stolen from Lout). git-archimport-id: lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-20 --- NEWS | 5 ++++- doc/user/document.skb | 4 ++++ doc/user/user.skb | 6 +++++- src/guile/skribilo/engine/html.scm | 30 ++++++++++++++++++++++++------ src/guile/skribilo/engine/lout.scm | 28 +++++++++++----------------- src/guile/skribilo/skribe/api.scm | 16 +++++++++++++++- 6 files changed, 63 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index e9b5c33..5ac9227 100644 --- a/NEWS +++ b/NEWS @@ -6,4 +6,7 @@ New in Skribilo 1.2 (compared to Skribe 1.2d) * New markups: `~', `numref', `!lout', `lout-illustration'. - * Extended markups: `footnote' now takes a `:label' option. + * Extended markups: + + - `footnote' now takes a `:label' option. + - `document' now takes a `:keywords' option. diff --git a/doc/user/document.skb b/doc/user/document.skb index 5797da8..8521af0 100644 --- a/doc/user/document.skb +++ b/doc/user/document.skb @@ -39,6 +39,10 @@ (:html-title "The title of window of the HTML browser.") (:author "The authors of the document.") (:ending "An ending text.") + (:keywords "A list of keywords which may be plain strings +or markups. The keywords will not appear in the final document but only +as meta-information (e.g., using the HTML `meta' tag) if the engine used +supports it.") (:env "A counter environment.") (#!rest node... "The document nodes.")) :see-also '(author chapter toc)) diff --git a/doc/user/user.skb b/doc/user/user.skb index f6a25ef..a8054e3 100644 --- a/doc/user/user.skb +++ b/doc/user/user.skb @@ -49,6 +49,8 @@ ;* The document */ ;*---------------------------------------------------------------------*/ (document :title "Skribilo User Manual" + :keywords '("Skribilo" "Skribe" "User Manual" "text processing" + "HTML" "LaTeX" "Lout" "PostScript" "PDF") :env '((example-counter 0) (example-env ())) :author (list (author :name "Erick Gallesio" :affiliation "Université de Nice - Sophia Antipolis" @@ -79,7 +81,9 @@ produce a high-quality printed document, and so on.] Everyone needing to design web pages, info documents, man pages or Postscript files can use Skribe. In particular, there is ,(bold "no need") for programming skills in order to use Skribe. Skribe can be used as -any text description languages such as TeX, LaTeX or HTML.]) +any text description languages such as ,(ref :text [LaTeX] :url +"http://latex-project.org/"), ,(ref :text [Lout] :url +"http://lout.sf.net/") or HTML.]) (section :title "Why using Skribe?" :number #f [ There are three main reasons for using Skribe:] diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm index 4ba058a..15bea53 100644 --- a/src/guile/skribilo/engine/html.scm +++ b/src/guile/skribilo/engine/html.scm @@ -572,7 +572,7 @@ ;* document ... */ ;*---------------------------------------------------------------------*/ (markup-writer 'document - :options '(:title :author :ending :html-title :env) + :options '(:title :author :ending :html-title :env :keywords) :action (lambda (n e) (let* ((id (markup-ident n)) (title (new markup @@ -601,12 +601,22 @@ ;*---------------------------------------------------------------------*/ (markup-writer '&html-head :before (lambda (n e) - (printf "\n") - (printf "\n" (engine-custom (find-engine 'html) - 'charset))) + (printf "\n") + (printf "\n" (engine-custom (find-engine 'html) + 'charset))) :after "\n\n") +;*---------------------------------------------------------------------*/ +;* &html-meta ... */ +;*---------------------------------------------------------------------*/ +(markup-writer '&html-meta + :before "string (or (markup-body n) '())))) + (output (keyword-list->comma-separated kw*) e))) + :after "\">\n") + ;*---------------------------------------------------------------------*/ ;* &html-body ... */ ;*---------------------------------------------------------------------*/ @@ -1190,12 +1200,20 @@ (class (markup-class n)) (parent n) (body (html-browser-title n)))) + (meta (new markup + (markup '&html-meta) + (ident (string-append id "-meta")) + (class (markup-class n)) + (parent n) + (body (markup-option n :keywords)))) (head (new markup (markup '&html-head) (ident (string-append id "-head")) (class (markup-class n)) + (options (the-options (list :keywords + (markup-option n :keywords)))) (parent n) - (body header))) + (body (list header meta)))) (ftnote (new markup (markup '&html-footnotes) (ident (string-append id "-footnote")) diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm index 3b62224..294a528 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -642,7 +642,8 @@ (pdf-author #t) ;; Keywords (a list of string) in the PDF - ;; document information. + ;; document information. This custom is deprecated, + ;; use the `:keywords' option of `document' instead. (pdf-keywords #f) ;; Extra PDF information, an alist of key-value @@ -812,15 +813,10 @@ (if (or (string? t) (ast? t)) t (markup-option doc :title)))) - (keywords (engine-custom engine 'pdf-keywords)) - (extra-fields (engine-custom engine 'pdf-extra-info)) - (stringify-kw (lambda (kws) - (let loop ((kws kws) (s "")) - (if (null? kws) s - (loop (cdr kws) - (string-append s (car kws) - (if (pair? (cdr kws)) - ", " "")))))))) + (keywords (or (engine-custom engine 'pdf-keywords) + (map ast->string (markup-option doc :keywords)))) + (extra-fields (engine-custom engine 'pdf-extra-info))) + (string-append "[ " (if title (docinfo-field "Title" (ast->string title)) @@ -837,13 +833,11 @@ (else (ast->string author))) "")) "") - (if keywords + (if (pair? keywords) (docinfo-field "Keywords" - (cond ((string? keywords) - keywords) - ((pair? keywords) - (stringify-kw keywords)) - (else ""))) + (apply string-append + (keyword-list->comma-separated + keywords))) "") ;; arbitrary key-value pairs, see sect. 4.7, "Info ;; dictionary" of the `pdfmark' reference. @@ -975,7 +969,7 @@ ;* document ... */ ;*---------------------------------------------------------------------*/ (markup-writer 'document - :options '(:title :author :ending :env) + :options '(:title :author :ending :keywords :env) :before (lambda (n e) ;; `e' is the engine (let* ((doc-type (let ((d (engine-custom e 'document-type))) (if (string? d) diff --git a/src/guile/skribilo/skribe/api.scm b/src/guile/skribilo/skribe/api.scm index 2a4d0ae..df73427 100644 --- a/src/guile/skribilo/skribe/api.scm +++ b/src/guile/skribilo/skribe/api.scm @@ -51,7 +51,7 @@ #!key (ident #f) (class "document") (title #f) (html-title #f) (author #f) - (ending #f) (env '())) + (ending #f) (keywords '()) (env '())) (new document (markup 'document) (ident (or ident @@ -67,6 +67,20 @@ (list 'footnote-counter 0) (list 'footnote-env '()) (list 'figure-counter 0) (list 'figure-env '())))))) +;*---------------------------------------------------------------------*/ +;* keyword-list->comma-separated ... */ +;*---------------------------------------------------------------------*/ +(define-public (keyword-list->comma-separated kw*) + ;; Turn the the list of keywords (which may be strings or other markups) + ;; KW* into a markup where the elements of KW* are comma-separated. This + ;; may commonly be used in handling the `:keywords' option of `document'. + (let loop ((kw* kw*) (result '())) + (if (null? kw*) + (reverse! result) + (loop (cdr kw*) + (cons* (if (pair? (cdr kw*)) ", " "") + (car kw*) result))))) + ;*---------------------------------------------------------------------*/ ;* author ... */ ;*---------------------------------------------------------------------*/ -- cgit v1.2.3