@@ -73,7 +73,7 @@ import Text.Pandoc.PDF (makePDF)
7373import Text.Pandoc.Readers.Markdown (yamlToMeta)
7474import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
7575import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,
76− headerShift, isURI, tabFilter, uriPathToPath)
76+ headerShift, isURI, tabFilter, uriPathToPath, filterIpynbOutput)
7777import qualified Text.Pandoc.UTF8 as UTF8
7878#ifndef _WINDOWS
7979import System.Posix.IO (stdOutput)
@@ -247,8 +247,20 @@ convertWithOpts opts = do
247247 (writerExtensions writerOptions) &&
248248 writerWrapText writerOptions == WrapPreserve)
249249 then (eastAsianLineBreakFilter :)
250− else id) $
251− []
250+ else id) .
251+ (case optIpynbOutput opts of
252+ "all" -> id
253+ "none" -> (filterIpynbOutput Nothing :)
254+ "best" -> (filterIpynbOutput (Just $
255+ if htmlFormat writerName
256+ then Format "html"
257+ else
258+ case writerName of
259+ "latex" -> Format "latex"
260+ "beamer" -> Format "latex"
261+ _ -> Format writerName) :)
262+ _ -> id) -- should not happen
263+ $ []
252264
253265 let sourceToDoc :: [FilePath] -> PandocIO Pandoc
254266 sourceToDoc sources' =
@@ -293,15 +305,12 @@ convertWithOpts opts = do
293305 TL.unpack (TE.decodeUtf8With TE.lenientDecode err')
294306
295307 Nothing -> do
296− let htmlFormat = format `elem`
297− ["html","html4","html5","s5","slidy",
298− "slideous","dzslides","revealjs"]
299− addNl = if standalone
308+ let addNl = if standalone
300309 then id
301310 else (<> T.singleton '\n')
302311 output <- addNl <$> f writerOptions doc
303312 writerFn eol outputFile =<<
304− if optSelfContained opts && htmlFormat
313+ if optSelfContained opts && htmlFormat writerName
305314 -- TODO not maximally efficient; change type
306315 -- of makeSelfContained so it works w/ Text
307316 then T.pack <$> makeSelfContained (T.unpack output)
@@ -309,6 +318,10 @@ convertWithOpts opts = do
309318
310319type Transform = Pandoc -> Pandoc
311320
321+htmlFormat :: String -> Bool
322+htmlFormat = (`elem` ["html","html4","html5","s5","slidy",
323+ "slideous","dzslides","revealjs"])
324+
312325isTextFormat :: String -> Bool
313326isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"]
314327