From 1a86155662784bc2ce3df6668e230941067189c5 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 8 Nov 2024 22:56:15 +0200 Subject: [PATCH] Join strings into one string --- pandoc/pandoc.r5rs.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pandoc/pandoc.r5rs.scm b/pandoc/pandoc.r5rs.scm index 6dfb501..3965a17 100644 --- a/pandoc/pandoc.r5rs.scm +++ b/pandoc/pandoc.r5rs.scm @@ -10,6 +10,13 @@ (cons (car list) new-list)) (cdr list))))) +(define (join-strings-into-one-string list) + (let loop ((result "") (tail list)) + (cond ((null? tail) result) + ((string? (car tail)) (loop (string-append result (car tail)) + (cdr tail))) + (else (error "Expected all strings" list))))) + (define (vector-refs vec . indexes) (let loop ((obj vec) (indexes indexes)) (if (null? indexes) obj @@ -40,9 +47,9 @@ ((equal? type "Code") `(code ,@(convert-many (cdr (contents-list))))) ((equal? type "CodeBlock") - `(pre (@ (data-syntax ,@(join-adjacent-strings - (vector->list - (vector-refs (contents) 0 1))))) + `(pre (@ (data-syntax ,(join-strings-into-one-string + (vector->list + (vector-refs (contents) 0 1))))) ,@(convert-many (cdr (contents-list))))) ((equal? type "Emph") `(em ,@(convert-many (contents-list)))) @@ -62,7 +69,7 @@ ,(join-strings-into-one-string (vector->list (vector-ref (contents) 1))))))) ((equal? type "Link") - `(a (@ (href ,(join-adjacent-strings + `(a (@ (href ,(join-strings-into-one-string (vector->list (vector-ref (contents) 2))))) ,@(convert-many (vector->list (vector-ref (contents) 1))))) ((equal? type "Plain")