Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a checklist in reStructuredText (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

like image 338
btel Avatar asked Aug 01 '11 21:08

btel


People also ask

What is RST in coding?

reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation.

How do I comment in RST file?

For comments, add 2 periods .. followed by a newline and then your comment indented.

What is RST Sphinx?

RST stands for ReStructured Text. It is the standard markup language used for documenting python packages. Sphinx is the Python package that generates an html website from RST files, and it is what we are using to generate this site.


2 Answers

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.

like image 88
Nick Avatar answered Oct 19 '22 04:10

Nick


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

like image 42
Carson Avatar answered Oct 19 '22 03:10

Carson