Better heuristics for guessing reader to use.
If argument is an absolute URL without a recognized extension, and no reader is explicitly specified, use HTML. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1908 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
695961155a
commit
d704f47b86
1 changed files with 9 additions and 6 deletions
|
@ -60,7 +60,7 @@ import Text.Pandoc.Biblio
|
|||
#endif
|
||||
import Control.Monad (when, unless, liftM)
|
||||
import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
|
||||
import Network.URI (parseURI)
|
||||
import Network.URI (parseURI, isURI)
|
||||
import Data.ByteString.Lazy.UTF8 (toString)
|
||||
|
||||
copyrightMessage :: String
|
||||
|
@ -536,9 +536,9 @@ usageMessage programName = usageInfo
|
|||
(intercalate ", " $ map fst writers) ++ "\nOptions:")
|
||||
|
||||
-- Determine default reader based on source file extensions
|
||||
defaultReaderName :: [FilePath] -> String
|
||||
defaultReaderName [] = "markdown"
|
||||
defaultReaderName (x:xs) =
|
||||
defaultReaderName :: String -> [FilePath] -> String
|
||||
defaultReaderName fallback [] = fallback
|
||||
defaultReaderName fallback (x:xs) =
|
||||
case takeExtension (map toLower x) of
|
||||
".xhtml" -> "html"
|
||||
".html" -> "html"
|
||||
|
@ -549,7 +549,7 @@ defaultReaderName (x:xs) =
|
|||
".rst" -> "rst"
|
||||
".lhs" -> "markdown+lhs"
|
||||
".native" -> "native"
|
||||
_ -> defaultReaderName xs
|
||||
_ -> defaultReaderName fallback xs
|
||||
|
||||
-- Returns True if extension of first source is .lhs
|
||||
lhsExtension :: [FilePath] -> Bool
|
||||
|
@ -667,7 +667,10 @@ main = do
|
|||
|
||||
-- assign reader and writer based on options and filenames
|
||||
let readerName' = if null readerName
|
||||
then defaultReaderName sources
|
||||
then let fallback = if any isURI sources
|
||||
then "html"
|
||||
else "markdown"
|
||||
in defaultReaderName fallback sources
|
||||
else readerName
|
||||
|
||||
let writerName' = if null writerName
|
||||
|
|
Loading…
Add table
Reference in a new issue