git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: handle includes without surrounding blanklines.

In addition, `\input` can now be used in an inline context, e.g. to provide part of a paragraph, as it can in LaTeX. Closes #4553.

commitd32e8664498d799932927d9865ce71e014472ef3 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 1 Jun 2018, 09:24 (8 years ago) parent0fc7d38
4 files changed+26−7
pandoc.cabal+1 src/Text/Pandoc/Readers/LaTeX.hs+9−7 test/command/4553.md+15 test/command/bar.tex+1
pandoc.cabal+1
@@ -192,6 +192,7 @@ extra-source-files:
192192 test/command/inkscape-cube.svg
193193 test/command/sub-file-chapter-1.tex
194194 test/command/sub-file-chapter-2.tex
195+ test/command/bar.tex
195196 test/command/3510-subdoc.org
196197 test/command/3510-export.latex
197198 test/command/3510-src.hs
src/Text/Pandoc/Readers/LaTeX.hs+9−7
@@ -1642,6 +1642,8 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
16421642 , ("Rn", romanNumeralLower)
16431643 -- babel
16441644 , ("foreignlanguage", foreignlanguage)
1645+ -- include
1646+ , ("input", include "input")
16451647 ]
16461648
16471649makeUppercase :: Inlines -> Inlines
@@ -1917,7 +1919,6 @@ end_ t = try (do
19171919preamble :: PandocMonad m => LP m Blocks
19181920preamble = mempty <$ many preambleBlock
19191921 where preambleBlock = spaces1
1920− <|> void include
19211922 <|> void macroDef
19221923 <|> void blockCommand
19231924 <|> void braced
@@ -1930,11 +1931,8 @@ paragraph = do
19301931 then return mempty
19311932 else return $ para x
19321933
1933−include :: PandocMonad m => LP m Blocks
1934−include = do
1935− (Tok _ (CtrlSeq name) _) <-
1936− controlSeq "include" <|> controlSeq "input" <|>
1937− controlSeq "subfile" <|> controlSeq "usepackage"
1934+include :: (PandocMonad m, Monoid a) => Text -> LP m a
1935+include name = do
19381936 skipMany opt
19391937 fs <- (map (T.unpack . removeDoubleQuotes . T.strip) . T.splitOn "," .
19401938 untokenize) <$> braced
@@ -2251,6 +2249,11 @@ blockCommands = M.fromList
22512249 -- LaTeX colors
22522250 , ("textcolor", coloredBlock "color")
22532251 , ("colorbox", coloredBlock "background-color")
2252+ -- include
2253+ , ("include", include "include")
2254+ , ("input", include "input")
2255+ , ("subfile", include "subfile")
2256+ , ("usepackage", include "usepackage")
22542257 ]
22552258
22562259
@@ -2689,7 +2692,6 @@ block :: PandocMonad m => LP m Blocks
26892692block = do
26902693 res <- (mempty <$ spaces1)
26912694 <|> environment
2692− <|> include
26932695 <|> macroDef
26942696 <|> blockCommand
26952697 <|> paragraph
test/command/4553.mdnew file+15
@@ -0,0 +1,15 @@
1+```
2+pandoc -f latex -t native
3+foo \include{command/bar}
4+^D
5+[Para [Str "foo"]
6+,Para [Emph [Str "hi",Space,Str "there"]]]
7+```
8+
9+```
10+pandoc -f latex -t native
11+foo \input{command/bar}
12+^D
13+[Para [Str "foo",Space,Emph [Str "hi",Space,Str "there"]]]
14+```
15+
test/command/bar.texnew file+1
@@ -0,0 +1 @@
1+\emph{hi there}