@@ -38,9 +38,8 @@ import Text.Pandoc.BCP47 (renderLang)
38import Text.Pandoc.Builder as B
38import Text.Pandoc.Builder as B
39import Text.Pandoc.Class.PandocPure (PandocPure)
39import Text.Pandoc.Class.PandocPure (PandocPure)
40import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
40import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
41− readFileFromDirs, report,
42− setResourcePath)
41+ report, setResourcePath)
43−import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError))
42+import Text.Pandoc.Error (PandocError (PandocParsecError))
44import Text.Pandoc.Highlighting (languagesByExtension)
43import Text.Pandoc.Highlighting (languagesByExtension)
45import Text.Pandoc.ImageSize (numUnit, showFl)
44import Text.Pandoc.ImageSize (numUnit, showFl)
46import Text.Pandoc.Logging
45import Text.Pandoc.Logging
@@ -61,6 +60,8 @@ import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
61 enquoteCommands,
60 enquoteCommands,
62 babelLangToBCP47, setDefaultLanguage)
61 babelLangToBCP47, setDefaultLanguage)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
62import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
63+import Text.Pandoc.Readers.LaTeX.Include (insertIncluded,
64+ readFileFromTexinputs)
64import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
65import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
65 nameCommands, charCommands,
66 nameCommands, charCommands,
66 accentCommands,
67 accentCommands,
@@ -235,19 +236,10 @@ mkImage options (T.unpack -> src) = do
235 _ -> return src
236 _ -> return src
236 return $ imageWith attr (T.pack src') "" alt
237 return $ imageWith attr (T.pack src') "" alt
238−doxspace :: PandocMonad m => LP m Inlines
240− (space <$ lookAhead (satisfyTok startsWithLetter)) <|> return mempty
241− where startsWithLetter (Tok _ Word t) =
243− Just (c, _) | isLetter c -> True
245− startsWithLetter _ = False
248removeDoubleQuotes :: Text -> Text
240removeDoubleQuotes :: Text -> Text
249removeDoubleQuotes t =
241removeDoubleQuotes t =
250− Data.Maybe.fromMaybe t $ T.stripPrefix "\"" t >>= T.stripSuffix "\""
242+ fromMaybe t $ T.stripPrefix "\"" t >>= T.stripSuffix "\""
252doubleQuote :: PandocMonad m => LP m Inlines
244doubleQuote :: PandocMonad m => LP m Inlines
253doubleQuote =
245doubleQuote =
@@ -406,8 +398,8 @@ inlineCommands = M.unions
406 link (unescapeURL $ untokenize url) "" <$> tok)
398 link (unescapeURL $ untokenize url) "" <$> tok)
407 , ("includegraphics", do options <- option [] keyvals
399 , ("includegraphics", do options <- option [] keyvals
408 src <- braced
400 src <- braced
409− mkImage options . unescapeURL . removeDoubleQuotes $
401+ mkImage options . unescapeURL .
410− untokenize src)
402+ removeDoubleQuotes $ untokenize src)
411 , ("hyperlink", hyperlink)
403 , ("hyperlink", hyperlink)
412 , ("hypertarget", hypertargetInline)
404 , ("hypertarget", hypertargetInline)
413 -- hyphenat
405 -- hyphenat
@@ -417,8 +409,6 @@ inlineCommands = M.unions
417 -- LaTeX colors
409 -- LaTeX colors
418 , ("textcolor", coloredInline "color")
410 , ("textcolor", coloredInline "color")
419 , ("colorbox", coloredInline "background-color")
411 , ("colorbox", coloredInline "background-color")
421− , ("xspace", doxspace)
422 -- etoolbox
412 -- etoolbox
423 , ("ifstrequal", ifstrequal)
413 , ("ifstrequal", ifstrequal)
424 , ("newtoggle", braced >>= newToggle)
414 , ("newtoggle", braced >>= newToggle)
@@ -698,39 +688,6 @@ include name = do
698 mapM_ (insertIncluded defaultExt) fs
688 mapM_ (insertIncluded defaultExt) fs
699 return mempty
689 return mempty
701−readFileFromTexinputs :: PandocMonad m => FilePath -> LP m (Maybe Text)
702−readFileFromTexinputs fp = do
703− fileContentsMap <- sFileContents <$> getState
704− case M.lookup (T.pack fp) fileContentsMap of
705− Just t -> return (Just t)
707− dirs <- map T.unpack . splitTextBy (==':') . fromMaybe "."
708− <$> lookupEnv "TEXINPUTS"
709− readFileFromDirs dirs fp
711−insertIncluded :: PandocMonad m
715−insertIncluded defaultExtension f' = do
716− let f = case takeExtension f' of
719− _ -> addExtension f' defaultExtension
721− containers <- getIncludeFiles <$> getState
722− when (T.pack f `elem` containers) $
723− throwError $ PandocParseError $ T.pack $ "Include file loop at " ++ show pos
724− updateState $ addIncludeFile $ T.pack f
725− mbcontents <- readFileFromTexinputs f
726− contents <- case mbcontents of
729− report $ CouldNotLoadIncludeFile (T.pack f) pos
731− getInput >>= setInput . (tokenize f contents ++)
732− updateState dropLatestIncludeFile
734authors :: PandocMonad m => LP m ()
691authors :: PandocMonad m => LP m ()
735authors = try $ do
692authors = try $ do