So as far as I know Jupyter Notebook uses the CodeMirror editor to render code cells. In the CodeMirror documentation I found the method `doc.getValue` which is supposed to give the editor's content. According to this topic, 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 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 jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/996ce1d8-607f-4fa0-b389-2fdf4f19c5bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sorry, a bug :-P, corrected versionvar cells = Jupyter.notebook.get_cells()if (cells[i].metadata['extract'] && cells[i].cell_type === "code"){
for (var i=0;i<cells.length;i++){
console.log(cells[i].get_text())
}
}
2017-03-14 12:20 GMT+01:00 Kiko <kikoco...@gmail.com>:
2017-03-14 11:20 GMT+01:00 Zelphir Kaltstahl <zelphirk...@gmail.com>:So as far as I know Jupyter Notebook uses the CodeMirror editor to render code cells. In the CodeMirror documentation I found the method `doc.getValue` which is supposed to give the editor's content. According to this topic, 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 jupyter+u...@googlegroups.com.
Sorry, a bug :-P, corrected versionvar cells = Jupyter.notebook.get_cells()if (cells[i].metadata['extract'] && cells[i].cell_type === "code"){
for (var i=0;i<cells.length;i++){
console.log(cells[i].get_text())
}
}
2017-03-14 12:20 GMT+01:00 Kiko <kikoco...@gmail.com>:
2017-03-14 11:20 GMT+01:00 Zelphir Kaltstahl <zelphirk...@gmail.com>:So as far as I know Jupyter Notebook uses the CodeMirror editor to render code cells. In the CodeMirror documentation I found the method `doc.getValue` which is supposed to give the editor's content. According to this topic, 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 jupyter+u...@googlegroups.com.