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

```{python} applied to R cells in Rmd #227

Closed
tomcatlingcma opened this issue May 14, 2019 · 5 comments
Closed

```{python} applied to R cells in Rmd #227

tomcatlingcma opened this issue May 14, 2019 · 5 comments

Comments

@tomcatlingcma
Copy link

Issue

Jupytext applies ```{python} in .Rmd to cells in a notebook created with an R kernel.

Steps to reproduce

Using jupytext 1.1.1 and c.ContentsManager.default_jupytext_formats = "ipynb,Rmd" in notebook config.

  • Create a new notebook with an R kernel.
  • Save it from the .ipynb file.
  • Open the .Rmd file in the editor - it looks like below.
---
jupyter:
  jupytext:
    text_representation:
      extension: .Rmd
      format_name: rmarkdown
      format_version: '1.1'
      jupytext_version: 1.1.1
  kernelspec:
    display_name: R
    language: R
    name: ir
---

```{python}
a<-1
```  

```{python}

```
  • Close above and re-open the .ipynb file, it renders as below and does not run because a<-1 is not valid python.

Capture

  • Manually changing ```{python} to ```{r} in the .Rmd seems to result in a stable state where things work as expected, even for new cells created later in the notebook.
---
jupyter:
  jupytext:
    text_representation:
      extension: .Rmd
      format_name: rmarkdown
      format_version: '1.1'
      jupytext_version: 1.1.1
  kernelspec:
    display_name: R
    language: R
    name: ir
---

```{r}
a<-1
```

```{r}

```

Capture

@mwouts
Copy link
Owner

mwouts commented May 14, 2019

Hello @tomcatlingcma , thanks for the report ! Let me see if I can reproduce (and fix) this...

@mwouts
Copy link
Owner

mwouts commented May 14, 2019

I confirm the issue, and I should be able to fix it soon.

Meanwhile, when you create a new notebook, please delete the main_language metadata that has been inserted in the notebook metadata (I think that the language is wrong because it was computed on a fully empty notebook, with no kernel information and no cell...)

{
  "jupytext": {
    "main_language": "python"
  },
  "kernelspec": {
    "name": "ir",
    "display_name": "R",
    "language": "R"
  },
  "language_info": {
    "name": "R",
    "codemirror_mode": "r",
    "pygments_lexer": "r",
    "mimetype": "text/x-r-source",
    "file_extension": ".r",
    "version": "3.4.3"
  }
}

@tomcatlingcma
Copy link
Author

Thanks for your very fast response!

Happy to do as you propose above in the meantime. This is a great project which solves a common issue with .ipynb in an elegant way.

mwouts added a commit that referenced this issue May 15, 2019
@mwouts mwouts mentioned this issue May 15, 2019
@mwouts mwouts closed this as completed in 03baf76 May 15, 2019
@mwouts
Copy link
Owner

mwouts commented May 15, 2019

Hello @tomcatlingcma , can you give a try to version 1.1.2? The problem should be fixed now, at least for new notebooks. Thanks!

@tomcatlingcma
Copy link
Author

Confirmed fixed - thanks!!

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