Skip to content
Open
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
37 changes: 36 additions & 1 deletion ConvertOneNote2MarkDown-v2.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,30 @@ hello world$( [char]0x00A0 )
some new paragraph
some more

$( [char]0x00A0 )

text after an empty paragraph

$( [char]0x00A0 )

$( [char]0x00A0 )

text after two empty paragraphs

- qux

$( [char]0x00A0 )

- quux

> quote
>
> $( [char]0x00A0 )
>
> quote after an empty paragraph

$( [char]0x00A0 )

"@ -replace "`r", '' # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.

foreach ($pageCfg in $result) {
Expand All @@ -1244,7 +1268,7 @@ some more
}
}

# Should remove extra newline between unordered and ordered lists, remove non-breaking spaces, and '>' from ordered lists. Ignore first 8 lines for page header
# Should remove extra newline between unordered and ordered lists, remove empty paragraphs, remove 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 $( @"
Expand All @@ -1271,6 +1295,17 @@ some other text
some new paragraph
some more

text after an empty paragraph

text after two empty paragraphs

- qux
- quux

quote

quote after an empty paragraph

"@ -replace "`r", '') # On some Windows Powershell 5 versions, a here-string will contain `\r`, so let's ensure that doesn't happen.
}

Expand Down
9 changes: 7 additions & 2 deletions ConvertOneNote2MarkDown-v2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Whether to include page timestamp and separator at top of document
}
keepspaces = @{
description = @'
Whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, non-breaking spaces from blank lines, and `>` after unordered lists
Whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, empty paragraphs (blank lines containing only non-breaking spaces), non-breaking spaces, and `>` after unordered lists
1: Clear - Default
2: Don't clear
'@
Expand Down Expand Up @@ -931,8 +931,13 @@ Function New-SectionGroupConversionConfig {
}
if ($config['keepspaces']['value'] -eq 1 ) {
@{
description = 'Clear extra newlines between unordered (bullet) and ordered (numbered) list items, non-breaking spaces from blank lines, and `>` after unordered lists'
description = 'Clear extra newlines between unordered (bullet) and ordered (numbered) list items, empty paragraphs (blank lines containing only non-breaking spaces), non-breaking spaces, and `>` after unordered lists'
replacements = @(
# Remove empty paragraphs, including the blank line before them. Pandoc converts each empty paragraph to a line containing only a non-breaking space, which would otherwise leave three blank lines between paragraphs
@{
searchRegex = '\r*\n[ \t>]*\r*\n[ \t>]*\xA0[\xA0 \t]*(?=\r*\n|$)'
replacement = ''
}
# Remove non-breaking spaces
@{
searchRegex = [regex]::Escape([char]0x00A0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The powershell script `ConvertOneNote2MarkDown-v2.ps1` will utilize the OneNote
* `markdown_phpextra` (PHP Markdown Extra)
* `markdown_strict` (original unextended Markdown)
* Improved headers, with title now as a `#` heading, standardized `DateTime` format for created and modified dates, and horizontal line to separate from rest of document
* Choose whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, non-breaking spaces from blank lines, and `>` after unordered lists, which are created when converting with Pandoc
* Choose whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, empty paragraphs (blank lines containing only non-breaking spaces), non-breaking spaces, and `>` after unordered lists, which are created when converting with Pandoc
* Choose whether to remove `\` escape symbol that are created when converting with Pandoc
* Choose whether to use Line Feed (`LF`) or Carriage Return + Line Feed (`CRLF`) for new lines
* Choose whether to include a `.pdf` export alongside the `.md` file. `.md` does not preserve `InkDrawing` (i.e. overlayed drawings, highlights, pen marks) absolute positions within a page, but a `.pdf` export is a complete page snapshot that preserves `InkDrawing` absolute positions within a page.
Expand Down
2 changes: 1 addition & 1 deletion config.example.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ $conversion = 'markdown-simple_tables-multiline_tables-grid_tables+pipe_tables'
# 2: Don't include
$headerTimestampEnabled = 1

# Whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, non-breaking spaces from blank lines, and `>` after unordered lists
# Whether to clear extra newlines between unordered (bullet) and ordered (numbered) list items, empty paragraphs (blank lines containing only non-breaking spaces), non-breaking spaces, and `>` after unordered lists
# 1: Clear - Default
# 2: Don't clear
$keepspaces = 1
Expand Down