markdown dosyasını htmle dönüştürüp şablona gömme
This commit is contained in:
29
ana.lisp
Normal file
29
ana.lisp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
(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ış)))))
|
||||||
@@ -6,4 +6,5 @@
|
|||||||
:components ((:file "paket")
|
:components ((:file "paket")
|
||||||
(:file "tanım")
|
(:file "tanım")
|
||||||
(:file "okur")
|
(:file "okur")
|
||||||
(:file "üretim")))
|
(:file "üretim")
|
||||||
|
(:file "ana")))
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
(defun tag-yeni-satır? (tag)
|
(defun tag-yeni-satır? (tag)
|
||||||
(case tag
|
(case tag
|
||||||
((:html :head :body :div :ol :ul) t)
|
((:html :head :body :div :ol :ul :link) t)
|
||||||
((:title :p :b :i :code :li) nil)))
|
((:title :p :b :i :code :li) nil)))
|
||||||
|
|
||||||
(defun tag-inline? (tag)
|
(defun tag-inline? (tag)
|
||||||
(case tag
|
(case tag
|
||||||
((:html :head :body :div :ol :ul :li :p) nil)
|
((:html :head :body :div :ol :ul :li :p :title) nil)
|
||||||
((:title :b :i :code) t)))
|
((:b :i :code) t)))
|
||||||
|
|
||||||
(defmethod node->html :before ((node node) &optional (stream *standard-output*))
|
(defmethod node->html :before ((node node) &optional (stream *standard-output*))
|
||||||
(unless (not *yeni-satır*)
|
(unless (not *yeni-satır*)
|
||||||
|
|||||||
Reference in New Issue
Block a user