git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: support column specs like `*{2}{r}`.
eeaa3b0John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+13−3
@@ -2406,8 +2406,7 @@ parseAligns = try $ do
2406 case safeRead ds of
2406 case safeRead ds of
2407 Just w -> return w
2407 Just w -> return w
2408 Nothing -> return 0.0
2408 Nothing -> return 0.0
2409− let alignSpec = try $ do
2409+ let alignSpec = do
2410− spaces
2411 pref <- option [] alignPrefix
2410 pref <- option [] alignPrefix
2412 spaces
2411 spaces
2413 al <- alignChar
2412 al <- alignChar
@@ -2418,10 +2417,21 @@ parseAligns = try $ do
2418 spaces
2417 spaces
2419 suff <- option [] alignSuffix
2418 suff <- option [] alignSuffix
2420 return (al, width, (pref, suff))
2419 return (al, width, (pref, suff))
2420+ let starAlign = do -- *{2}{r} == rr, we just expand like a macro
2421+ symbol '*'
2422+ spaces
2423+ ds <- trim . toksToString <$> braced
2424+ spaces
2425+ spec <- braced
2426+ case safeRead ds of
2427+ Just n -> do
2428+ getInput >>= setInput . (mconcat (replicate n spec) ++)
2429+ Nothing -> fail $ "Could not parse " ++ ds ++ " as number"
2421 bgroup
2430 bgroup
2422 spaces
2431 spaces
2423 maybeBar
2432 maybeBar
2433+ aligns' <- many $ try $ spaces >> optional starAlign >>
2424− aligns' <- many (alignSpec <* maybeBar)
2434+ (alignSpec <* maybeBar)
2425 spaces
2435 spaces
2426 egroup
2436 egroup
2427 spaces
2437 spaces
test/command/4056.md+14−1
@@ -8,4 +8,17 @@
8[RawBlock (Format "latex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"]
8[RawBlock (Format "latex") "\\parbox[t]{0.4\\textwidth}{\n\\begin{shaded}\n\\end{shaded}\n}"]
9```
9```
10
10
11−
11+```
12+% pandoc -f latex -t native
13+\begin{tabular}{l*{2}{r}}
14+Blah & Foo & Bar \\
15+\end{tabular}
16+^D
17+[Table [] [AlignLeft,AlignRight,AlignRight] [0.0,0.0,0.0]
18+ [[]
19+ ,[]
20+ ,[]]
21+ [[[Plain [Str "Blah"]]
22+ ,[Plain [Str "Foo"]]
23+ ,[Plain [Str "Bar"]]]]]
24+```