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

[BUG] Hide Code won't work if there is "---" in the document #21

Closed
nikosbosse opened this issue Oct 11, 2021 · 2 comments
Closed

[BUG] Hide Code won't work if there is "---" in the document #21

nikosbosse opened this issue Oct 11, 2021 · 2 comments

Comments

@nikosbosse
Copy link

nikosbosse commented Oct 11, 2021

If there are three dashes somewhere in the document, then the option to hide the code will not work when syncing the file to Google Drive.

Reprex:

Test.Rmd (adapted the code chunks so they can be rendered as code):

---
title: "Test"
output: html_document
---

``{r setup, include=FALSE}
 knitr::opts_chunk$set(echo = TRUE)
``

## R Markdown

---

``{r cars}
summary(cars)
``

Command that fails:

trackdown::upload_file("test.Rmd", hide_code = TRUE)

As far as I can tell the error happens in trackdown:::extract_header(). The following lines produce an error when there are three dashes in the text:

header_index <- which(grepl(info_patterns$file_header_start, text_lines))
    if (length(header_index) != 2) 
        stop("There are some issues in the identification of YAML start/end line indexes", call. = FALSE)

If this is expected, maybe adding a hint to the error messages might be a good idea.

Thanks a lot!

> session_info()$platform
 setting  value                       
 version  R version 4.1.1 (2021-08-10)
 os       Manjaro Linux               
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Berlin               
 date     2021-10-11  
ClaudioZandonella added a commit that referenced this issue Oct 11, 2021
When looking for YAML header test lines "---" to be more or equal than 2
@ClaudioZandonella
Copy link
Owner

Hi @nikosbosse,

Thank you for reporting this issue! You are right. When using hide_code = TRUE, the code checks for exactly two lines of the type--- that are supposed to delimit the YAML header. However, this causes the error if --- is used somewhere else in the text to create a horizontal rule.

Now, the code produces the error only if there are less than 2 ---, this would mean that there are some problems in the definition of the YAML header.

I have updated the package version (v 1.0.2) in the master branch.

Thanks for your help!

@nikosbosse
Copy link
Author

Sweet, thanks a lot!

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

No branches or pull requests

2 participants