Skip to content

Commit

Permalink
fix(theme-classic): allow nested task lists to preserve the indent (#…
Browse files Browse the repository at this point in the history
…7438)

* fix(theme-classic): allow nested task lists to preserve the indent

* add Ul back
  • Loading branch information
Josh-Cena authored May 26, 2022
1 parent 309a7e8 commit e955ae4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
32 changes: 32 additions & 0 deletions website/_dogfooding/_pages tests/markdownPageTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e955ae4

Please sign in to comment.