From b7705c8cd70b9a00dfa58f3fc096000da2a42208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 19 Jul 2021 16:04:06 +0200 Subject: Add parser for Microsoft Teams generated events in sample config. --- config.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'config.scm') diff --git a/config.scm b/config.scm index cb5779f4..14a54bdb 100644 --- a/config.scm +++ b/config.scm @@ -57,6 +57,32 @@ (a (match:substring m)) (recur (match:suffix m))))))) +(define (parse-teams-description str) + (map (lambda (line) + (let loop ((line line)) + (cond [(string-match "^_+$" line) + '((hr) (br))] + ;; hyperlinks go from start of line, + ;; or from last pipe character + [(string-match "([^|<]*)<([^>]*)>" line) + => (lambda (m) + (cons* + (match:prefix m) + `(a (@ (href ,(match:substring m 2))) + ,(match:substring m 1)) + (loop (match:suffix m))))] + ;; square brackets are images + [(string-match "\\[([^]]+)\\]" line) + => (lambda (m) + (cons* + (match:prefix m) + `(img (@ (src ,(match:substring m 1)))) + (loop (match:suffix m))))] + ;; Either the full line, or the remainder + ;; after hyperlink and img match. + [else (list line '(br))]))) + (string-split str #\newline))) + (define html-cals '("D-sektionens officiella kalender" "LiTHe kod" @@ -70,6 +96,8 @@ (parse-html (regexp-substitute/global #f "
" str 'pre "
" 'post))] + [(prop ev 'X-MICROSOFT-SKYPETEAMSMEETINGURL) + (parse-teams-description str)] [else (parse-links str)]))) (set-config! 'week-start mon) -- cgit v1.2.3