Handling of {{< include >}}
shortcodes
#338
Closed
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.
Currently, when you have a file
A.qmd
which has{{< include B.qmd >}}
on line 101, and then some code inB.qmd
errors on line 100, you get a stacktrace pointing toA.qmd
on line 200 which is not helpful. So far, we've just been running quarto's pre-expanded markdown strings instead of the string from a qmd file to handle include shortcodes. But this didn't give us the ability to annotate with the correct line numbers.This PR switches to manual handling of include shortcodes. As far as I can tell, this type of shortcode is the only one that modifies the markdown before handing it off to the execution engine so we should not be in danger of reimplementing too large a share of the quarto internals. (Cf. https://quarto.org/docs/authoring/shortcodes.html) In principle the logic is simple, once a line with an include shortcode is detected, the file at that location is parsed separately and all its chunks added into the overall list.
The quarto docs say the following (https://quarto.org/docs/authoring/includes.html):
and
so I think the way I detect the shortcode should cover all cases that are meant to work (what wouldn't work is to continue some markdown block with an included qmd, but I think that's excluded by the note above).
What I haven't implemented, yet, is the ignoring of shortcodes in code blocks that have
{shortcodes=false}
but this seems rather niche because you'd only need that for explaining the include shortcode in a document. https://quarto.org/docs/extensions/shortcodes.html#escapingThis fixes #310