aboutsummaryrefslogtreecommitdiff
path: root/config.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-07-19 16:04:06 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2021-07-19 16:04:06 +0200
commitb7705c8cd70b9a00dfa58f3fc096000da2a42208 (patch)
tree595161a48490ebc86305db1c6396b44d31c775d4 /config.scm
parentFix bug where 'base' of event repeated through multiple VEVENT:s would be "lo... (diff)
downloadcalp-b7705c8cd70b9a00dfa58f3fc096000da2a42208.tar.gz
calp-b7705c8cd70b9a00dfa58f3fc096000da2a42208.tar.xz
Add parser for Microsoft Teams generated events in sample config.
Diffstat (limited to 'config.scm')
-rw-r--r--config.scm28
1 files changed, 28 insertions, 0 deletions
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 "<br>" str
'pre "<br/>" 'post))]
+ [(prop ev 'X-MICROSOFT-SKYPETEAMSMEETINGURL)
+ (parse-teams-description str)]
[else (parse-links str)])))
(set-config! 'week-start mon)