{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `ui.restructured_text`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ReStructuredText\n", "\n", "将 ReStructuredText 渲染到页面上。\n", "\n", "`content`:要显示的 ReStructuredText 内容" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "ui.restructured_text('This is **reStructuredText**.')\n", "\n", "# ui.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 带有缩进的 reStructuredText\n", "\n", "您可以对 reStructuredText 元素进行缩进来创建层次结构。为了保持相对缩进,每行开头的常见缩进会自动被去除,因此您可以缩进多行字符串。" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "ui.restructured_text('''\n", " This is an example of a reStructuredText paragraph with several indentation levels.\n", "\n", " You can use multiple levels of indentation to structure your content.\n", " Each level of indentation represents a different level of hierarchy.\n", "\n", " - Level 1\n", " - Level 2\n", " - Level 3\n", " - Level 4\n", " - Level 5\n", "''')\n", "\n", "# ui.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 带有代码块的 reStructuredText\n", "\n", "您可以使用代码块来显示代码示例。如果指定了语言,代码将会被语法高亮显示。请参阅此链接以获取支持的语言列表。" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "ui.restructured_text('''\n", " .. code-block:: python3\n", " \n", " from nicegui import ui\n", "\n", " ui.label('Hello World!')\n", "\n", " ui.run()\n", "''')\n", "\n", "# ui.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 带有表格的 reStructuredText\n", "\n", "有关 reStructuredText 表格的更多信息,请参阅 [Sphinx 文档](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#tables)。" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "ui.restructured_text('''\n", " +-------+-------+---------+--------+\n", " | A | B | A and B | A or B |\n", " +=======+=======+=========+========+\n", " | False | False | False | False |\n", " +-------+-------+---------+--------+\n", " | True | False | False | True |\n", " +-------+-------+---------+--------+\n", " | False | True | False | True |\n", " +-------+-------+---------+--------+\n", " | True | True | True | True |\n", " +-------+-------+---------+--------+\n", "''')\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }