Replies: 5 comments
-
One issue we need to deal with here is that Rmd files are actually not parseable by Pandoc (the traditional chunk option syntax is actually not valid pandoc code block markup, as it requires strict So while Quarto is technically a ground-up re-implementation we've made compatibility a a cornerstone, so we can't just have carte blanche with new syntax/rules. We could create a world where one execution order exists if you refrain from options on the main chunk header and a different one if you don't, but that could be quite confusing. At the end of the day we thought that the principle of executing existing Rmds unmodified was more important than any features we might be able to introduce by breaking compatibility. It seems to me that for the scenario you describe that we could achieve this outcome with either execution order (i.e. we end up with an .md file with cells/output and content, and if the user edits only content the merge can be done). I am probably missing something though! What are the peculiarities introduced by execution order that make this type of merge more straightforward with execution after the AST is resolved? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation; I think there are ways to work around the issue of back-compatibility with Rmd. A couple of thoughts:
Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
One thing to consider is that the markdown we write from cell output is considerably more structured than what is written by knitr in Rmd (we have hooks that override nearly all of the default output behavior). Try executing with So I think with the current markup a content-only change could indeed be successfully merged back into the source qmd (it would as you said rely on the marked up output being paired with the original code cells inputs by their order). |
Beta Was this translation helpful? Give feedback.
-
OK, thanks, I get your perspective, especially given the existing knitr codebase. As a side note, I believe there's a need for a "patching" framework, where one could apply a set of structured changes (patch) to a document – be it Rmd/qmd or even generic pandoc. This is best done at the AST level, e.g in JSON form or similar. The patch would be some change made to the output manuscript. Having tools to diff, merge, etc. such processes would be very useful, I believe. |
Beta Was this translation helpful? Give feedback.
-
I agree about the patching framework. I have seen some JSON oriented diff/patch libraries and there is of course Google's diff-match-patch library for operating at the markdown source level: https://github.com/google/diff-match-patch |
Beta Was this translation helpful? Give feedback.
-
(Tom pointed me to this discussion group so I'm just discovering it – hopefully I didn't miss a thread in my search.)
Some years ago I remember discussing the knitr process with Yihui and suggesting that perhaps code chunks etc. should instead be captured in pandoc's AST, after pandoc has parsed the input, evaluated, and the output injected in the AST. Historically this access to pandoc's AST wasn't available when knitr first started (IIRC), so the main reason for the current workflow seemed historical.
Seeing that Quarto is a reimplementation centered around pandoc, I was really hoping this would be the new strategy, removing the knitting step before pandoc parsing, and moving it to become an intermediate transform of the AST.
A key reason I see this as beneficial is the opportunity to merge changes made to the output file. For example, if a collaborator edits the text in the final Word document, but doesn't touch the results of computations, it should be possible to merge changes by simply comparing the 2 trees, as all the necessary information is present. In contrast, the knitr step is currently a one-way street (cannot infer back the input document given the output).
I can imagine other benefits along those lines.
Beta Was this translation helpful? Give feedback.
All reactions