Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper empty cell filtering in LaTeX reader #6681

Closed
despresc opened this issue Sep 12, 2020 · 5 comments · Fixed by #6689
Closed

Improper empty cell filtering in LaTeX reader #6681

despresc opened this issue Sep 12, 2020 · 5 comments · Fixed by #6689

Comments

@despresc
Copy link
Contributor

In Readers.LaTeX the following is done to work around the fact that LaTeX tables explicitly note the grid spaces taken up by multirowand multicolumn cells:

-- Because of table normalization performed by Text.Pandoc.Builder.table,
-- we need to remove empty cells
return $ Row nullAttr $ filter (\c -> c /= emptyCell) cells

It fixes the problem, but it also removes empty cells that don't denote such grid spaces.

E.g. using master on this LaTeX input:

\documentclass{article}

\begin{document}
\begin{tabular}{|r|r|r|}
  A &   & B \\
    & C &
\end{tabular}
\end{document}

gives this native output:

[Table ("",[],[]) (Caption Nothing
 [])
 [(AlignRight,ColWidthDefault)
 ,(AlignRight,ColWidthDefault)
 ,(AlignRight,ColWidthDefault)]
 (TableHead ("",[],[])
 [])
 [(TableBody ("",[],[]) (RowHeadColumns 0)
  []
  [Row ("",[],[])
   [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    [Plain [Str "A"]]
   ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    [Plain [Str "B"]]
   ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    []]
  ,Row ("",[],[])
   [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    [Plain [Str "C"]]
   ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    []
   ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1)
    []]])]
 (TableFoot ("",[],[])
 [])]

and you can see that the space between A and B is gone, and C has migrated to the first column.

@despresc
Copy link
Contributor Author

This can't be fixed in parseTableRow locally. Either the relevant data about \multirow cells need to be passed in to parseTableRow so that the two types of emptyCell can be distinguished, or the parsed table needs to be fixed up at the very end, in simpTable. The latter is probably cleaner.

@jgm
Copy link
Owner

jgm commented Sep 13, 2020

Bringing @LaurentRDC into the discussion.
I guess I was right to wonder about the empty cell filtering in that PR (#6608)!

@LaurentRDC
Copy link
Contributor

@jgm Oups, you were right. I'm sorry this is causing trouble.

I have a very busy month of September, so I won't have time to formulate a solution soon unfortunately

@jgm
Copy link
Owner

jgm commented Sep 14, 2020

If someone else can put together a PR sooner, it would be good to get this fixed.

@despresc
Copy link
Contributor Author

I should be able to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants