-
Notifications
You must be signed in to change notification settings - Fork 0
/
mbnt.el
36 lines (33 loc) · 1.24 KB
/
mbnt.el
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
(setq make-backup-files nil)
(defun mbnt-process-paragraph (chapter)
(kill-whole-line)
(push-mark)
(forward-to-indentation)
(delete-region (point) (mark))
(push-mark)
(forward-paragraph)
(narrow-to-region (point) (mark))
(while (> (point) (point-min))
(delete-indentation))
(while (re-search-forward verse-regex nil t)
(replace-match (concat "\n$$$" book " " chapter ":\\1\n")))
(narrow-to-page))
(defun mbnt-convert (file)
(with-current-buffer (find-file-noselect file)
(let* ((book (substring file 0 -4))
(chapter-regex "Κεφάλαιο \\([0-9]+\\)")
(verse-regex "\\([0-9]+\\) ")
chapter)
(goto-char (point-min))
(push-mark)
(if (re-search-forward chapter-regex nil t)
(progn (beginning-of-line)
(delete-region (point) (mark))
(while (re-search-forward chapter-regex nil t)
(mbnt-process-paragraph (match-string 1))))
(mbnt-process-paragraph "1"))
(forward-line)
(delete-region (point) (point-max))
(write-file (expand-file-name (concat book ".imp"))))))
(let ((default-directory (expand-file-name "texts")))
(mapc 'mbnt-convert (directory-files "." nil "^[0-9a-zA-z ]+\\.txt$")))