diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Options.hs | 26 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 7 |
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 c476e23a7..e198586d6 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 @@ -1562,7 +1563,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 |