change replacement syntax to &:

master
Josha von Gizycki 6 years ago
parent fba3fd8577
commit 093bd816e5

@ -1,17 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Equilibrium page &title</title>
<meta charset="UTF-8">
<!-- generated at &:generated-at -->
<title>Equilibrium page &:title</title>
</head>
<body>
<nav>
&nav
&:nav
</nav>
<main>
&content
&:content
</main>
<aside>
&particle:aside
&:particle:aside
</aside>
</body>
</html>

@ -89,7 +89,7 @@
(page-content "aiaiaiai"))
(defn particles-in-content [content]
(re-seq #"&particle:([^\s]+)" content))
(re-seq #"&:particle:([^\s]+)" content))
(comment
(particles-in-content "asd &particle:hullu"))
@ -99,10 +99,10 @@
(defn fill-in-placeholders [context html page]
(let [simple (-> html
(string/replace #"&nav" (:navcode context))
(string/replace #"&content" (:content page))
(string/replace #"&title" (get-in page [:metadata :title]))
(string/replace #"&generated-at" (now-str)))
(string/replace #"&:nav" (:navcode context))
(string/replace #"&:content" (:content page))
(string/replace #"&:title" (get-in page [:metadata :title]))
(string/replace #"&:generated-at" (now-str)))
particles (particles-in-content simple)]
(reduce (fn [result particle]
(string/replace result
@ -113,10 +113,10 @@
(comment
(fill-in-placeholders {:navcode "hhh"}
"&nav &content &particle:aside\n "
"&:nav &content &:particle:aside\n "
{:content "dinge"})
(fill-in-placeholders {:navcode "hhh"}
"&nav &content &particle:aside\n &generated-at"
"&:nav &:content &:particle:aside\n &:generated-at"
{:content "dinge"})
)
@ -133,9 +133,18 @@
:content (-> content page-content render-markdown)
:metadata (page-metadata content)}))
(defn clear-dir [dir]
(doseq [file (file-seq dir)]
(when (.exists dir)
(when (and (.isDirectory file)
(not= dir file))
(clear-dir file))
(.delete file))))
(defn render
"Renders all markdown pages under resources/user using the structure in resources/user/structure to target/page"
[project]
(clear-dir (io/file "target/page"))
(.mkdirs (io/file "target/page"))
(let [sites (md-files (str input-root "/sites"))
rendered-sites (map analysed-page sites)

Loading…
Cancel
Save