From 052753e4a3c00929c10702f46cb4404bd11b63d5 Mon Sep 17 00:00:00 2001 From: riton Date: Mon, 24 Mar 2025 00:23:07 +0300 Subject: =?UTF-8?q?markdown=20dosyas=C4=B1n=C4=B1=20htmle=20d=C3=B6n=C3=BC?= =?UTF-8?q?=C5=9Ft=C3=BCr=C3=BCp=20=C5=9Fablona=20g=C3=B6mme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ana.lisp | 29 +++++++++++++++++++++++++++++ html-jen.asd | 3 ++- "\303\274retim.lisp" | 6 +++--- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 ana.lisp diff --git a/ana.lisp b/ana.lisp new file mode 100644 index 0000000..ac4c9ca --- /dev/null +++ b/ana.lisp @@ -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 + " +")) + (ebeveyn-node! :body + (list node))))) + +(defun şablonlu-yazdır (node &optional (stream *standard-output*)) + (format stream "~%~%") + (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ış))))) diff --git a/html-jen.asd b/html-jen.asd index da2af8c..bbad5d4 100644 --- a/html-jen.asd +++ b/html-jen.asd @@ -6,4 +6,5 @@ :components ((:file "paket") (:file "tanım") (:file "okur") - (:file "üretim"))) + (:file "üretim") + (:file "ana"))) diff --git "a/\303\274retim.lisp" "b/\303\274retim.lisp" index 6074888..3f8c8cc 100644 --- "a/\303\274retim.lisp" +++ "b/\303\274retim.lisp" @@ -11,13 +11,13 @@ (defun tag-yeni-satır? (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))) (defun tag-inline? (tag) (case tag - ((:html :head :body :div :ol :ul :li :p) nil) - ((:title :b :i :code) t))) + ((:html :head :body :div :ol :ul :li :p :title) nil) + ((:b :i :code) t))) (defmethod node->html :before ((node node) &optional (stream *standard-output*)) (unless (not *yeni-satır*) -- cgit v1.2.3