yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

Restore `opts_current` after each code chunk, and also after `knit()` exits #2292

Closed yihui closed 8 months ago

yihui commented 9 months ago

Will this fix #1988? (except for the support of inline labels)

yihui commented 8 months ago

I've applied your patch with a small change. Thanks!

Now inline code will have access to a unique label in opts_current$get('label').

cderv commented 8 months ago

Cool thanks !

I wonder how many side effect this unamed chunk scheme could cause 😅 it is possible that some user may rely on it too much. Would it invalidate existing cache too ?

Not saying it is bad, but we could probably communicate ahead of time if this could help

yihui commented 8 months ago

Yes, this could be a breaking change, so I've started the revdep check: https://github.com/yihui/crandalf/actions/runs/6644880330/job/18054982641 I'll see how bad this change could be, and write a blog post accordingly.

yihui commented 8 months ago

I've reverted the change in the naming scheme, since the revdep check showed that a few packages would be broken.