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)))
|
||||
|
||||
(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))
|
||||
(r (and (>= n 3)
|
||||
(char=? #\( (string-ref str 0))
|
||||
(char<=? #\1 (string-ref str 1))
|
||||
(char<=? (string-ref str 1) #\9)
|
||||
(cond ((char=? #\) (string-ref str (- n 1)))
|
||||
(is 0 "(")
|
||||
(is 1 "123456789")
|
||||
(cond ((is (- n 1) ")")
|
||||
1)
|
||||
((and (>= n 4)
|
||||
(char=? #\) (string-ref str (- n 2)))
|
||||
(char=? #\, (string-ref str (- n 1))))
|
||||
(is (- n 2) ")")
|
||||
(is (- n 1) ",."))
|
||||
2)
|
||||
(else
|
||||
#f)))))
|
||||
|
|
Loading…
Reference in New Issue