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

Enable 'task list' markdown extension #81766

Merged
merged 1 commit into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/doc/rustdoc/src/how-to-write-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,25 @@ This example will render similarly to this:
See the specification for the [GitHub Tables extension][tables] for more
details on the exact syntax supported.

### Task lists

Task lists can be used as a checklist of items that have been completed.
Example:

```md
- [x] Complete task
- [ ] IncComplete task
```

This will render as

<ul>
<li><input type="checkbox"></li>
<li><input type="checkbox" checked></li>
</ul>

See the specification for the [task list extension] for more details.

[`backtrace`]: https://docs.rs/backtrace/0.3.50/backtrace/
[commonmark markdown specification]: https://commonmark.org/
[commonmark quick reference]: https://commonmark.org/help/
Expand All @@ -234,3 +253,4 @@ details on the exact syntax supported.
[`std::env`]: https://doc.rust-lang.org/stable/std/env/index.html#functions
[strikethrough]: https://github.github.com/gfm/#strikethrough-extension-
[tables]: https://github.github.com/gfm/#tables-extension-
[task list extension]: https://github.github.com/gfm/#task-list-items-extension-
5 changes: 4 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ mod tests;

/// Options for rendering Markdown in the main body of documentation.
pub(crate) fn opts() -> Options {
Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH
Options::ENABLE_TABLES
| Options::ENABLE_FOOTNOTES
| Options::ENABLE_STRIKETHROUGH
| Options::ENABLE_TASKLISTS
}

/// A subset of [`opts()`] used for rendering summaries.
Expand Down
13 changes: 13 additions & 0 deletions src/test/rustdoc/task-lists.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ignore-tidy-linelength
// FIXME: this doesn't test as much as I'd like; ideally it would have these query too:
// has task_lists/index.html '//li/input[@type="checkbox" and disabled]/following-sibling::text()' 'a'
// has task_lists/index.html '//li/input[@type="checkbox"]/following-sibling::text()' 'b'
// Unfortunately that requires LXML, because the built-in xml module doesn't support all of xpath.

// @has task_lists/index.html '//ul/li/input[@type="checkbox"]' ''
// @has task_lists/index.html '//ul/li/input[@disabled]' ''
// @has task_lists/index.html '//ul/li' 'a'
// @has task_lists/index.html '//ul/li' 'b'
//! This tests 'task list' support, a common markdown extension.
//! - [ ] a
//! - [x] b