Fixed HTML escaping issues and clean-up code.
This commit is contained in:
parent
ae24c5d54c
commit
df9f2b4140
1 changed files with 1 additions and 32 deletions
|
@ -73,19 +73,6 @@
|
||||||
[s]
|
[s]
|
||||||
(.markdown mdp s))
|
(.markdown mdp s))
|
||||||
|
|
||||||
(defn replace-special-chars
|
|
||||||
"Inserts super-fancy characters into the doc section."
|
|
||||||
[s]
|
|
||||||
(-> s
|
|
||||||
(str/replace #"->" "→")
|
|
||||||
(str/replace #""" "\"")))
|
|
||||||
|
|
||||||
(defn replace-html-entities
|
|
||||||
[s]
|
|
||||||
(-> s
|
|
||||||
(str/replace "<" "<")
|
|
||||||
(str/replace ">" ">")))
|
|
||||||
|
|
||||||
;; As a result of docifying then grouping, you'll end up with a seq like this one:
|
;; As a result of docifying then grouping, you'll end up with a seq like this one:
|
||||||
;; <pre><code>[...
|
;; <pre><code>[...
|
||||||
;; {:docs [{:docs-text "Some doc text"}]
|
;; {:docs [{:docs-text "Some doc text"}]
|
||||||
|
@ -95,21 +82,6 @@
|
||||||
;; `docs-to-html` and `codes-to-html` convert their respective entries into html,
|
;; `docs-to-html` and `codes-to-html` convert their respective entries into html,
|
||||||
;; and `group-to-html` calls them on each seq item to do so.
|
;; and `group-to-html` calls them on each seq item to do so.
|
||||||
|
|
||||||
(defn prep-docs-text [s] s)
|
|
||||||
|
|
||||||
(defn prep-docstring-text [s]
|
|
||||||
(-> s
|
|
||||||
(str/replace #"\\\"" "\"")
|
|
||||||
(str/replace #"^\s\s\"" "")
|
|
||||||
(str/replace #"^\s\s\s" "")
|
|
||||||
(str/replace #"\"$" "")
|
|
||||||
;; Don't escape code blocks
|
|
||||||
((fn [t]
|
|
||||||
(if (re-find #"^\s\s\s\s" t)
|
|
||||||
t
|
|
||||||
(escape-html t))))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn docs-to-html
|
(defn docs-to-html
|
||||||
"Converts a docs section to html by threading each doc line through the forms
|
"Converts a docs section to html by threading each doc line through the forms
|
||||||
outlined above.
|
outlined above.
|
||||||
|
@ -121,14 +93,11 @@
|
||||||
[docs]
|
[docs]
|
||||||
(-> docs
|
(-> docs
|
||||||
str
|
str
|
||||||
prep-docs-text
|
|
||||||
replace-special-chars
|
|
||||||
replace-html-entities
|
|
||||||
(md)))
|
(md)))
|
||||||
|
|
||||||
(defn codes-to-html [code-block]
|
(defn codes-to-html [code-block]
|
||||||
(html [:pre {:class "brush: clojure"}
|
(html [:pre {:class "brush: clojure"}
|
||||||
(replace-html-entities code-block)]))
|
(escape-html code-block)]))
|
||||||
|
|
||||||
(defn section-to-html [section]
|
(defn section-to-html [section]
|
||||||
(html [:tr
|
(html [:tr
|
||||||
|
|
Loading…
Reference in a new issue