(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))
             (greek (match-string 1)))
        (princ (concat "<tr>\n"
                       "<td><span class=\"greek\">" greek "</span></td>\n"
                       "<td><span class=\"definition\">" definition "</span></td>\n"
                       "</tr>\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 "<html>\n"
                   "<head>\n"
                   "<title>" (buffer-name (current-buffer)) "</title>\n"
                   "<link rel=\"stylesheet\" type=\"text/css\""
                   " href=\"szotar.css\" media=\"all\" />\n"
                   "</head>\n"
                   "<meta http-equiv=\"Content-Type\""
                   " content=\"text/html;charset=utf-8\" />\n"
                   "<body>\n"
                   "<table>\n"))
    (save-excursion
      (goto-char (point-min))
      (while (szotar-next-line)))
    (princ "</table>\n</body>\n</html>")))