Permalink
Browse files

Commented link clauses in inlineToHtml.

  • Loading branch information...
1 parent cc77dec commit 1b9f307b63834a498ef4b2256ebd39ecbdac9d7f @jgm committed Apr 6, 2008
Showing with 5 additions and 1 deletion.
  1. +5 −1 Markdown.hs
View
@@ -273,13 +273,17 @@ inlineToHtml refs i =
Emph xs -> inTagsSimple "em" $ hcat $ map (inlineToHtml refs) xs
Strong xs -> inTagsSimple "strong" $ hcat $ map (inlineToHtml refs) xs
Html s -> P.text s
- Link l (Src (u,"")) -> inTags False "a" [("href", u)] $ hcat $ map (inlineToHtml refs) l
+ -- an autolink <http://google.com> or [explicit link](google.com) with no title
+ Link l (Src (u,"")) -> inTags False "a" [("href", u)] $ hcat $ map (inlineToHtml refs) l
+ -- an explicit link with a title: [like this](google.com "title")
Link l (Src (u,t)) -> inTags False "a" [("href", u), ("title", t)] $ hcat $ map (inlineToHtml refs) l
+ -- a shortcut-style reference link: [like this]
Link l Null -> case lookup l refs of
Just (u, "") -> inTags False "a" [("href", u)] $ hcat $ map (inlineToHtml refs) l
Just (u, t) -> inTags False "a" [("href", u), ("title", t)] $ hcat $
map (inlineToHtml refs) l
Nothing -> hcat $ map (inlineToHtml refs) $ [Text "["] ++ l ++ [Text "]"]
+ -- a regular reference link: [like][this] or [like] [this]
Link l (Ref r s) -> let r' = if null r then l else r
in case lookup r' refs of
Just (u, "") -> inTags False "a" [("href", u)] $ hcat $ map (inlineToHtml refs) l

0 comments on commit 1b9f307

Please sign in to comment.