refactor rewrite-hrefs into 2 functions
- (1) can be reused by the asciidoc processing, it simply does the text replace - (2) is a transformer using (1) for use in markdown.core
This commit is contained in:
parent
21d825d0cd
commit
1cff8eadf2
1 changed files with 7 additions and 2 deletions
|
@ -17,9 +17,14 @@
|
|||
"Injects the blog prefix in front of any local links
|
||||
|
||||
ex. <img src='/img/cryogen.png'/> becomes <img src='/blog/img/cryogen.png'/>"
|
||||
[blog-prefix text]
|
||||
(clojure.string/replace text #"href=.?/|src=.?/" #(str (subs % 0 (dec (count %))) blog-prefix "/")))
|
||||
|
||||
(defn- rewrite-hrefs-transformer
|
||||
"A :replacement-transformer for use in markdown.core that will inject the
|
||||
given blog prefix in front of local links."
|
||||
[{:keys [blog-prefix]} text state]
|
||||
[(clojure.string/replace text #"href=.?/|src=.?/" #(str (subs % 0 (dec (count %))) blog-prefix "/"))
|
||||
state])
|
||||
[(rewrite-hrefs blog-prefix text) state])
|
||||
|
||||
(defn- markdown
|
||||
"Returns a Markdown (https://daringfireball.net/projects/markdown/)
|
||||
|
|
Loading…
Reference in a new issue