如何在 reStructuredText (reST) 中创建清单?

发布于 2024-11-27 18:39:18 字数 375 浏览 5 评论 0原文

我正在使用 reStructuredText 制作一个简单的清单。为此,我使用项目符号列表,但我想要用自定义符号(例如空复选框)替换标准项目符号点。最理想的是,这些复选框在 HTML 和/或 PDF 文档中是可单击的。

如果在 reST 中这是不可能/微不足道的,您能否推荐其他可能的基于文本的格式?

巴尔托什

I am working on a simple checklist using reStructuredText. To this end I use a bullet list, but I would like to replace the standard bullet points with custom signs, such as empty checkboxes. Optimally, the checkboxes would be clickable in the HTML and/or PDF document.

If it is not possible/trivial in reST, could you recommend other text-based format where it is possible?

Bartosz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

酒与心事 2024-12-04 18:39:18

静态

尝试使用Unicode char。

这比直接输入 [] 漂亮但麻烦。

U+2611

U+2610

动态

.. |check| raw:: html

    <input checked=""  type="checkbox">

.. |check_| raw:: html

    <input checked=""  disabled="" type="checkbox">

.. |uncheck| raw:: html

    <input type="checkbox">

.. |uncheck_| raw:: html

    <input disabled="" type="checkbox">

checkbox
=============

check to enable: |check|

check disable: |check_| 

uncheck enable: |uncheck|

uncheck disable: |uncheck_|

您可以在此网站上运行以上代码:https://livesphinx.herokuapp.com/

你会看到如下图:

在此处输入图像描述

Static

try to use Unicode char.

It is beautiful than typing [] direct but hassle.

U+2611

U+2610

Dynamic

.. |check| raw:: html

    <input checked=""  type="checkbox">

.. |check_| raw:: html

    <input checked=""  disabled="" type="checkbox">

.. |uncheck| raw:: html

    <input type="checkbox">

.. |uncheck_| raw:: html

    <input disabled="" type="checkbox">

checkbox
=============

check to enable: |check|

check disable: |check_| 

uncheck enable: |uncheck|

uncheck disable: |uncheck_|

you can run above code on this website: https://livesphinx.herokuapp.com/

and you will see as below picture:

enter image description here

千鲤 2024-12-04 18:39:18

我昨天遇到了这个,只是假装而已。如果您只是寻找在用户打印文档时具有与复选框相同的视觉效果的东西(例如,用户无法以 HTML 表单形式提交我的文档),那么这真的很容易做到:

- [ ] Checkbox item 1.

  - [ ] sub-item.

  - [ ] another sub-item.

    - [ ] a sub-sub-item.

- [X] an already filled in checkbox.

查看时,它看起来像:

  • [ ] 复选框项目 1。

    • [ ] 子项目。

    • []另一个子项目。

    • [ ] 子子项。

  • [X] 已填写的复选框。

I ran into this yesterday and just faked it. If you're just looking for something that has the same visual effect as a checkbox when the user prints the document (the user can't submit my document as an HTML form, for example), it's really easy to do:

- [ ] Checkbox item 1.

  - [ ] sub-item.

  - [ ] another sub-item.

    - [ ] a sub-sub-item.

- [X] an already filled in checkbox.

When viewed, it looks like:

  • [ ] Checkbox item 1.

    • [ ] sub-item.

    • [ ] another sub-item.

    • [ ] a sub-sub-item.

  • [X] an already filled in checkbox.

南风起 2024-12-04 18:39:18

6 年后,ReST 仍然不支持复选框。但是 GitHub Flavored Markdown 确实支持使用以下语法的任务列表项由尼克建议。这可以通过 tasklist 扩展在 GitHub 上运行,但默认情况下在 Markdown 中不存在。

该语法可能在其他 Markdown 实现或其他在线平台上可用,也可能不可用。例如,截至 2019 年,StackOverflow 的 Markdown 语法中不存在它。

6 years later ReST still does not support checkboxes. But GitHub Flavored Markdown does support task list items with the syntax suggested by Nick. This works on GitHub via the tasklist extension but isn't present by default in Markdown.

The syntax may or may not be available in other Markdown implementations or on other online platforms. For example, as of 2019, it isn't present in StackOverflow's Markdown syntax.

心碎的声音 2024-12-04 18:39:18

Unicode 2751 适用于我(使用 rst2pdf,默认 Helvetica 字体)

样式表的相关部分:

base:
bulletFontName: stdFont
bulletFontSize: 10
bulletIndent: 0
bulletText: "\u2751"

Unicode 2751 works for me (with rst2pdf, default Helvetica font)

Relevant parts of the stylesheet:

base:
bulletFontName: stdFont
bulletFontSize: 10
bulletIndent: 0
bulletText: "\u2751"
<逆流佳人身旁 2024-12-04 18:39:18

rst 旨在构建文本内容而不是表单,因此它不适合。您可能需要执行一些自定义操作来解决此问题,因为不太可能有一种合适的产品或标记来涵盖这两者。 PDF 表单有多种实现方式,而旧的 HTML 表单也适用于 Web。然而,PDF 表单可能很昂贵且存在问题,特别是如果您必须使用 Adob​​e Lifecycle Designer 或类似的东西。

rst is designed to build textual content rather than forms so it is not suitable. You will probably have to do something custom to get around this as there is unlikely to be one suitable product or markup to cover both. There are several implementations of PDF forms around and good old HTML forms will do for the web. PDF forms are however potentially expensive and problematic, especially if you have to go with Adobe Lifecycle Designer or something like that.

呆头 2024-12-04 18:39:18

没有经过我自己的测试,但我相信这将是一个可行的方法。

首先使用 css 禁用默认的项目符号点字符:

list-style-type: none;

,然后使用图像作为项目符号点。

最后但并非最不重要的一点是,您可以使用此技巧将 css 包含在 restrusturedtext 文件中。 https://stackoverflow.com/a/5815382/728675

Not tested by myself, but I believe this would be a way to go.

First use css to disable the default bullet point char:

list-style-type: none;

and then you use an image to serve as your bullet point.

Last but not the least, you can use this trick to include css inside your restrusturedtext file. https://stackoverflow.com/a/5815382/728675

烟酉 2024-12-04 18:39:18

Docutils 文档有一个讨论/展示各种替代方案的示例文档。 https://docutils.sourceforge.io/docs/user/todo-lists。 html
与源 https://docutils.sourceforge.io/docs/user/todo -lists.txt

我推荐一个带有类参数和一些 CSS 样式的字段列表,例如

.. class:: todo

:|x|: Compile this example with ``rst2html5``,
:|y|: compare markup variants,
:|-|: select the best.
dl.todo > dt > .colon {display: none}
dl.todo > dd {margin-left: 2.5em;}

The Docutils documentation has an example document discussing/presenting various alternatives. https://docutils.sourceforge.io/docs/user/todo-lists.html
with the source https://docutils.sourceforge.io/docs/user/todo-lists.txt

I recommend a field list with class argument and some CSS styling, e.g

.. class:: todo

:|x|: Compile this example with ``rst2html5``,
:|y|: compare markup variants,
:|-|: select the best.
dl.todo > dt > .colon {display: none}
dl.todo > dd {margin-left: 2.5em;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文