Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Apr 26, 2023
1 parent fa51e92 commit 4994e27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
43 changes: 15 additions & 28 deletions ConvertOneNote2MarkDown-v2.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ Describe 'New-SectionGroupConversionConfig' -Tag 'Unit' {

$fakeMarkdownContent = @"
hello world$( [char]0x00A0 )
- foo
- foo1
Expand All @@ -1198,6 +1199,10 @@ hello world$( [char]0x00A0 )
- bar1
- baz
- baz1
>
>
> some other text
Expand All @@ -1214,6 +1219,8 @@ hello world$( [char]0x00A0 )
1. baz1
some new paragraph
some more
"@ -replace "`r", '' # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.

Expand All @@ -1231,10 +1238,14 @@ hello world$( [char]0x00A0 )
$expectedBody = $split[8..($split.Count - 1)] -join "`n"
$expectedBody | Should -Be $( @"
hello world
- foo
- foo1
- bar
- bar1
- baz
- baz1
some other text
Expand All @@ -1246,6 +1257,9 @@ some other text
3. baz
1. baz1
some new paragraph
some more
"@ -replace "`r", '') # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.
}

Expand All @@ -1268,34 +1282,7 @@ some other text
# Should keep extra newline between ordered and unordered list items, keep non-breaking spaces, and `>` from ordered lists. Ignore first 8 lines for page header
$split = $mutated -split "`n"
$expectedBody = $split[8..($split.Count - 1)] -join "`n"
$expectedBody | Should -Be $( @"
hello world$( [char]0x00A0 )
- foo
- foo1
- bar
- bar1
>
>
> some other text
1. foo
1. foo1
2. bar
1. bar1
3. baz
1. baz1
"@ -replace "`r", '') # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.
$expectedBody | Should -Be $fakeMarkdownContent # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.
}

}
Expand Down
5 changes: 3 additions & 2 deletions ConvertOneNote2MarkDown-v2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -930,18 +930,19 @@ Function New-SectionGroupConversionConfig {
@{
description = 'Clear extra newlines between unordered (bullet) and ordered (numbered) list items, non-breaking spaces from blank lines, and `>` after unordered lists'
replacements = @(
# Remove non-breaking spaces
@{
searchRegex = [regex]::Escape([char]0x00A0)
replacement = ''
}
# Remove an extra newline between each occurrence of '- some unordered list item'
@{
searchRegex = '(\s*)- ([^\r\n]*)\r*\n\r*\n'
searchRegex = '(\s*)- ([^\r\n]*)\r*\n\r*\n(?=\s*-)'
replacement = "`$1- `$2`n"
}
# Remove an extra newline between each occurrence of '1. some ordered list item'
@{
searchRegex = '(\s*)(\d+\.) ([^\r\n]*)\r*\n\r*\n'
searchRegex = '(\s*)(\d+\.) ([^\r\n]*)\r*\n\r*\n(?=\s*\d+\.)'
replacement = "`$1`$2 `$3`n"
}
# Remove all '>' occurrences immediately following unordered lists
Expand Down

0 comments on commit 4994e27

Please sign in to comment.