correctly detect the docx output format for pandoc conversion #1084
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 should fix quarto-dev/quarto-cli#2996 and probably a better solution than #1063 which should fix #1040
I don't think
rmarkdown::all_output_formats()
should be used that way to detect format. First it is unnecessary andknitr::pandoc_to()
(or directly checkingrmarkdown.pandoc.to
as done in gt) should be enough to know which output format will be targeted by Pandoc for you to insert the correct raw code.Second, it is won't work well from within subfolder it seems - probably an issue with rmarkdown but that is another topic. This is what causes issue within Quarto too.
And lastly, you are doing what I believe to be the correct thing for
knitr_is_rtf_output()
and something different should not be done forknitr_is_word_output
IMO.I did not go that far, but just so you know you could remove your
knitr_is_**
function, and just rely onknitr::pandoc_to()
isTRUE(knitr::pandoc_to("rtf"))
isTRUE(knitr::pandoc_to("docx"))
This will also work with Quarto and Quarto will set the knitr option correctly based on output format.
I tested this PR solves quarto-dev/quarto-cli#2996 - it will probably also solved #1040 and replace #1063 that would be to close.
Hope it helps