简体   繁体   English

默认情况下如何在ipython notebook markdown中制作新单元格?

[英]How to make new cells in ipython notebook markdown by default?

Currently, whenever you create a new cell in an iPython notebook, it defaults to a opening up a cell for Python code. 目前,无论何时在iPython笔记本中创建新单元,它都默认为打开Python代码的单元格。 I can then change it to markdown by hitting the keyboard shortcut ctrl m m 然后,我可以通过按键盘快捷键ctrl m m将其更改为markdown

Is there any method or any setting I can tweak so that new cells default to being in "markdown mode"? 我可以调整任何方法或任何设置,以便新单元格默认处于“降价模式”吗?

I did find this question which appears to ask the same thing, but it was erroneously flagged as a duplicate and wasn't answered. 我确实发现这个问题似乎问了同样的问题,但它被错误地标记为重复并且没有得到回答。

I was just reading the IPython notebook js code, and found the insert_cell_below method at https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/notebook.js#L849 . 我刚刚阅读了IPython笔记本js代码,并在https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/notebook.js#L849找到了insert_cell_below方法。

If you want to do this programatically, it would simply be a case of doing something like: 如果你想以编程方式执行此操作,那么只需执行以下操作即可:

from IPython.display import display, Javascript

def markdown_below():
    display(Javascript("""
    IPython.notebook.insert_cell_below('markdown')
    """));

markdown_below()

This would be fairly early to turn into a button on the toolbar in a similar way to the gist button in https://github.com/minrk/ipython_extensions . 这与在https://github.com/minrk/ipython_extensions中与gist按钮类似的方式转换为工具栏上的按钮相当早。

HTH HTH

Quote from Brian E. Granger in 2012 from this forum: http://python.6.x6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-td4997506.html 引自Brian E. Granger在2012年的论坛: http//python.6.x6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-td4997506.html

The best way of doing this right now is to clone an existing notebook. 现在最好的方法是克隆现有的笔记本。 We don't have a great way of doing that, but starting in Jan, we will be working on the dashboard and we will add things like that. 我们没有很好的方法,但从1月开始,我们将在仪表板上工作,我们将添加类似的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM