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

[WIP] Rows are not regexes --- LaTeX only #795

Closed

Conversation

vincentarelbundock
Copy link
Collaborator

@vincentarelbundock vincentarelbundock commented Dec 10, 2023

There is a problematic pattern in row_spec(), column_spec() and maybe elsewhere:

  1. Extract row contents with magic_mirror(kable_input)
  2. Feed the content of the row as the first argument to gsub(row, row_modified, perl=TRUE)

In many cases, this works well to modify the table. But whenever the content of the row includes regex tokens, the results are unpredictable.

For example, in issue #582 , the command produces bad results because the row includes dots, which are interpreted as "any character". I suspect that several of the weird corner case bugs reported on the issue tracker stem from this.

This work-in-progress PR switches perl=TRUE to fixed=TRUE, and makes other attendant changes. Since changing these internals could have unpredictable results, I also add a lot of snapshot tests and also tests to see if Rmarkdown documents can compile to PDF.

TODO:

  • [!h] visible in some tables in awesome_table_in_pdf.pdf
  • Test indent
  • Figure out the complex regex in add_indent()
  • cleaner solution to the \\makecell double escape
  • Extra space in last cell of best_practice doc

@dmurdoch
Copy link
Collaborator

If fixed works, that seems easiest, but I'm guessing there are cases where it won't be easy to get it to work. For most of those cases you can probably wrap the user code as \Q ... \E, though I guess that won't work for code containing \E.

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

Successfully merging this pull request may close these issues.

2 participants