SXML linkify text added by DerGuteMoritz on Sat Apr 14 17:25:51 2012

(define (linkify str)
  (irregex-fold '(seq "http://" (+ (~ space)))
                (lambda (i m sxml)
                  (let ((text (substring str i (irregex-match-start-index m 0)))
                        (link (irregex-match-substring  m 0)))
                    (cons (list text `(a (@ (href ,link)) ,link))
                          sxml)))
                '()
                str
                (lambda (i sxml)
                  (let ((tail (substring str i (string-length str))))
                    (reverse (cons tail sxml))))))


;; (output-xml (linkify "Some <em>text</em> with http://example.com/ embedded http://call-cc.org/ URIs.")
;;             (list universal-conversion-rules))

;; Some &lt;em&gt;text&lt;/em&gt; with <a href="http://example.com/">http://example.com/</a> embedded <a href="http://call-cc.org/">http://call-cc.org/</a> URIs.