aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-11-12 14:46:29 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-11-12 14:46:29 -0800
commiteeaa3b048c325859d049f1b7aa7f60553c897aa6 (patch)
treeefdc25f50e264c5325aad5ca1acc54f9ab25b6b6 /src/Text/Pandoc
parent7ba0ae8b4d9a6d3e7d4484a5f257e1e53f35667d (diff)
downloadpandoc-eeaa3b048c325859d049f1b7aa7f60553c897aa6.tar.gz
LaTeX reader: support column specs like `*{2}{r}`.
This is equivalent to `rr`. We now expand it like a macro. Closes #4056.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 708980f1d..28c8fd736 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -2406,8 +2406,7 @@ parseAligns = try $ do
case safeRead ds of
Just w -> return w
Nothing -> return 0.0
- let alignSpec = try $ do
- spaces
+ let alignSpec = do
pref <- option [] alignPrefix
spaces
al <- alignChar
@@ -2418,10 +2417,21 @@ parseAligns = try $ do
spaces
suff <- option [] alignSuffix
return (al, width, (pref, suff))
+ let starAlign = do -- *{2}{r} == rr, we just expand like a macro
+ symbol '*'
+ spaces
+ ds <- trim . toksToString <$> braced
+ spaces
+ spec <- braced
+ case safeRead ds of
+ Just n -> do
+ getInput >>= setInput . (mconcat (replicate n spec) ++)
+ Nothing -> fail $ "Could not parse " ++ ds ++ " as number"
bgroup
spaces
maybeBar
- aligns' <- many (alignSpec <* maybeBar)
+ aligns' <- many $ try $ spaces >> optional starAlign >>
+ (alignSpec <* maybeBar)
spaces
egroup
spaces