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

Trailing text (prose) not rendered for expression input #89

Closed
Henrik-P opened this issue Jun 1, 2017 · 5 comments
Closed

Trailing text (prose) not rendered for expression input #89

Henrik-P opened this issue Jun 1, 2017 · 5 comments

Comments

@Henrik-P
Copy link

@Henrik-P Henrik-P commented Jun 1, 2017

If a reprex ends with text, the text following the code is not rendered. I.e. this reprex code:

reprex({
#' If a `reprex` ends with text, the text following the code is not rendered
x <- 1:2 
#' Trailing text
})

...generates this:

If a reprex ends with text, the text following the code is not rendered

x <- 1:2

reprex({
  #' Add some code after the trailing text to render it
  x <- 1:2
  #' Non-trailing text is rendered
  x
  })

Add some code after the trailing text to render it

x <- 1:2

Non-trailing text is rendered

x
#> [1] 1 2
@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jul 13, 2017

This looks like an issue with knitr::spin(), can you please double-check?

@jennybc
Copy link
Member

@jennybc jennybc commented Sep 23, 2017

AFAICT this problem is specific to expression input and is because R's source references do not contain the trailing comment. As long as reprex uses substitute() and the "srcref" attribute, this is going to be a problem. The examples show this and that it could be fixed if I could somehow append #+ echo = FALSE; invisible() to expression input. How could you even do that?


Non-expression input:

reprex(input = c("1:2", "#' Trailing text"))

Result:

1:2
#> [1] 1 2

Trailing text


Expression input:

reprex(input = c("1:2", "#' Trailing text"))

Result:

1:2
#> [1] 1 2

Expression input with a protective end-cap:

reprex({
  1:2 
  #' Trailing text
  #+ echo = FALSE
  invisible()
})

Result:

1:2
#> [1] 1 2

Trailing text

@jennybc jennybc changed the title Trailing text (prose) not rendered Trailing text (prose) not rendered for expression input Sep 23, 2017
@jennybc
Copy link
Member

@jennybc jennybc commented Sep 23, 2017

Pretty sure it's not practical to address this. Trailing text is a reason to use the input argument or clipboard.

@jennybc
Copy link
Member

@jennybc jennybc commented Sep 26, 2017

OK I am going to fix this.

@jennybc jennybc reopened this Sep 26, 2017
@jennybc
Copy link
Member

@jennybc jennybc commented Sep 26, 2017

After the fix, with this input:

reprex({
#' If a `reprex` ends with text, the text following the code is NOW rendered
x <- 1:2 
#' Trailing text woot!
})

Output:

If a reprex ends with text, the text following the code is NOW rendered

x <- 1:2

Trailing text woot!

@jennybc jennybc closed this in d455304 Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants