-
Notifications
You must be signed in to change notification settings - Fork 213
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
Alignment when using parentheses for negative values (#144) #149
Conversation
@steveputman Thanks for this contribution! It'd be great if this change didn't result in the default formatter code being copy/pasted for html and latex, but instead to use the "function factory" pattern--see |
@jcheng5 — got it. It was bugging me when I was copying and pasting! Will have a look and revert. |
Added factory functions for I suppose there could be a megafactory function for just about all the functions in I assigned the HTML and LaTeX used for all the nonneg formatting to vars near the top of the file but wonder if the HTML and LaTeX should just be repeated in the calls to the factory functions to avoid a sort of Where's Waldo problem. Any further guidance would be appreciated. |
This looks really good. I sort of agree with the idea of a larger/better function for all of the functions here. However, there is still some not-yet-merged PRs that need to be integrated here first. I think that this could be part of a separate refactoring PR for this file. I would put this inside the # Strings for alignment of non-negative number in formatting functions
paren_nonneg_start_html <- "<span style=\"visibility: hidden;\">(</span>"
paren_nonneg_end_html <- "<span style=\"visibility: hidden;\">)</span>"
paren_nonneg_start_latex <- "\\hphantom{(}"
paren_nonneg_end_latex <- "\\hphantom{)}" Thanks again for your continued work on this. This will get merged soon! |
Thanks for the quick turnaround on this. We will review again and merge soon after that. A final ask: could you please sign the individual or corporate contributor agreement as appropriate. Then, send the signed copy over to [email protected]. (This is something we ask of any significant outside contribution.) |
Thanks! Contributor agreement sent. |
Closing this PR; will replace with new PR to reflect refactoring of formatters |
@rich-iannone Here's a first cut. Code changes in
format_data.R
(I conformed the order of the latex/html/default functions in what I dealt with--that might have screwed up the diff, so happy to try to put that back together). Basically just takes the nonneg vector fromx_str
and applies leading and trailing hidden spaces, usinghphantom{}
in LaTeX and<span>
in HTML. Changes applied for LaTeX and HTML infmt_number()
,fmt_percent
, andfmt_currency
.