aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-06-01 09:24:26 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-06-01 09:25:10 -0700
commitd32e8664498d799932927d9865ce71e014472ef3 (patch)
tree84ee3b27a1a442cfd9bc1a13e589ded4afd9f047
parent0fc7d38544346779051c2e25fb1d6f9c98a83a00 (diff)
downloadpandoc-d32e8664498d799932927d9865ce71e014472ef3.tar.gz
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.
-rw-r--r--pandoc.cabal1
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs16
-rw-r--r--test/command/4553.md15
-rw-r--r--test/command/bar.tex1
4 files changed, 26 insertions, 7 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 75eb60d95..3931db123 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -192,6 +192,7 @@ extra-source-files:
test/command/inkscape-cube.svg
test/command/sub-file-chapter-1.tex
test/command/sub-file-chapter-2.tex
+ test/command/bar.tex
test/command/3510-subdoc.org
test/command/3510-export.latex
test/command/3510-src.hs
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index fff628c46..042295fd9 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1642,6 +1642,8 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
, ("Rn", romanNumeralLower)
-- babel
, ("foreignlanguage", foreignlanguage)
+ -- include
+ , ("input", include "input")
]
makeUppercase :: Inlines -> Inlines
@@ -1917,7 +1919,6 @@ end_ t = try (do
preamble :: PandocMonad m => LP m Blocks
preamble = mempty <$ many preambleBlock
where preambleBlock = spaces1
- <|> void include
<|> void macroDef
<|> void blockCommand
<|> void braced
@@ -1930,11 +1931,8 @@ paragraph = do
then return mempty
else return $ para x
-include :: PandocMonad m => LP m Blocks
-include = do
- (Tok _ (CtrlSeq name) _) <-
- controlSeq "include" <|> controlSeq "input" <|>
- controlSeq "subfile" <|> controlSeq "usepackage"
+include :: (PandocMonad m, Monoid a) => Text -> LP m a
+include name = do
skipMany opt
fs <- (map (T.unpack . removeDoubleQuotes . T.strip) . T.splitOn "," .
untokenize) <$> braced
@@ -2251,6 +2249,11 @@ blockCommands = M.fromList
-- LaTeX colors
, ("textcolor", coloredBlock "color")
, ("colorbox", coloredBlock "background-color")
+ -- include
+ , ("include", include "include")
+ , ("input", include "input")
+ , ("subfile", include "subfile")
+ , ("usepackage", include "usepackage")
]
@@ -2689,7 +2692,6 @@ block :: PandocMonad m => LP m Blocks
block = do
res <- (mempty <$ spaces1)
<|> environment
- <|> include
<|> macroDef
<|> blockCommand
<|> paragraph
diff --git a/test/command/4553.md b/test/command/4553.md
new file mode 100644
index 000000000..e5122d4d9
--- /dev/null
+++ b/test/command/4553.md
@@ -0,0 +1,15 @@
+```
+pandoc -f latex -t native
+foo \include{command/bar}
+^D
+[Para [Str "foo"]
+,Para [Emph [Str "hi",Space,Str "there"]]]
+```
+
+```
+pandoc -f latex -t native
+foo \input{command/bar}
+^D
+[Para [Str "foo",Space,Emph [Str "hi",Space,Str "there"]]]
+```
+
diff --git a/test/command/bar.tex b/test/command/bar.tex
new file mode 100644
index 000000000..e2113ab93
--- /dev/null
+++ b/test/command/bar.tex
@@ -0,0 +1 @@
+\emph{hi there}