Skip to content

Commit

Permalink
fix: replacing two spaces by a single tab (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Nov 24, 2022
1 parent ee8686f commit ade1cf8
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
6 changes: 3 additions & 3 deletions src/utils/turndown-rules/task-list-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { yarleOptions } from '../../yarle';

import { filterByNodeName } from './filter-by-nodename';
import { getAttributeProxy } from './get-attribute-proxy';

const indentCharacter = ' ';
export const taskListRule = {
filter: 'li',
replacement: (content: any, node: any, options: any) => {
Expand All @@ -12,8 +12,8 @@ export const taskListRule = {
const singleLineContent = content
.replace(/^\n+/, '') // Remove leading newlines
.replace(/\n+$/, '\n') // Replace trailing newlines with just a single one
.replace(/\n/gm, '\n '); // Indent
const indentChars = ' '.repeat(indentCount);
.replace(/\n/gm, `\n${indentCharacter}`); // Indent
const indentChars = indentCharacter.repeat(indentCount);

let prefix = indentCount > 0 ? indentChars : '* ';
const parent = node.parentNode;
Expand Down
10 changes: 5 additions & 5 deletions test/data/test-checklist.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# test - checklist

* [ ] Checklist item 1
* [ ] Nested item 1a
* [x] Nested item 1b is checked
* [ ] Nested item 1a
* [x] Nested item 1b is checked
* [x] Checklist item 2 is checked
* Nested unordered 2a
* Nested unordered 2a
* [ ] Checklist item 3
1. Nested ordered 3a
1. Nested ordered 3a

* Unordered list item
* [ ] Nested checklist item
* [ ] Nested checklist item

* [ ] Checklist **bold** `inline code` & [link](https://example.com?a=1&b=2)

Expand Down
64 changes: 32 additions & 32 deletions test/data/test-hugeHtml.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,21 @@ Save for later
### Most popular

* [![[./_resources/Untitled_Note.resources/unknown_filename.6.png]]
#### Manchester Royal Infirmary closes A&E due to suspected Mers cases](http://www.theguardian.com/society/2015/jul/27/manchester-royal-infirmary-closes-ae-suspected-mers-cases)
#### Manchester Royal Infirmary closes A&E due to suspected Mers cases](http://www.theguardian.com/society/2015/jul/27/manchester-royal-infirmary-closes-ae-suspected-mers-cases)

<http://www.theguardian.com/society/2015/jul/27/manchester-royal-infirmary-closes-ae-suspected-mers-cases>* <http://www.theguardian.com/society/2015/jul/27/manchester-royal-infirmary-closes-ae-suspected-mers-cases>[![[./_resources/Untitled_Note.resources/unknown_filename.11.png]]
#### The brilliant thing about Kate Moss is that she can never be shamed](http://www.theguardian.com/fashion/2015/jul/27/kate-moss-refuses-shamed-tabloid-media)
#### The brilliant thing about Kate Moss is that she can never be shamed](http://www.theguardian.com/fashion/2015/jul/27/kate-moss-refuses-shamed-tabloid-media)
<http://www.theguardian.com/fashion/2015/jul/27/kate-moss-refuses-shamed-tabloid-media>* <http://www.theguardian.com/fashion/2015/jul/27/kate-moss-refuses-shamed-tabloid-media>[![[./_resources/Untitled_Note.resources/unknown_filename.3.png]]
#### 'I'm sitting next to a weirdo on the bus' and other true meanings of emoji](http://www.theguardian.com/technology/2015/jul/27/emoji-true-meanings-explained)
#### 'I'm sitting next to a weirdo on the bus' and other true meanings of emoji](http://www.theguardian.com/technology/2015/jul/27/emoji-true-meanings-explained)
<http://www.theguardian.com/technology/2015/jul/27/emoji-true-meanings-explained>* <http://www.theguardian.com/technology/2015/jul/27/emoji-true-meanings-explained>[![[./_resources/Untitled_Note.resources/unknown_filename.15.png]]
#### Rail operators were warned of cows near tracks before Kent collision](http://www.theguardian.com/uk-news/2015/jul/27/rail-operators-were-warned-of-cows-near-tracks-before-kent-collision)
#### Rail operators were warned of cows near tracks before Kent collision](http://www.theguardian.com/uk-news/2015/jul/27/rail-operators-were-warned-of-cows-near-tracks-before-kent-collision)
<http://www.theguardian.com/uk-news/2015/jul/27/rail-operators-were-warned-of-cows-near-tracks-before-kent-collision>* <http://www.theguardian.com/uk-news/2015/jul/27/rail-operators-were-warned-of-cows-near-tracks-before-kent-collision>[![[./_resources/Untitled_Note.resources/unknown_filename.7.png]]
#### Murdered 'Mr Big' said he could be killed 'at any time' in 1998 interview](http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998)
#### Murdered 'Mr Big' said he could be killed 'at any time' in 1998 interview](http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998)
<http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998>
<http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998>
<http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998>
Expand All @@ -266,28 +266,28 @@ Threads collapsed](http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big
<http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998>
[1 [2](http://www.theguardian.com/discussion/p/4azh6?page=2)](http://www.theguardian.com/uk-news/2015/jul/27/salford-mr-big-paul-massey-murder-risk-interview-1998) [3](http://www.theguardian.com/discussion/p/4azh6?page=3) [4](http://www.theguardian.com/discussion/p/4azh6?page=4)[8](http://www.theguardian.com/discussion/p/4azh6?page=8) [next](http://www.theguardian.com/discussion/p/4azh6?page=2)

![[./_resources/Untitled_Note.resources/unknown_filename.5.png]]
[Lillianne](https://profile.theguardian.com/user/id/14670089)
[3h ago](http://discussion.theguardian.com/comment-permalink/56464029)
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
[                            This comment was removed by a moderator because it didn't abide by our](http://discussion.theguardian.com/comment-permalink/56464029) [community standards](http://www.theguardian.com/community-standards).                             Replies may also be deleted. For more detail see [our FAQs](http://www.theguardian.com/community-faqs).
![[./_resources/Untitled_Note.resources/unknown_filename.5.png]]
[nevermindlastnight](https://profile.theguardian.com/user/id/14881964)
[3h ago](http://discussion.theguardian.com/comment-permalink/56464149)
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
[                            This comment was removed by a moderator because it didn't abide by our](http://discussion.theguardian.com/comment-permalink/56464149) [community standards](http://www.theguardian.com/community-standards).                             Replies may also be deleted. For more detail see [our FAQs](http://www.theguardian.com/community-faqs).
![[./_resources/Untitled_Note.resources/unknown_filename.5.png]]
[Lillianne](https://profile.theguardian.com/user/id/14670089)
[3h ago](http://discussion.theguardian.com/comment-permalink/56464029)
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
<http://discussion.theguardian.com/comment-permalink/56464029>
[                            This comment was removed by a moderator because it didn't abide by our](http://discussion.theguardian.com/comment-permalink/56464029) [community standards](http://www.theguardian.com/community-standards).                             Replies may also be deleted. For more detail see [our FAQs](http://www.theguardian.com/community-faqs).
![[./_resources/Untitled_Note.resources/unknown_filename.5.png]]
[nevermindlastnight](https://profile.theguardian.com/user/id/14881964)
[3h ago](http://discussion.theguardian.com/comment-permalink/56464149)
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
<http://discussion.theguardian.com/comment-permalink/56464149>
[                            This comment was removed by a moderator because it didn't abide by our](http://discussion.theguardian.com/comment-permalink/56464149) [community standards](http://www.theguardian.com/community-standards).                             Replies may also be deleted. For more detail see [our FAQs](http://www.theguardian.com/community-faqs).

Close report comment form
Reason (optional)
Expand Down
14 changes: 7 additions & 7 deletions test/data/test-sublists-invalid.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Test note

* List item 1
* List item 1.1
* List item 1.1.1
* List item 1.2
* List item 1.2.1
* List item 1.2.1.1
* List item 1.3
* List item 1.1
* List item 1.1.1
* List item 1.2
* List item 1.2.1
* List item 1.2.1.1
* List item 1.3
* List item 2
* List item 2.1
* List item 2.1
* List item 3

Created at: 2016-03-09T13:47:11+00:00
Expand Down
16 changes: 8 additions & 8 deletions test/data/test-sublists-multiple.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# test - sublists - multiple

* Level1
* Level2
* Level2
* Level2
* Level2
* Level1
* Level2
* Level2
* Level3
* Level2
* Level2
* Level3
* Level1
* Level2
* Level3
* Level2
* Level2
* Level3
* Level2

Created at: 2020-10-17T13:56:13+01:00
Updated at: 2020-10-17T13:59:13+01:00
Expand Down
4 changes: 2 additions & 2 deletions test/data/test-sublists-valid.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# test - sublists - valid

* Level1
* Level2
* Level3
* Level2
* Level3

Created at: 2020-10-10T17:57:15+01:00
Updated at: 2020-10-10T21:42:13+01:00
Expand Down
4 changes: 2 additions & 2 deletions test/data/test-sublists.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# test - sublists

* Level1
* Level2
* Level3
* Level2
* Level3

Created at: 2020-10-10T17:57:15+01:00
Updated at: 2020-10-10T21:42:13+01:00
Expand Down

0 comments on commit ade1cf8

Please sign in to comment.