Skip to content

fix: escape the cols_merge_range() and cols_merge_uncert() separator in LaTeX - #1176

Open
LuisFigueroaG wants to merge 1 commit into
posit-dev:mainfrom
LuisFigueroaG:fix/merge-sep-latex-escape
Open

LuisFigueroaG wants to merge 1 commit into
posit-dev:mainfrom
LuisFigueroaG:fix/merge-sep-latex-escape

Conversation

@LuisFigueroaG

Copy link
Copy Markdown
Contributor

Summary

The sep= of cols_merge_range() and cols_merge_uncert() is put between the two values as is, so in LaTeX output any special character in it goes straight into the table. With & that splits the merged cell into two columns:

import polars as pl
from great_tables import GT

df = pl.DataFrame({"low": [1, 3], "high": [2, 4]})
GT(df).cols_merge_range(col_begin="low", col_end="high", sep=" & ").as_latex()
# before: 1 & 2 \\   (two cells in a one-column table)
# after:  1 \& 2 \\

The separator is now escaped for LaTeX when the merge is performed, the same way the literal parts of a formatter's pattern= already are. HTML output is unchanged.

I added a test for each function checking the LaTeX and HTML values with an & separator.

Related GitHub Issues and PRs

Checklist

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.71%. Comparing base (a7002c2) to head (9b97255).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1176   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files          73       73           
  Lines       14714    14716    +2     
=======================================
+ Hits        14525    14527    +2     
  Misses        189      189           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

1 participant