aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-05 20:08:00 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-05 20:08:00 -0800
commitc5f1a8ad2d2f7972e2c3e8bd22686bb99e84356d (patch)
treefddc9cc35071f7bb46477c9872f65d537506c7d6 /src/Text
parent1aa74199cf26ce5c603b2431b821cbf39e8eccf9 (diff)
downloadpandoc-c5f1a8ad2d2f7972e2c3e8bd22686bb99e84356d.tar.gz
Added `--default-image-extension` and `readerDefaultImageExtension`.
Note: Currently this only affects the markdown reader.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Options.hs26
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs7
2 files changed, 20 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index f67debf97..1ba8a6dd6 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -204,22 +204,24 @@ data ReaderOptions = ReaderOptions{
, readerApplyMacros :: Bool -- ^ Apply macros to TeX math
, readerIndentedCodeClasses :: [String] -- ^ Default classes for
-- indented code blocks
+ , readerDefaultImageExtension :: String -- ^ Default extension for images
} deriving (Show, Read)
instance Default ReaderOptions
where def = ReaderOptions{
- readerExtensions = pandocExtensions
- , readerSmart = False
- , readerStrict = False
- , readerStandalone = False
- , readerParseRaw = False
- , readerColumns = 80
- , readerTabStop = 4
- , readerOldDashes = False
- , readerReferences = []
- , readerCitationStyle = Nothing
- , readerApplyMacros = True
- , readerIndentedCodeClasses = []
+ readerExtensions = pandocExtensions
+ , readerSmart = False
+ , readerStrict = False
+ , readerStandalone = False
+ , readerParseRaw = False
+ , readerColumns = 80
+ , readerTabStop = 4
+ , readerOldDashes = False
+ , readerReferences = []
+ , readerCitationStyle = Nothing
+ , readerApplyMacros = True
+ , readerIndentedCodeClasses = []
+ , readerDefaultImageExtension = ""
}
--
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index dc30e17ed..6b144f35e 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -51,6 +51,7 @@ import qualified Text.CSL as CSL
import Data.Monoid (mconcat, mempty)
import Control.Applicative ((<$>), (<*), (*>), (<$))
import Control.Monad
+import System.FilePath (takeExtension, addExtension)
import Text.HTML.TagSoup
import Text.HTML.TagSoup.Match (tagOpen)
import qualified Data.Set as Set
@@ -1561,7 +1562,11 @@ image :: MarkdownParser (F Inlines)
image = try $ do
char '!'
(lab,raw) <- reference
- regLink B.image lab <|> referenceLink B.image (lab,raw)
+ defaultExt <- getOption readerDefaultImageExtension
+ let constructor src = case takeExtension src of
+ "" -> B.image (addExtension src defaultExt)
+ _ -> B.image src
+ regLink constructor lab <|> referenceLink constructor (lab,raw)
note :: MarkdownParser (F Inlines)
note = try $ do