feat: to-html
This commit is contained in:
@@ -180,8 +180,8 @@
|
|||||||
parser, return a map with the following keys
|
parser, return a map with the following keys
|
||||||
• :top-level-nodes The nodes that /should/ be at the top-level.
|
• :top-level-nodes The nodes that /should/ be at the top-level.
|
||||||
• :first-section-nodes The nodes that should be wrapped in a new
|
• :first-section-nodes The nodes that should be wrapped in a new
|
||||||
section node
|
section node.
|
||||||
• :rest Everything else!"
|
• :rest Everything else."
|
||||||
[nodes]
|
[nodes]
|
||||||
(let [[of-top-level remaining-nodes]
|
(let [[of-top-level remaining-nodes]
|
||||||
(->> nodes (split-with #(of-type? % "property-drawer" "keyword")))
|
(->> nodes (split-with #(of-type? % "property-drawer" "keyword")))
|
||||||
|
|||||||
@@ -72,6 +72,12 @@
|
|||||||
[:article
|
[:article
|
||||||
rendered]]])))
|
rendered]]])))
|
||||||
|
|
||||||
|
(defn to-html
|
||||||
|
"Read `f` with `slurp` as an Org document and return a string of
|
||||||
|
rendered HTML."
|
||||||
|
[f]
|
||||||
|
(str (hiccup/html {} (-> f slurp element/read-string org-document))))
|
||||||
|
|
||||||
|
|
||||||
;;; Further dispatching on `org-element`
|
;;; Further dispatching on `org-element`
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,7 @@
|
|||||||
(force-create-sym-link (fs/file dest "Temml-Plex.css")
|
(force-create-sym-link (fs/file dest "Temml-Plex.css")
|
||||||
(io/resource "net/deertopia/doerg/Temml-Plex.css"))
|
(io/resource "net/deertopia/doerg/Temml-Plex.css"))
|
||||||
(fs/delete-if-exists (fs/file dest "index.html"))
|
(fs/delete-if-exists (fs/file dest "index.html"))
|
||||||
(->> (h/html (-> src slurp element/read-string render/org-document))
|
(->> src render/to-html str (spit (fs/file dest "index.html"))))
|
||||||
str (spit (fs/file dest "index.html"))))
|
|
||||||
|
|
||||||
(defn render-edn [& {:keys [src dest]
|
(defn render-edn [& {:keys [src dest]
|
||||||
:or {src some-org-file
|
:or {src some-org-file
|
||||||
|
|||||||
2
doerg/test/net/deertopia/doerg/render_test.clj
Normal file
2
doerg/test/net/deertopia/doerg/render_test.clj
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
(ns net.deertopia.doerg.render-test
|
||||||
|
(:require [net.deertopia.doerg.render :as sut]))
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#+title: aghhh
|
#+title: aghhh
|
||||||
#+latex_header: \usepackage{ifxetex}
|
|
||||||
|
|
||||||
- blah blah prose prose prose \(c = \sqrt{x^2 + y^2}\), alal.
|
- blah blah prose prose prose \(c = \sqrt{x^2 + y^2}\), alal.
|
||||||
- this thing is \(x\)
|
- this thing is \(x\)
|
||||||
|
|||||||
Reference in New Issue
Block a user