From c86e1b4276fba6dd110dfb91ffead5707a77421d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 5 Nov 2021 23:20:54 +0530 Subject: doc: Support extracting specific forms from a scheme file. * doc/skribilo.scm (scheme-source-form): New public function. --- doc/skribilo.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/skribilo.scm b/doc/skribilo.scm index 22d31f9..cba6d08 100644 --- a/doc/skribilo.scm +++ b/doc/skribilo.scm @@ -38,6 +38,7 @@ #:export (command file scheme-source + scheme-source-form source-ref)) ;; Constants @@ -125,6 +126,18 @@ and END are line numbers indexed from 1." (number->string end-line))))) #:text text)) +;; Extract forms from scheme source +(define (scheme-source-form file regexp) + "Extract form from scheme source FILE whose beginning matches +REGEXP. Return it enclosed in a prog form." + (prog (match (sexp-file-lines file regexp) + ((start . stop) + (source #:language scheme + #:file file + #:start (1- start) + #:stop (1- stop)))) + #:line #f)) + ;; HTML engine customizations (let ((html-engine (find-engine 'html))) (engine-custom-set! html-engine 'css "/style.css") -- cgit v1.2.3