Files
html-jen/ana.lisp
2025-03-24 02:09:09 +03:00

37 lines
1.3 KiB
Common Lisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(in-package :html-jen)
(defun başlık-bul (node)
(loop :for çocuk :in (children node)
:do (when (eq :h1 (tag çocuk))
(return (value çocuk)))))
(defun şablon-yap (node)
(ebeveyn-node! :html
(list (ebeveyn-node! :head
(list (çocuk-node! :title (başlık-bul node))
;;; geçici hack çünkü /> ile biten tagleri düzgün basamıyorum
" <link href=\"index.css\" rel=\"stylesheet\">
"))
(ebeveyn-node! :body
(list node)))))
(defun şablonlu-yazdır (node &optional (stream *standard-output*))
(format stream "<!DOCTYPE html>~%~%")
(node->html (şablon-yap node) stream))
(defun markdown->html (kaynak hedef)
(let ((okur (okur! kaynak)))
(let ((root (markdown-ayrıştır okur))
(*print-case* :downcase))
(with-open-file (dış hedef :direction :output
:if-does-not-exist :create
:if-exists :supersede)
(şablonlu-yazdır root dış)))))
(defun ana ()
(let ((args sb-ext:*posix-argv*))
(assert (= 3 (length args)))
(let ((kaynak (nth 1 args))
(hedef (nth 2 args)))
(markdown->html kaynak hedef))))