From 31c030e3a55c3bc9d4a606e9658dd30a9aa1c938 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 3 Mar 2007 18:19:31 +0000 Subject: Added --inline-links option to force links in HTML to be parsed as inline links, rather than reference links. (Addresses Issue #4.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@554 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/HTML.hs | 9 ++++++--- src/Text/Pandoc/Shared.hs | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 3fcb33698..8ebf02c33 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -449,15 +449,18 @@ extractAttribute name ((attrName, contents):rest) = then Just (decodeEntities contents) else extractAttribute name rest -link = try (do +link = try $ do (tag, attributes) <- htmlTag "a" url <- case (extractAttribute "href" attributes) of Just url -> do {return url} Nothing -> fail "no href" let title = fromMaybe "" (extractAttribute "title" attributes) label <- inlinesTilEnd "a" - ref <- generateReference url title - return (Link (normalizeSpaces label) ref)) + state <- getState + ref <- if stateInlineLinks state + then return (Src url title) + else generateReference url title + return $ Link (normalizeSpaces label) ref image = try (do (tag, attributes) <- htmlTag "img" diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 87718030f..55e093ee7 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -133,6 +133,7 @@ data ParserState = ParserState stateSmart :: Bool, -- ^ Use smart typography stateColumns :: Int, -- ^ Number of columns in -- terminal (used for tables) + stateInlineLinks :: Bool, -- ^ Parse html links as inline stateHeaderTable :: [HeaderType] -- ^ List of header types used, -- in what order (rst only) } @@ -155,6 +156,7 @@ defaultParserState = stateStrict = False, stateSmart = False, stateColumns = 80, + stateInlineLinks = False, stateHeaderTable = [] } -- | Indent string as a block. -- cgit v1.2.3