19

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

asked Aug 1, 2011 at 21:15

7 Answers 7

19

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

answered Oct 31, 2019 at 8:37
Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to enable the checked box to be memorized (by minimal customization of my sphinx doc?)
14

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.

answered Aug 15, 2011 at 0:55

Comments

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,7794 gold badges35 silver badges44 bronze badges
answered Apr 22, 2017 at 11:07

1 Comment

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?
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"
answered Aug 31, 2011 at 13:55

Comments

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.

answered Aug 1, 2011 at 21:28

2 Comments

Thanks for your answer. I do not really need a form, but rather an empty box symbol instead of the standard bullet point.
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.
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

answered Jan 5, 2013 at 3:33

Comments

1

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;}
Kevin Horn
4,32530 silver badges30 bronze badges
answered Nov 26, 2023 at 23:20

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.