@@ -90,11 +90,11 @@ import System.Posix.IO (stdOutput)
90import System.Posix.Terminal (queryTerminal)
90import System.Posix.Terminal (queryTerminal)
93−data Newline = LF | CRLF deriving (Show, Generic)
93+data LineEnding = LF | CRLF | Native deriving (Show, Generic)
95−instance ToJSON Newline where
95+instance ToJSON LineEnding where
96 toEncoding = genericToEncoding defaultOptions
96 toEncoding = genericToEncoding defaultOptions
97−instance FromJSON Newline
97+instance FromJSON LineEnding
99parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
99parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
100parseOptions options' defaults = do
100parseOptions options' defaults = do
@@ -422,9 +422,9 @@ convertWithOpts opts = do
422 else return $ optMetadata opts
422 else return $ optMetadata opts
424 let eol = case optEol opts of
424 let eol = case optEol opts of
425− Just CRLF -> IO.CRLF
425+ CRLF -> IO.CRLF
426− Just LF -> IO.LF
426+ LF -> IO.LF
427− Nothing -> nativeNewline
427+ Native -> nativeNewline
429 runIO' $ do
429 runIO' $ do
430 setResourcePath (optResourcePath opts)
430 setResourcePath (optResourcePath opts)
@@ -584,7 +584,7 @@ data Opt = Opt
584 , optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
584 , optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
585 , optIncludeInHeader :: [FilePath] -- ^ Files to include in header
585 , optIncludeInHeader :: [FilePath] -- ^ Files to include in header
586 , optResourcePath :: [FilePath] -- ^ Path to search for images etc
586 , optResourcePath :: [FilePath] -- ^ Path to search for images etc
587− , optEol :: Maybe Newline -- ^ Enforce line-endings
587+ , optEol :: LineEnding -- ^ Style of line-endings to use
588 } deriving (Generic, Show)
588 } deriving (Generic, Show)
590instance ToJSON Opt where
590instance ToJSON Opt where
@@ -658,7 +658,7 @@ defaultOpts = Opt
658 , optIncludeAfterBody = []
658 , optIncludeAfterBody = []
659 , optIncludeInHeader = []
659 , optIncludeInHeader = []
660 , optResourcePath = ["."]
660 , optResourcePath = ["."]
661− , optEol = Nothing
661+ , optEol = Native
664addMetadata :: (String, String) -> Pandoc -> Pandoc
664addMetadata :: (String, String) -> Pandoc -> Pandoc
@@ -986,12 +986,13 @@ options =
987 (\arg opt ->
987 (\arg opt ->
988 case toLower <$> arg of
988 case toLower <$> arg of
989− "crlf" -> return opt { optEol = Just CRLF }
989+ "crlf" -> return opt { optEol = CRLF }
990− "lf" -> return opt { optEol = Just LF }
990+ "lf" -> return opt { optEol = LF }
991+ "native" -> return opt { optEol = Native }
991 -- mac-syntax (cr) is not supported in ghc-base.
992 -- mac-syntax (cr) is not supported in ghc-base.
992 _ -> E.throwIO $ PandocOptionError
993 _ -> E.throwIO $ PandocOptionError
993− "--eol must be one of crlf (Windows), lf (Unix)")
994+ "--eol must be crlf, lf, or native")
994− "crlf|lf")
995+ "crlf|lf|native")
995 "" -- "EOL (default OS-dependent)"
996 "" -- "EOL (default OS-dependent)"
997 , Option "" ["wrap"]
998 , Option "" ["wrap"]