2017-03-14 11:20 GMT+01:00 Zelphir Kaltstahl <[email protected]>:
> So as far as I know Jupyter Notebook uses the CodeMirror editor to render > code cells. In the CodeMirror documentation > <https://codemirror.net/doc/manual.html#api> I found the method > `doc.getValue` which is supposed to give the editor's content. According to > this > topic > <https://groups.google.com/forum/#%21searchin/jupyter/JS$20APi%7Csort:relevance/jupyter/1syLAOfC0jA/BgpRGN-FCgAJ>, > there is no documentation for the JS API of Jupyter Notebook. > > My question is: How do I get the (code) content of a/all code cell(s)? > Better even would be a way to get only the code cell's contents of code > cells, which are assigned a specific CSS class or other identifying feature. > You could provide metadata to the cells you want to extract, e.g.: { "extract": true } and then, from javascript, you could do: var cells = Jupyter.notebook.get_cells() for (var i=0;i<cells.length;i++){ if (cells[i].metadata['extract'] && cell.cell_type === "code"){ console.log(cells[i].get_text()) } } > -- > You received this message because you are subscribed to the Google Groups > "Project Jupyter" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/jupyter/996ce1d8-607f-4fa0-b389-2fdf4f19c5bb%40googlegroups.com > <https://groups.google.com/d/msgid/jupyter/996ce1d8-607f-4fa0-b389-2fdf4f19c5bb%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CAB-sx60wWm8ZC6rZ1dK6y3gj0Z8z%3D_Lm3-yRhZiLLp0PB_WgUw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
