From e0b2afcf28d7e00dbc1762e4cf4558a633cf5581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Apr 2022 16:21:14 +0200 Subject: Clean up config.scm. --- config.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config.scm b/config.scm index 641b3050..606384e9 100644 --- a/config.scm +++ b/config.scm @@ -4,6 +4,7 @@ (use-modules (ice-9 regex) (sxml simple) + (sxml xpath) ) (set-config! 'calendar-files (glob "~/.local/var/cal/*")) @@ -26,8 +27,6 @@ 'pre (lambda (m) (aref my-courses (string->symbol (match:substring m)))) 'post))) -(define (a link) `(a (@ (href ,link)) ,link)) - (define (parse-html str) (catch 'misc-error ;; resolve-interface throws misc-error on missing module. @@ -35,10 +34,14 @@ (lambda () (let* ((gumbo (resolve-interface '(sxml gumbo))) (html->sxml (module-ref gumbo 'html->sxml))) - (html->sxml str))) + ;; html->sxml always gives us (html (head ...) (body )) + ;; this strips it down to just + (cdar ((sxpath '(// body)) (html->sxml str))))) ;; Give up on parsing (lambda _ str))) +(define (a link) `(a (@ (href ,link)) ,link)) + (define (parse-links str) (define regexp (make-regexp "https?://\\S+")) (let recur ((str str)) @@ -83,11 +86,8 @@ (set-config! 'description-filter (lambda (ev str) (cond [(member (prop (parent ev) 'NAME) - html-cals - ) - (parse-html (regexp-substitute/global - #f "
" str - 'pre "
" 'post))] + html-cals) + (parse-html str)] [(prop ev 'X-MICROSOFT-SKYPETEAMSMEETINGURL) (parse-teams-description str)] [else (parse-links str)]))) -- cgit v1.2.3