Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook_purl() writes filename to the md file #2348

Closed
3 tasks done
fenguoerbian opened this issue Jun 6, 2024 · 1 comment
Closed
3 tasks done

hook_purl() writes filename to the md file #2348

fenguoerbian opened this issue Jun 6, 2024 · 1 comment
Labels
bug Bugs

Comments

@fenguoerbian
Copy link

After setting knitr::knit_hooks$set(purl = knitr::hook_purl), the filename of the rscript is also included in the knitted md file. I'm not sure if this is a WIP feature or newly introduced bug or something that's setted wrong in my machine.

An example of Rmd file

---
title: "Template Title"
author: "Your Name"
date: "Last compiled on `r format(Sys.time(), '%d %B, %Y')`"
output: 
  html_document:
    toc: yes
    toc_float: yes
    number_section: yes
    keep_md: TRUE
---

```{r setup, include=FALSE}
knitr::knit_hooks$set(purl = knitr::hook_purl)
```

```{r, a_code_chunk}
1 + 1
```

```{r, current_work_directory}
getwd()
```

```{r sessioninfo}
sessioninfo::session_info()
```

and the rendered .md file is

---
title: "Template Title"
author: "Your Name"
date: "Last compiled on 06 June, 2024"
output: 
  html_document:
    toc: yes
    toc_float: yes
    number_section: yes
    keep_md: TRUE
---




``` r
1 + 1
```

```
## [1] 2
```

D:\playground\rmarkdown\knitr_purl_hook\knitr_purl_hook.R


``` r
getwd()
```

```
## [1] "D:/playground/rmarkdown/knitr_purl_hook"
```

D:\playground\rmarkdown\knitr_purl_hook\knitr_purl_hook.R


``` r
sessioninfo::session_info()
```

```
## ─ Session info ───────────────────────────────────────────────────────────────
##  setting  value
##  version  R version 4.4.0 (2024-04-24 ucrt)
##  os       Windows 10 x64 (build 19044)
##  system   x86_64, mingw32
##  ui       RTerm
##  language (EN)
##  collate  English_United States.utf8
##  ctype    English_United States.utf8
##  tz       Asia/Shanghai
##  date     2024-06-06
##  pandoc   3.2 @ C:/Users/yj220158/scoop/shims/ (via rmarkdown)
## 
## ─ Packages ───────────────────────────────────────────────────────────────────
##  package     * version date (UTC) lib source
##  bslib         0.7.0   2024-03-29 [1] CRAN (R 4.4.0)
##  cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.0)
##  cli           3.6.2   2023-12-11 [1] CRAN (R 4.4.0)
##  digest        0.6.35  2024-03-11 [1] CRAN (R 4.4.0)
##  evaluate      0.23    2023-11-01 [1] CRAN (R 4.4.0)
##  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
##  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
##  jquerylib     0.1.4   2021-04-26 [1] CRAN (R 4.4.0)
##  jsonlite      1.8.8   2023-12-04 [1] CRAN (R 4.4.0)
##  knitr         1.47    2024-05-29 [1] CRAN (R 4.4.0)
##  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
##  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.0)
##  rlang         1.1.3   2024-01-10 [1] CRAN (R 4.4.0)
##  rmarkdown     2.27    2024-05-17 [1] CRAN (R 4.4.0)
##  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.0)
##  sass          0.4.9   2024-03-15 [1] CRAN (R 4.4.0)
##  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
##  xfun          0.44    2024-05-15 [1] CRAN (R 4.4.0)
##  yaml          2.3.8   2023-12-11 [1] CRAN (R 4.4.0)
## 
##  [1] C:/R/MyLibrary
##  [2] C:/R/R-4.4.0/library
## 
## ──────────────────────────────────────────────────────────────────────────────
```

D:\playground\rmarkdown\knitr_purl_hook\knitr_purl_hook.R

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui yihui added the bug Bugs label Jun 6, 2024
@yihui yihui closed this as completed in 1db544b Jun 6, 2024
@yihui
Copy link
Owner

yihui commented Jun 6, 2024

It's a bug caused by yihui/xfun@27484dd. Fixed now. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants