Fixup some knitr syntax in Lua to support SQL engine output #7829
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.
This closes #4869
I believe knitr SQL engine is not correctly designed, and this creates for us some difficulty to catch its output to wrap it under output
cell-output-display
div. The engine setsresults = 'asis'
and the output is onlycat()
without any other processing (no hooks, or no sewing of class item).sew.character
is directly applied on it and not thesew()
method that we do patch.Anyhow, i did not find any easy way to do the fixup in R without regex or else. It seemed fragile, and more robust to add a fixup stage in Lua. This is possible because a
div
is emitted and this is correctly parsed aspandoc.Div
due tonative_spans
extension being the default.Other approach would be to consider this behavior in Quarto a bug in knitr and would require an update of the .sql engine for its output to go through the proper
sew()
processing, or have aclass
we can catch (we should catch aknit_asis
element but here it is missing).Doing this in knitr would require an update of knitr to be used with Quarto - this fix here should solve for any knitr version.
This could be interesting in the meantime to have it, but if you think fixing this in knitr is better I can work on that too.
@cscheid I added the step as an init step with a conditional on engine being used. My understanding is that this should happen from the start of AST normalization before any processing as we are fixing up the input syntax. If this needs to be elsewhere, please do tell me.