grid context that formats text as-is #1727
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR aims to fix #1701. Briefly, it swaps the html context for grid context in
as_gtable()
.This context will format text with
as.character()
only, to avoid the html escape mechanism that renders poorly in graphics.Please be forewarned that I only have a partial understanding of how contexts work in {gt}, so somebody who is more familiar should double-check whether this is the correct approach.
Here is a reprex from the linked issue, notice that the symbols on the left are now rendered as actual symbols.
Created on 2024-06-20 with reprex v2.1.0
The currency formatting is still quite poor as it displays 'GBP' instead of '£', but I'm not familiar enough with the codebase to know where this should be fixed (the 'how' is just passing unicode symbols).
Related GitHub Issues and PRs
Checklist
testthat
unit tests totests/testthat
for any new functionality.