Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[f3064f]: news-items.lisp Maximize Restore History

Download this file

news-items.lisp    55 lines (53 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(in-package :sbcl-page)
(defun convert-news (pathname)
(with-open-file (news-i pathname
:direction :input
:external-format :iso-8859-1)
(with-open-file (news-o (merge-pathnames "news.lisp-expr" *root*)
:direction :output
:if-exists :supersede
:external-format :iso-8859-1)
(format news-o "(cl:in-package :sbcl-page)")
(loop for line = (read-line news-i nil nil)
with level = 0
with need-close-string = nil
while line
do
(progn
(setf line (regex-replace-all "\\\\" line "\\\\\\\\"))
(setf line (regex-replace-all "\"" line "\\\""))
(or
(when (scan "^(?i)changes in sbcl-([0-9a-zA-Z.]+) .*$" line)
(when need-close-string
(write-string "\"" news-o)
(setf need-close-string nil))
(dotimes (i level)
(write-string ")" news-o))
(setf level 1)
(setf line (regex-replace-all "^(?i)changes in sbcl-([0-9a-zA-Z.]+) .*$"
line
"(define-news \"\\1\"")))
(when (and
(scan "^\\s*(\\*+)\\s*\\S.+$" line)
(not (scan "^\\s*\\*[-a-zA-Z0-9]+\\*.*$" line)))
(when need-close-string
(write-string "\"" news-o))
(let ((c (length
(elt
(nth-value 1
(scan-to-strings "^(?i)\\s*(\\*+).+$" line)) 0))))
(dotimes (i (- level c))
(write-string ")" news-o))
(setf level (1+ c))
(write-string "(" news-o))
(setf need-close-string t)
(setf line (regex-replace-all "^\\s*\\*+\\s*(\\S.+)$" line "\"\\1"))))
(write-string line news-o)
(terpri news-o))
finally
(progn
(when need-close-string
(write-string "\"" news-o)
(setf need-close-string nil))
(dotimes (i level)
(write-string ")" news-o)))))))