Improve parse-section-in-parentheses
Recognize "foo(3scm)." in addition to "foo(3scm),"
This commit is contained in:
parent
9e85f4bd92
commit
f1bfc3c9ce
|
@ -162,16 +162,21 @@
|
||||||
(format #f "<a href=\"~a\">~a</a>" url body)))
|
(format #f "<a href=\"~a\">~a</a>" url body)))
|
||||||
|
|
||||||
(define (parse-section-in-parentheses str)
|
(define (parse-section-in-parentheses str)
|
||||||
|
(define (is i choices)
|
||||||
|
(let ((char (string-ref str i)))
|
||||||
|
(let loop ((k 0))
|
||||||
|
(and (< k (string-length choices))
|
||||||
|
(or (char=? char (string-ref choices k))
|
||||||
|
(loop (+ k 1)))))))
|
||||||
(let* ((n (string-length str))
|
(let* ((n (string-length str))
|
||||||
(r (and (>= n 3)
|
(r (and (>= n 3)
|
||||||
(char=? #\( (string-ref str 0))
|
(is 0 "(")
|
||||||
(char<=? #\1 (string-ref str 1))
|
(is 1 "123456789")
|
||||||
(char<=? (string-ref str 1) #\9)
|
(cond ((is (- n 1) ")")
|
||||||
(cond ((char=? #\) (string-ref str (- n 1)))
|
|
||||||
1)
|
1)
|
||||||
((and (>= n 4)
|
((and (>= n 4)
|
||||||
(char=? #\) (string-ref str (- n 2)))
|
(is (- n 2) ")")
|
||||||
(char=? #\, (string-ref str (- n 1))))
|
(is (- n 1) ",."))
|
||||||
2)
|
2)
|
||||||
(else
|
(else
|
||||||
#f)))))
|
#f)))))
|
||||||
|
|
Loading…
Reference in New Issue