diff options
author | Ludovic Court`es | 2007-03-28 08:48:01 +0000 |
---|---|---|
committer | Ludovic Court`es | 2007-03-28 08:48:01 +0000 |
commit | 8518f2cf57d353c541b9a393e85a7ee34c321bd5 (patch) | |
tree | 08ad63698e15eb849dce835684712bf72d01c20b /src | |
parent | 97305e584f34ed7eeda7a0dff36db71274d4c561 (diff) | |
parent | f3499346871c1234795da242add35c4cdb520964 (diff) | |
download | skribilo-8518f2cf57d353c541b9a393e85a7ee34c321bd5.tar.gz skribilo-8518f2cf57d353c541b9a393e85a7ee34c321bd5.tar.lz skribilo-8518f2cf57d353c541b9a393e85a7ee34c321bd5.zip |
`diff' package: Compute diffs on selected options.
* src/guile/skribilo/package/diff.scm (%diffable-options): New.
(make-diff-document)[make-diff-options]: New.
Use it.
git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-70
Diffstat (limited to 'src')
-rw-r--r-- | src/guile/skribilo/package/diff.scm | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/guile/skribilo/package/diff.scm b/src/guile/skribilo/package/diff.scm index 15fdcf2..3aeed08 100644 --- a/src/guile/skribilo/package/diff.scm +++ b/src/guile/skribilo/package/diff.scm @@ -189,6 +189,10 @@ toc index &index-entry &the-index &the-index-header)) +(define %diffable-options + ;; List of diffable options. + '(:title :text)) + (define (annotated-string-diff str1 str2) ;; Return a list (actually an AST) denoting the differences between STR1 ;; and STR2. The returned text is actually that of STR2 augmented with @@ -218,6 +222,18 @@ (define (undiffable? kind) (memq kind %undiffable-markups)) + (define (make-diff-options m1 m2 loop) + ;; Return a list of options based on that of markup M2. + (map (lambda (opt+val) + (let ((opt (car opt+val))) + (if (memq opt %diffable-options) + (cons opt + (loop (markup-option m1 opt) + (cdr opt+val))) + opt+val))) + (markup-options m2))) + + (let loop ((ast1 ast1) (ast2 ast2)) ;;(format (current-error-port) "diff: ~a ~a~%" ast1 ast2) @@ -252,14 +268,16 @@ ((container? ast2) (let ((kind (markup-markup ast2)) (ident (markup-ident ast2)) - (opts (markup-options ast2)) (class (markup-class ast2)) (body (markup-body ast2))) (new container (markup kind) (ident ident) (class class) - (options opts) + (options (if (or (undiffable? kind) + (not (container? ast1))) + (markup-options ast2) + (make-diff-options ast1 ast2 loop))) (body (if (undiffable? kind) body (loop (if (and (container? ast1) @@ -271,14 +289,16 @@ ((markup? ast2) (let ((kind (markup-markup ast2)) (ident (markup-ident ast2)) - (opts (markup-options ast2)) (class (markup-class ast2)) (body (markup-body ast2))) (new markup (markup kind) (ident ident) (class class) - (options opts) + (options (if (or (undiffable? kind) + (not (markup? ast1))) + (markup-options ast2) + (make-diff-options ast1 ast2 loop))) (body (if (undiffable? kind) body (loop (if (is-markup? ast1 kind) |