Skip to content

Read LaTeX tables where there is whitespace before the \begin{tabular} - #17624

Merged
pllim merged 2 commits into
astropy:mainfrom
hamogu:fix_4295_whitespace
Jan 11, 2025
Merged

pllim merged 2 commits into
astropy:mainfrom
hamogu:fix_4295_whitespace

Conversation

@hamogu

@hamogu hamogu commented Jan 10, 2025 •

Copy link
Copy Markdown
Member

This commit fixes #4595 as discussed in that issue:
It makes the finding of the \begin{tabular} (and similar keywords) a little bit more flexible by allowing extra white space. Extra white space is easy to introduce when copying and pasting from a LaTeX file. It does not implement any further flexibility. It does not allow extra text in front of the tag because the reader cannot replace a full LaTeX parser an we prefer to fail in cases like 1 & 3 & 4 \\ \end{tabular} instead of silently dropping the last row of data just because it happens to be in the same line as the \end{tabular}.
It also does not add a reader to read LaTeX tables without the \bgin{tabular} \end{tabular} lines. Every full LaTeX table has those and if users copy and paste from a longer LaTeX file, they can simply include those lines. Documentation has been added to that effect.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@hamogu hamogu added this to the v7.0.1 milestone Jan 10, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

Comment thread docs/changes/io.ascii/17624.bugfix.rst Outdated
@hamogu

hamogu commented Jan 11, 2025

Copy link
Copy Markdown
Member Author

pre-commit.ci autofix

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, nice little paper cut avoidance! Small comments inline.

Comment thread astropy/io/ascii/latex.py
Comment thread astropy/io/ascii/latex.py Outdated
@hamogu

hamogu commented Jan 11, 2025

Copy link
Copy Markdown
Member Author

Note that I didn't' want to shift the entire doctoring inwards y 4 space, but the pre-commit checked failed until I did so with the autofix. I don't like it, but I guess we use that formatter, so that we never have to discuss formatting again... just don't blame me if you don't like it!

hamogu and others added 2 commits January 11, 2025 12:00
This commit  fixes astropy#4595 as discussed in that issue:
It makes the finding of the \begin{tabular} (and similar keywords) a little bit more flexible by allowing extra white space. Extra white space is easy to introduce when copying and pasting from a LaTeX file. It does not implement any further flexibility. It does not allow extra text in front of the tag because the reader cannot replace a full LaTeX parser an we prefer to fail in cases like `1 & 3 & 4 \\ \end{tabular}` instead of silently dropping the last row of data just because it happens to be in the same line as the `\end{tabular}`.
It also does not add a reader to read LaTeX tables without the \bgin{tabular} \end{tabular} lines. Every full LaTeX table has those and if users copy and paste from a longer LaTeX file, they can simply include those lines. Documentation has been added to that effect.
@mhvk
mhvk force-pushed the fix_4295_whitespace branch from 3784f53 to 1002717 Compare January 11, 2025 17:01

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the strange effects of my request to replace the back-slash strings with raw strings...

@pllim
pllim merged commit e6957e7 into astropy:main Jan 11, 2025
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Jan 11, 2025
pllim added a commit that referenced this pull request Jan 13, 2025
…624-on-v7.0.x

Backport PR #17624 on branch v7.0.x (Read LaTeX tables where there is whitespace before the `\begin{tabular}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants