Implement --default-image-extension
for LaTeX reader.
This commit is contained in:
parent
1a2eea23a1
commit
8dfbe3bbe8
2 changed files with 14 additions and 5 deletions
7
README
7
README
|
@ -244,9 +244,10 @@ Reader options
|
|||
by spaces or commas.
|
||||
|
||||
`--default-image-extension=`*EXTENSION*
|
||||
: Specify a default extension to use when markdown image paths/URLs have no
|
||||
extension. This allows you to use the same markdown source for
|
||||
formats that require different kinds of images.
|
||||
: Specify a default extension to use when image paths/URLs have no
|
||||
extension. This allows you to use the same source for formats that
|
||||
require different kinds of images. Currently this option only affects
|
||||
the markdown and LaTeX readers.
|
||||
|
||||
`--normalize`
|
||||
: Normalize the document after reading: merge adjacent
|
||||
|
|
|
@ -51,6 +51,7 @@ import System.FilePath (replaceExtension, (</>))
|
|||
import Data.List (intercalate)
|
||||
import qualified Data.Map as M
|
||||
import qualified Control.Exception as E
|
||||
import System.FilePath (takeExtension, addExtension)
|
||||
|
||||
-- | Parse LaTeX from string and return 'Pandoc' document.
|
||||
readLaTeX :: ReaderOptions -- ^ Reader options
|
||||
|
@ -430,8 +431,7 @@ inlineCommands = M.fromList $
|
|||
, ("href", (unescapeURL <$> braced <* optional sp) >>= \url ->
|
||||
tok >>= \lab ->
|
||||
pure (link url "" lab))
|
||||
, ("includegraphics", skipopts *> (unescapeURL <$> braced) >>=
|
||||
(\src -> pure (image src "" (str "image"))))
|
||||
, ("includegraphics", skipopts *> (unescapeURL <$> braced) >>= mkImage)
|
||||
, ("enquote", enquote)
|
||||
, ("cite", citation "cite" AuthorInText False)
|
||||
, ("citep", citation "citep" NormalCitation False)
|
||||
|
@ -488,6 +488,14 @@ inlineCommands = M.fromList $
|
|||
-- in which case they will appear as raw latex blocks:
|
||||
[ "noindent", "index", "nocite" ]
|
||||
|
||||
mkImage :: String -> LP Inlines
|
||||
mkImage src =
|
||||
case takeExtension src of
|
||||
"" -> do
|
||||
defaultExt <- getOption readerDefaultImageExtension
|
||||
return $ image (addExtension src defaultExt) "" (str "image")
|
||||
_ -> return $ image src "" (str "image")
|
||||
|
||||
inNote :: Inlines -> Inlines
|
||||
inNote ils =
|
||||
note $ para $ ils <> str "."
|
||||
|
|
Loading…
Add table
Reference in a new issue