Abstract

Jupyter Notebook is widely used for interactive computing in various fields of science and technology. As a rule, Jupyter Notebook documents are created directly in the browser, but it is possible to generate them by software, for example, from Python code that contains Python string literals with Markdown code. Generation from Python code allows you to save documents in an easy-to-edit text format. In addition, in some cases, this Python code can be executed by a standard Python interpreter without having a Jupyter Notebook installed. This provides format flexibility. Currently, there are several tools for converting Python code to a Jupyter Notebook (.ipynb) document. Their disadvantage is either support for old formats or an inconvenient way to mark up cells in a Jupyter Notebook document. The principles of function are described and the Python program is developed for generating interactive Jupyter Notebook documents (.ipynb v4) from the simple marked Python code. The program has the ability to further convert .ipynb to HTML and docx formats. The program can be used to facilitate the creation and editing of documents based on Jupyter Notebook. In comparison with analogues, the program has a simple and clear algorithm based on regular expressions, which allows its simple modification for other tasks. An additional advantage is the simple way of marking Python code on cells, which consists in placing Markdown text blocks in multiline Python literals in quotes and separating code blocks by using ## symbols. An example of creating Python code is provided, which contains a Markdown block with such features as formatting with various fonts, hyperlinks, pictures, program code blocks, LaTeX formulas and tables; a block of code for building interactive graphics using Python libraries Matplotlib and ipywidgets; a block of code that outputs unformatted text and interpretation results of HTML, Markdown, SVG code by the display function from the IPython.display module. An example of converting this code to Jupyter Notebook (including interactive), Markdown, HTML and docx formats is shown.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call