aaren / notedown

Markdown <=> IPython Notebook
BSD 2-Clause "Simplified" License
855 stars 115 forks source link

How to select code chunks and Jupyter kernel #68

Closed kiwi0fruit closed 6 years ago

kiwi0fruit commented 6 years ago

Suppose I have a multikernel markdown document (written with Stitch). Then I convert it from markdown to makdown and now have two kinds of code chunks: code chunks of the particular language that should be converted to jupyter code cells. And code chunks of other languages or dummy code chunks that should be inside jupyter markdown code cells.

How can I specify target language (it can be any jupyter kernel) and marks chunks that should be converted to jupyter code cells?

Note that stitch md -> md conversion makes all code chunks to be fenced.

kiwi0fruit commented 6 years ago

By the way, how do you populate these metadata sections:

 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "R",
   "language": "R",
   "name": "ir"
  },
  "language_info": {
   "codemirror_mode": "r",
   "file_extension": ".r",
   "mimetype": "text/x-r-source",
   "name": "R",
   "pygments_lexer": "r",
   "version": "3.3.2"
  }
 },
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },

There can be non-trivial combinations.

kiwi0fruit commented 6 years ago

Am I right that to convert specific cells only I should use --match=mymarker and write write something like that:

```{.py .mymarker}
# this would be Jupyter code cell
print('Hello')

Text.

# this would be inside markdown cell
print('Hello')

Text.

kiwi0fruit commented 6 years ago

I've found that kernel specification is yet to added to notedown. Can you poit to where in the code the part that specifies kernel metadata. Or there are no such section at all and Jupyter simply treats it as default so uses default python kernel?