Permalink
Browse files

support ((<Reference>)) syntax

  • Loading branch information...
1 parent cd5accf commit 8e32969e8c97f0887fa18530c7f728babf66ccc3 @himura committed Nov 12, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/Text/Pandoc/Readers/RD.hs
@@ -263,7 +263,7 @@ inlineElems =
, var
, keyboard
, index
- -- , reference
+ , reference
, footnote
, verb
, symbol
@@ -328,7 +328,22 @@ index :: GenParser Char ParserState Inline
index = inlineParser "((:" ":))" inline' >>= return . Strikeout
reference :: GenParser Char ParserState Inline
-reference = undefined
+reference = try $ string "((<" >> refparser
+
+refparser :: GenParser Char ParserState Inline
+refparser = shortLink <|> detailLink
+ where
+ link t = try $ do
+ string "URL:"
+ l <- manyTill anyChar (string ">))")
+ return $ Link (if null t then [Str l] else t) (l, "")
+ label t = try $ do
+ l <- manyTill alphaNum (string ">))")
+ return $ Link (if null t then [Str l] else t) (l, "")
+ shortLink = link [] <|> label []
+ detailLink = do
+ title <- manyTill inline' (char '|')
+ link title <|> label title
footnote :: GenParser Char ParserState Inline
footnote = inlineParser "((-" "-))" inline' >>= return . Note . (:[]) . Plain

0 comments on commit 8e32969

Please sign in to comment.