summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-08 09:42:33 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-08 09:42:33 +0100
commit547f98dff029d011e6498c901190de11a0bc9c61 (patch)
tree39b4be2b4b6c2a03ae4fd21c6d0a5cbcd9ddcfa3 /src/Text
parentd29e4157f1647b06367c2e04c1cdea4c8175fd4c (diff)
downloadhakyll-547f98dff029d011e6498c901190de11a0bc9c61.tar.gz
Added link function.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Hakyll/File.hs1
-rw-r--r--src/Text/Hakyll/Util.hs8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs
index c535b11..0c803e1 100644
--- a/src/Text/Hakyll/File.hs
+++ b/src/Text/Hakyll/File.hs
@@ -50,6 +50,7 @@ getRecursiveContents topdir = do
-- | A filter that takes all file names with a given extension. Prefix the
-- extension with a dot:
+--
-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"]
havingExtension :: String -> [FilePath] -> [FilePath]
havingExtension extension = filter ((==) extension . takeExtension)
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
index d498281..319bed4 100644
--- a/src/Text/Hakyll/Util.hs
+++ b/src/Text/Hakyll/Util.hs
@@ -2,6 +2,7 @@ module Text.Hakyll.Util
( trim
, split
, stripHTML
+ , link
) where
import Data.Char (isSpace)
@@ -26,3 +27,10 @@ stripHTML str = let (beforeTag, rest) = break (== '<') str
split :: String -> String -> [String]
split pattern = filter (not . null)
. splitRegex (mkRegex pattern)
+
+-- | Make a HTML link.
+--
+-- > link "foo" "bar.html" == "<a href='bar.html'>foo</a>"
+link :: String -> String -> String
+link text destination = "<a href=\"" ++ destination ++ "\">"
+ ++ text ++ "</a>"