17

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

btel
  • 5,563
  • 6
  • 37
  • 47

6 Answers6

14

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

Carson
  • 6,105
  • 2
  • 37
  • 45
  • Is it possible to enable the checked box to be memorized (by minimal customization of my sphinx doc?) – panc Jun 10 '21 at 19:04
13

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.

Nick
  • 139
  • 2
4

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.

davidjb
  • 8,247
  • 3
  • 32
  • 42
frans
  • 8,868
  • 11
  • 58
  • 132
  • GitHub can do what they like with their markdown, it's not part of the normal use-case. Everyone wants their feature so there's a million feature requests so developers implement according to their intended use-case and priorities. Why don't you implement it? Which implementation will you do it in first? – NeilG Jun 15 '23 at 08:24
3

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

Relevant parts of the stylesheet:

base:
bulletFontName: stdFont
bulletFontSize: 10
bulletIndent: 0
bulletText: "\u2751"
avuko
  • 31
  • 2
2

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

Community
  • 1
  • 1
RayLuo
  • 17,257
  • 6
  • 88
  • 73
2

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.

Deleted
  • 4,804
  • 1
  • 22
  • 17
  • Thanks for your answer. I do not really need a form, but rather an empty box symbol instead of the standard bullet point. – btel Aug 01 '11 at 22:22
  • You can probably do that with CSS list-style-type -or- list-style-image and plug that into your document output however you are rendering it. – Deleted Aug 01 '11 at 22:25