(defun szotar-next-line ()
"Takes the next line and prints its HTML representation."
(if (re-search-forward "^\\(.*\\) = \\(.*\\)$" (point-max) t)
(let* ((definition (match-string 2))
(latin (match-string 1)))
(princ (concat "
\n"
"" latin "\n"
"" definition "\n"
"
\n"))
t)
nil))
(defun szotar-htmlize ()
"Generates a CSS-driven HTML file from the current buffer.
The buffer is assumed to be in UTF-8 encoding."
(interactive)
(with-output-to-temp-buffer (concat (buffer-name (current-buffer)) ".html")
(princ (concat "\n"
"\n"
"" (buffer-name (current-buffer)) "\n"
"\n"
"\n"
"\n"
"\n"))
(save-excursion
(goto-char (point-min))
(while (szotar-next-line)))
(princ "\n")))
;;; Takes out the words of the given lessons.
;;; Lessons are given as a regexp pattern, e.g. Lesson XI-XIII is `XI\{1,3\}'.
;;; 0- 4 : \(I*\|IV\) 5- 9 : \(VI*\|IX\)
;;; 10-14 : X\(I*\|IV\) 15-19 : X\(VI*\|IX\)
;;; 20-24 : XX\(I*\|IV\) 25-29 : XX\(VI*\|IX\)
;;; etc.
(defun generate-szotar (str)
(interactive "sLecke száma: ")
(with-output-to-temp-buffer "szotar"
(save-excursion
(goto-char (point-min))
(while (search-forward-regexp (concat "^\\*+ " str "$") nil t)
(forward-line 1)
(let* ((begin (point))
(found (search-forward-regexp "^\\*" nil t))
(end (or (and found (1- found)) (point-max))))
(princ (buffer-substring-no-properties begin end)))
(beginning-of-line)))))