diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul.tsx b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/index.tsx similarity index 78% rename from packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul.tsx rename to packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/index.tsx index 080ecaac2a..d426298f6a 100644 --- a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul.tsx +++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/index.tsx @@ -9,13 +9,15 @@ import React from 'react'; import clsx from 'clsx'; import type {Props} from '@theme/MDXComponents/Ul'; +import styles from './styles.module.css'; + function transformUlClassName(className?: string): string { return clsx( className, // This class is set globally by GitHub/MDX. We keep the global class, and - // add another Infima class to get list without styling + // add another class to get a task list without the default ul styling // See https://github.com/syntax-tree/mdast-util-to-hast/issues/28 - className?.includes('contains-task-list') && 'clean-list', + className?.includes('contains-task-list') && styles.containsTaskList, ); } diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/styles.module.css b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/styles.module.css new file mode 100644 index 0000000000..c1d9c4f95d --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Ul/styles.module.css @@ -0,0 +1,14 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +.containsTaskList { + list-style: none; +} + +:not(.containsTaskList > li) > .containsTaskList { + padding-left: 0; +} diff --git a/website/_dogfooding/_pages tests/markdownPageTests.md b/website/_dogfooding/_pages tests/markdownPageTests.md index ca7e9fcff7..dc8695b111 100644 --- a/website/_dogfooding/_pages tests/markdownPageTests.md +++ b/website/_dogfooding/_pages tests/markdownPageTests.md @@ -189,3 +189,35 @@ This is a fragment: <>Hello It should work :) + +## Task list + +A list: + +- [ ] Simple +- [x] Tasks +- [ ] Has simple +- [ ] Styles + +Another list: + +- Nested + - [ ] Tasks + - [ ] Should be well-formatted +- [ ] No matter +- [ ] How weird + +Can be arbitrarily nested: + +- Level + - [ ] Task + - [ ] Task + - Another level + - [ ] Task + - [ ] Task + - Deeper + - [ ] Task + - [ ] Task + - [ ] Task + - [ ] Task +- [ ] Task