aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-04-05 16:21:14 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-04-05 16:56:14 +0200
commite0b2afcf28d7e00dbc1762e4cf4558a633cf5581 (patch)
treeb7bf3e4e2424600c82368833673b60245db7059d
parentFix rrule:s in frontend being parsed incorrectly. (diff)
downloadcalp-e0b2afcf28d7e00dbc1762e4cf4558a633cf5581.tar.gz
calp-e0b2afcf28d7e00dbc1762e4cf4558a633cf5581.tar.xz
Clean up config.scm.
-rw-r--r--config.scm16
1 files 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 <content>))
+ ;; this strips it down to just <content>
+ (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 "<br>" str
- 'pre "<br/>" 'post))]
+ html-cals)
+ (parse-html str)]
[(prop ev 'X-MICROSOFT-SKYPETEAMSMEETINGURL)
(parse-teams-description str)]
[else (parse-links str)])))