如何在 reStructuredText (reST) 中创建清单?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
静态
尝试使用Unicode char。
这比直接输入
[]
漂亮但麻烦。☑ U+2611
☐ U+2610
动态
您可以在此网站上运行以上代码:https://livesphinx.herokuapp.com/
你会看到如下图:
Static
try to use Unicode char.
It is beautiful than typing
[]
direct but hassle.☑ U+2611
☐ U+2610
Dynamic
you can run above code on this website: https://livesphinx.herokuapp.com/
and you will see as below picture:
我昨天遇到了这个,只是假装而已。如果您只是寻找在用户打印文档时具有与复选框相同的视觉效果的东西(例如,用户无法以 HTML 表单形式提交我的文档),那么这真的很容易做到:
查看时,它看起来像:
[ ] 复选框项目 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:
When viewed, it looks like:
[ ] Checkbox item 1.
[ ] sub-item.
[ ] another sub-item.
[ ] a sub-sub-item.
[X] an already filled in checkbox.
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.
Unicode 2751 适用于我(使用 rst2pdf,默认 Helvetica 字体)
样式表的相关部分:
Unicode 2751 works for me (with rst2pdf, default Helvetica font)
Relevant parts of the stylesheet:
rst 旨在构建文本内容而不是表单,因此它不适合。您可能需要执行一些自定义操作来解决此问题,因为不太可能有一种合适的产品或标记来涵盖这两者。 PDF 表单有多种实现方式,而旧的 HTML 表单也适用于 Web。然而,PDF 表单可能很昂贵且存在问题,特别是如果您必须使用 Adobe 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.
没有经过我自己的测试,但我相信这将是一个可行的方法。
首先使用 css 禁用默认的项目符号点字符:
,然后使用图像作为项目符号点。
最后但并非最不重要的一点是,您可以使用此技巧将 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:
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
Docutils 文档有一个讨论/展示各种替代方案的示例文档。 https://docutils.sourceforge.io/docs/user/todo-lists。 html
与源 https://docutils.sourceforge.io/docs/user/todo -lists.txt
我推荐一个带有类参数和一些 CSS 样式的字段列表,例如
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