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

IPYNB: no code language information include #636

Open
esraay opened this issue Aug 11, 2020 · 2 comments
Open

IPYNB: no code language information include #636

esraay opened this issue Aug 11, 2020 · 2 comments

Comments

@esraay
Copy link

esraay commented Aug 11, 2020

When converting Rmarkdown files to .ipnb files, code cell language information eliminated. (It should be in code section metadata) The example file is attached:

The .rmd file which is wanted to convert------>


title: example
output: html_notebook

print(1)
print(1)

The .ipynb file which is converted by stencila/encoda------->
{
"nbformat": 4,
"nbformat_minor": 4,
"metadata": {
"title": "example"
},
"cells": [
{
"cell_type": "code",
"metadata": {},
"execution_count": 1,
"source": [
"print(1)"
],
"outputs": []
},
{
"cell_type": "code",
"metadata": {},
"execution_count": 1,
"source": [
"print(1)"
],
"outputs": []
}
]
}

Code language information in metadata expected like:
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}

@nokome
Copy link
Member

nokome commented Aug 12, 2020

Thanks for reporting this @esraay.

A single Stencila document can have CodeChunks containing a variety of languages, but the .ipynb format only allows for a single language at the top level in kernelspec. So to solve this I think we need to iterate over all the CodeChunks and set the kernelspec.name to the most common language (in this case R).

@esraay
Copy link
Author

esraay commented Aug 12, 2020

Thanks for your answer @nokome, basically we have multi language .rmd files. We are looking for a way to extract the language blocks without loosing their language tag. We initially thought we could use encoda for this. We see now that going through .ipynb format is not suitable for this task. What format would you recommend we use? We already tried .json, .xml, .html but couldn't get any success.

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