@@ -118,34 +118,7 @@ findFile (f:fs) = do
118118-- in response to a command-line option.
119119options :: [OptDescr (Opt -> IO Opt)]
120120options =
121− [ Option "" ["defaults"]
122− (ReqArg
123− (\arg opt -> runIOorExplode $ do
124− setVerbosity $ optVerbosity opt
125− let fp = if null (takeExtension arg)
126− then addExtension arg "yaml"
127− else arg
128− dataDirs <- liftIO defaultUserDataDirs
129− let fps = case optDataDir opt of
130− Nothing -> (fp : map (</> ("defaults" </> fp))
131− dataDirs)
132− Just dd -> [fp, dd </> "defaults" </> fp]
133− fp' <- fromMaybe fp <$> findFile fps
134− inp <- readFileLazy fp'
135− let defaults = YA.encode1 opt
136− case YA.decode1 (defaults <> inp) of
137− Right (newopts :: Opt) -> return newopts
138− Left (errpos, errmsg) -> throwError $
139− PandocParseError $
140− "Error parsing " ++ fp' ++
141− " (line " ++ show (Y.posLine errpos) ++
142− " column " ++ show (Y.posColumn errpos) ++
143− ")\n" ++ errmsg
144− )
145− "FILE")
146− ""
147−
148− , Option "fr" ["from","read"]
121+ [ Option "fr" ["from","read"]
149122 (ReqArg
150123 (\arg opt -> return opt { optFrom =
151124 Just (map toLower arg) })
@@ -165,31 +138,6 @@ options =
165138 "FILE")
166139 "" -- "Name of output file"
167140
168− , Option "" ["wrap"]
169− (ReqArg
170− (\arg opt ->
171− case arg of
172− "auto" -> return opt{ optWrapText = WrapAuto }
173− "none" -> return opt{ optWrapText = WrapNone }
174− "preserve" -> return opt{ optWrapText = WrapPreserve }
175− _ -> E.throwIO $ PandocOptionError
176− "--wrap must be auto, none, or preserve")
177− "auto|none|preserve")
178− "" -- "Option for wrapping text in output"
179−
180− , Option "s" ["standalone"]
181− (NoArg
182− (\opt -> return opt { optStandalone = True }))
183− "" -- "Include needed header and footer on output"
184−
185− , Option "" ["template"]
186− (ReqArg
187− (\arg opt ->
188− return opt{ optTemplate = Just (normalizePath arg),
189− optStandalone = True })
190− "FILE")
191− "" -- "Use custom template"
192−
193141 , Option "" ["data-dir"]
194142 (ReqArg
195143 (\arg opt -> return opt { optDataDir =
@@ -213,6 +161,51 @@ options =
213161 "FILE")
214162 ""
215163
164+ , Option "" ["defaults"]
165+ (ReqArg
166+ (\arg opt -> runIOorExplode $ do
167+ setVerbosity $ optVerbosity opt
168+ let fp = if null (takeExtension arg)
169+ then addExtension arg "yaml"
170+ else arg
171+ dataDirs <- liftIO defaultUserDataDirs
172+ let fps = case optDataDir opt of
173+ Nothing -> (fp : map (</> ("defaults" </> fp))
174+ dataDirs)
175+ Just dd -> [fp, dd </> "defaults" </> fp]
176+ fp' <- fromMaybe fp <$> findFile fps
177+ inp <- readFileLazy fp'
178+ let defaults = YA.encode1 opt
179+ case YA.decode1 (defaults <> inp) of
180+ Right (newopts :: Opt) -> return newopts
181+ Left (errpos, errmsg) -> throwError $
182+ PandocParseError $
183+ "Error parsing " ++ fp' ++
184+ " (line " ++ show (Y.posLine errpos) ++
185+ " column " ++ show (Y.posColumn errpos) ++
186+ ")\n" ++ errmsg
187+ )
188+ "FILE")
189+ ""
190+
191+ , Option "" ["file-scope"]
192+ (NoArg
193+ (\opt -> return opt { optFileScope = True }))
194+ "" -- "Parse input files before combining"
195+
196+ , Option "s" ["standalone"]
197+ (NoArg
198+ (\opt -> return opt { optStandalone = True }))
199+ "" -- "Include needed header and footer on output"
200+
201+ , Option "" ["template"]
202+ (ReqArg
203+ (\arg opt ->
204+ return opt{ optTemplate = Just (normalizePath arg),
205+ optStandalone = True })
206+ "FILE")
207+ "" -- "Use custom template"
208+
216209 , Option "V" ["variable"]
217210 (ReqArg
218211 (\arg opt -> do
@@ -222,6 +215,18 @@ options =
222215 "KEY[:VALUE]")
223216 ""
224217
218+ , Option "" ["wrap"]
219+ (ReqArg
220+ (\arg opt ->
221+ case arg of
222+ "auto" -> return opt{ optWrapText = WrapAuto }
223+ "none" -> return opt{ optWrapText = WrapNone }
224+ "preserve" -> return opt{ optWrapText = WrapPreserve }
225+ _ -> E.throwIO $ PandocOptionError
226+ "--wrap must be auto, none, or preserve")
227+ "auto|none|preserve")
228+ "" -- "Option for wrapping text in output"
229+
225230 , Option "" ["ascii"]
226231 (NoArg
227232 (\opt -> return opt { optAscii = True }))
@@ -431,11 +436,6 @@ options =
431436 "NAME:VALUE")
432437 ""
433438
434− , Option "" ["file-scope"]
435− (NoArg
436− (\opt -> return opt { optFileScope = True }))
437− "" -- "Parse input files before combining"
438−
439439 , Option "" ["abbreviations"]
440440 (ReqArg
441441 (\arg opt -> return opt { optAbbreviations = Just arg })