From 1cff8eadf22052f2b3d03c49a9cc1d50f0e21ddb Mon Sep 17 00:00:00 2001 From: Adam Tankanow Date: Fri, 9 Jan 2015 07:11:38 -0500 Subject: [PATCH] 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 --- src/cryogen_core/markup.clj | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cryogen_core/markup.clj b/src/cryogen_core/markup.clj index 1bff084..7b44ae7 100644 --- a/src/cryogen_core/markup.clj +++ b/src/cryogen_core/markup.clj @@ -17,9 +17,14 @@ "Injects the blog prefix in front of any local links ex. becomes " + [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/)