Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for task lists #47

Closed
2bndy5 opened this issue Mar 19, 2022 · 3 comments · Fixed by #60
Closed

Support for task lists #47

2bndy5 opened this issue Mar 19, 2022 · 3 comments · Fixed by #60

Comments

@2bndy5
Copy link
Collaborator

2bndy5 commented Mar 19, 2022

Currently sphinx/rst do not provide a way that generates HTML that takes advantage of mkdocs-material's task lists (configured using a md extension again).

Example HTML output from mkdocs-material docs
<ul class="task-list">
  <li class="task-list-item">
    <label class="task-list-control">
      <input type="checkbox" disabled="" checked="">
      <span class="task-list-indicator"></span>
    </label>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit
  </li>
  <li class="task-list-item">
    <label class="task-list-control">
      <input type="checkbox" disabled="">
      <span class="task-list-indicator"></span>
    </label>
    Vestibulum convallis sit amet nisi a tincidunt
    <ul class="task-list">
      <li class="task-list-item">
        <label class="task-list-control">
          <input type="checkbox" disabled="" checked="">
          <span class="task-list-indicator"></span>
        </label>
        In hac habitasse platea dictumst
      </li>
      <li class="task-list-item">
        <label class="task-list-control">
          <input type="checkbox" disabled="" checked="">
          <span class="task-list-indicator"></span>
        </label>
        In scelerisque nibh non dolor mollis congue sed et metus
      </li>
      <li class="task-list-item">
        <label class="task-list-control">
          <input type="checkbox" disabled="">
          <span class="task-list-indicator"></span>
        </label>
        Praesent sed risus massa
      </li>
    </ul>
  </li>
  <li class="task-list-item">
    <label class="task-list-control">
      <input type="checkbox" disabled="">
      <span class="task-list-indicator"></span>
    </label>
    Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque
    </li>
</ul>

I'm not sure how popular the feature is, but I figured I'd discuss the implementation here before submitting a proposal.

About ideal syntax

I would prefer to be able to use the GitHub-flavored MD style of task lists (as used in upstream). This way users migrating from mkdocs to sphinx would be faced with less friction.

.. md-task-list::
    - [x] Lorem ipsum dolor sit amet, consectetur adipiscing elit
    - [ ] Vestibulum convallis sit amet nisi a tincidunt
        .. md-task-list::
            * [x] In hac habitasse platea dictumst
            * [x] In scelerisque nibh non dolor mollis congue sed et metus
            * [ ] Praesent sed risus massa
    - [ ] Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque

There may be nothing stopping the user from implementing this on their own, but the styling from upstream (& thus this theme) is desirable.

About persistence

As noted in the upstream's docs, checkbox states aren't persistent. Although this could easily be done with a little extra JS from the user's end.

@jbms
Copy link
Owner

jbms commented Mar 20, 2022

It is hard to imagine a use case for letting the user click on the checkboxes to change their state.

I think your syntax choice is reasonable.

I wonder about the md prefix --- I think the use of md in the css classes refers to mkdocs. We could just have it be task-list.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Mar 20, 2022

I always thought the CSS's md stood for "material design".

No objections to using task-list since there doesn't seem to be any [published] sphinx extension (that I could find) that modifies the list's marker for this scenario. Honestly, I think this was primarily meant to support GFM syntax, but it looks pretty enough (and I'm a completionist at heart).

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Mar 20, 2022

I did manage to find this thread: https://groups.google.com/g/sphinx-users/c/EzuDSNDA5DI/m/uoHmhJCdAgAJ?pli=1

@2bndy5 2bndy5 mentioned this issue Apr 12, 2022
@jbms jbms closed this as completed in #60 Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants