-
Notifications
You must be signed in to change notification settings - Fork 209
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
Rewrite of RTF building functions and as_rtf()
#638
Conversation
}, | ||
item = function(x, process) { | ||
# TODO: probably needs something like process_children() | ||
rtf_escape(xml2::xml_text(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you replace this with process(xml2::xml_children(x))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do make just that change, it just affects the markdown to RTF conversion of lists, and, we get unprocessed XML tags in the RTF.
With the following gt code
dplyr::tibble(markdown = "- item 1\n- item 2\n\n") %>%
gt() %>%
fmt_markdown(vars(markdown))
We get this RTF markup (just showing the one row):
\row
\trowd\trrh0
\pard\plain\uc0\ql\clvertalc\clpadb50\clpadfb3\clpadr50\clpadfr3\clpadl50\clpadfl3\clpadt50\clpadft3\clbrdrb\brdrs\brdrw10\brdrcf1\clbrdrl\brdrs\brdrw10\brdrcf1\clbrdrr\brdrs\brdrw10\brdrcf1\cellx9468
\intbl {\f0 {\f0\fs20 \pard\intbl\itap1\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720 \ls1\ilvl0\cf0
{\listtext }\u8226 <paragraph>
<text xml:space="preserve">item 1</text>
</paragraph>\
{\listtext }\u8226 <paragraph>
<text xml:space="preserve">item 2</text>
</paragraph>\
}}\cell
\pard\plain
\row
R/utils.R
Outdated
# assume there is only `type` values of "ordered" and "bullet" (unordered) | ||
rtf_raw( | ||
paste( | ||
"\\pard\\intbl\\itap1\\tx220\\tx720\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\\tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\li720\\fi-720", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the tab-stops are needed? What happens if you remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't needed. I followed your advice and lowered the values for li
and fi
to 300
and it looks much better. New line:
"\\pard\\intbl\\itap1\\li300\\fi-300"
The removal of tab stops only removes those stops in Word for the cell. But I don't think they're really useful.
* master: Rewrite of RTF building functions and `as_rtf()` (#638) v0.2.2 Release Candidate (#629) Settable font options (#591) Add options for sig figs / inclusion of trailing dec marks (#546) Fix issues with defining column widths in `cols_width()` (#561) Add `scale_values` arg to `fmt_percent()` (#565) Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556)
* master: (30 commits) Spanner alignment correction (#662) PEN currency fix (#663) Fix for `gtsave()` when saving an image and specifying a `path` value (#592) Rewrite of RTF building functions and `as_rtf()` (#638) v0.2.2 Release Candidate (#629) Settable font options (#591) Add options for sig figs / inclusion of trailing dec marks (#546) Fix issues with defining column widths in `cols_width()` (#561) Add `scale_values` arg to `fmt_percent()` (#565) Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564) Refactor `data_color()` so that it executes faster (#576) Update R-CMD-check.yaml (#599) Release gt 0.2.1 (#588) Ensure that row ordering doesn't affect summary row calculations (#556) Update failing example (#586) Remove test of scales behaviour Squelch warnings from tibble 3.0.0/3.0.1 (#557) Bump cache on pkgdown.yaml for GH workflow (#570) Update GH Actions workflow for R CMD check (#568) Update Description of package to be less confusing (#569) ...
This PR focusses on improving the RTF output of gt tables.