BlogLiterately 0.8.3.1 → 0.8.4
raw patch · 3 files changed
+56/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- BlogLiterately.cabal +1/−1
- CHANGES.md +8/−0
- src/Text/BlogLiterately/Transform.hs +47/−4
BlogLiterately.cabal view
@@ -1,5 +1,5 @@ Name: BlogLiterately-Version: 0.8.3.1+Version: 0.8.4 Synopsis: A tool for posting Haskelly articles to blogs Description: Write blog posts in Markdown format, then use BlogLiterately to do syntax highlighting, format ghci sessions, and upload
CHANGES.md view
@@ -1,3 +1,11 @@+0.8.4 (13 July 2016)+--------------------++Two new special link types:++ - Github (link to a repo, issue, or commit)+ - Hackage (link to a package)+ 0.8.3.1 (14 June 2016) ----------------------
src/Text/BlogLiterately/Transform.hs view
@@ -199,14 +199,22 @@ : bs centerImage bs = bs --- | Replace special links with appropriate URLs. Currently, four--- types of special links are supported:+-- | Replace special links with appropriate URLs. Currently, the+-- following types of special links are supported: -- -- [@lucky::<search>@] The first Google result for @<search>@. -- -- [@wiki::<title>@] The Wikipedia page for @<title>@. Note that -- the page is not checked for existence. --+-- [@hackage::<pkg>@] The Hackage page for @<pkg>@.+--+-- [@github::<user>/<repo>@] The top page for the given repo on github.+--+-- [@github::<user>/<repo>/#<nnn>@] Link to a particular issue.+--+-- [@github::<user>/<repo>/\@<hash>@] Link to a particular commit.+-- -- [@post::nnnn@] Link to the blog post with post ID @nnnn@. Note -- that this form of special link is invoked when @nnnn@ consists of -- all digits, so it only works on blogs which use numerical@@ -234,9 +242,16 @@ specialLinksXF = mkSpecialLinksXF standardSpecialLinks -- | The standard special link types included in 'specialLinksXF':--- 'luckyLink', 'wikiLink', and 'postLink'.+-- 'luckyLink', 'wikiLink', 'postLink', 'githubLink', and+-- 'hackageLink'. standardSpecialLinks :: [SpecialLink]-standardSpecialLinks = [luckyLink, wikiLink, postLink]+standardSpecialLinks =+ [ luckyLink+ , wikiLink+ , postLink+ , githubLink+ , hackageLink+ ] -- | A special link consists of two parts: --@@ -328,6 +343,34 @@ -- If all digits, replace with permalink for that postid -- Otherwise, search titles of 20 most recent posts. -- Choose most recent that matches.++-- | @githubLink@ handles several types of special links.+--+-- [@github::<user>/<repo>@] links to a repository.+--+-- [@github::<user>/<repo>/#<nnn>@] links to issue #nnn.+--+-- [@github::<user>/<repo>/\@<hash>@] links to the commit with the+-- given hash.+githubLink :: SpecialLink+githubLink = ("github", getGithubLink)+ where+ getGithubLink target bl =+ case splitOn "/" target of+ (user : repo : ghTarget) -> return $ github </> user </> repo </> mkTarget ghTarget+ _ -> return $ github </> target+ github = "https://github.com/"+ mkTarget [] = ""+ mkTarget (('@': hash) : _) = "commit" </> hash+ mkTarget (('#': issue) : _) = "issues" </> issue++-- | A target of the form @hackage::<pkg>@ turns into a link to the+-- package @<pkg>@ on Hackage.+hackageLink :: SpecialLink+hackageLink = ("hackage", getHackageLink)+ where+ getHackageLink pkg bl = return $ hackagePrefix ++ pkg+ hackagePrefix = "http://hackage.haskell.org/package/" -- | Potentially extract a title from the metadata block, and set it -- in the options record.