开发者

How to create a checklist in reStructuredText (reST)?

I am working on a simple checkl开发者_StackOverflow中文版ist 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


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:

How to create a checklist in reStructuredText (reST)?


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.


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 works for me (with rst2pdf, default Helvetica font)

Relevant parts of the stylesheet:

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜