From fd0b77140030b70236ac257fefd715376f10eb25 Mon Sep 17 00:00:00 2001 From: nixsee Date: Mon, 3 Aug 2020 10:51:53 -0600 Subject: [PATCH 1/2] Update ConvertOneNote2MarkDown-v2.ps1 --- ConvertOneNote2MarkDown-v2.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConvertOneNote2MarkDown-v2.ps1 b/ConvertOneNote2MarkDown-v2.ps1 index e55a287..8105bfa 100644 --- a/ConvertOneNote2MarkDown-v2.ps1 +++ b/ConvertOneNote2MarkDown-v2.ps1 @@ -159,7 +159,7 @@ Function ProcessSections ($group, $FilePath) { # https://gist.github.com/heardk/ded40b72056cee33abb18f3724e0a580 try { - pandoc.exe -f docx -t $converter-simple_tables-multiline_tables-grid_tables+pipe_tables -i $fullexportpath -o "$($fullfilepathwithoutextension).md" --wrap=none --atx-headers --extract-media="$($mediaPath)" + pandoc.exe -f docx -t markdown-simple_tables-multiline_tables-grid_tables+pipe_tables -i $fullexportpath -o "$($fullfilepathwithoutextension).md" --wrap=none --atx-headers --extract-media="$($mediaPath)" } catch { Write-Host "Error while converting file '$($page.name)' to md: $($Error[0].ToString())" -ForegroundColor Red From 137dfbd3d884ebb85783cc0c6f68ef4520efd426 Mon Sep 17 00:00:00 2001 From: nixsee Date: Thu, 1 Oct 2020 20:10:14 -0600 Subject: [PATCH 2/2] added section group nesting to 5 levels --- ConvertOneNote2MarkDown-v2.ps1 | 41 ++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/ConvertOneNote2MarkDown-v2.ps1 b/ConvertOneNote2MarkDown-v2.ps1 index 8105bfa..f659904 100644 --- a/ConvertOneNote2MarkDown-v2.ps1 +++ b/ConvertOneNote2MarkDown-v2.ps1 @@ -159,7 +159,7 @@ Function ProcessSections ($group, $FilePath) { # https://gist.github.com/heardk/ded40b72056cee33abb18f3724e0a580 try { - pandoc.exe -f docx -t markdown-simple_tables-multiline_tables-grid_tables+pipe_tables -i $fullexportpath -o "$($fullfilepathwithoutextension).md" --wrap=none --atx-headers --extract-media="$($mediaPath)" + pandoc.exe -f docx -t $converter-simple_tables-multiline_tables-grid_tables+pipe_tables -i $fullexportpath -o "$($fullfilepathwithoutextension).md" --wrap=none --atx-headers --extract-media="$($mediaPath)" } catch { Write-Host "Error while converting file '$($page.name)' to md: $($Error[0].ToString())" -ForegroundColor Red @@ -296,7 +296,8 @@ $notesdestpath = Read-Host -Prompt "Entry" "1: Discard intermediate .docx files - Default" "2: Keep .docx files" [int] $keepdocx = Read-Host -Prompt "Entry" - +"" +"-----------------------------------------------" # prompt for prefix vs subfolders "1: Create folders for subpages (e.g. Page\Subpage.md)- Default" "2: Add prefixes for subpages (e.g. Page_Subpage.md)" @@ -388,6 +389,42 @@ if (Test-Path -Path $notesdestpath) { New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)" -Name "$($sectiongroupFileName2)" -ItemType "directory" -ErrorAction SilentlyContinue $sectiongroupFilePath2 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)" ProcessSections $sectiongroup2 $sectiongroupFilePath2 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup3 in $sectiongroup2.SectionGroup) { + $levelsfromroot = 3 + if ($sectiongroup3.isRecycleBin -ne 'true') { + "### " + $sectiongroup3.Name + $sectiongroupFileName3 = "$($sectiongroup3.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)" -Name "$($sectiongroupFileName3)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath3 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)" + ProcessSections $sectiongroup3 $sectiongroupFilePath3 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup4 in $sectiongroup3.SectionGroup) { + $levelsfromroot = 4 + if ($sectiongroup4.isRecycleBin -ne 'true') { + "#### " + $sectiongroup4.Name + $sectiongroupFileName4 = "$($sectiongroup4.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)" -Name "$($sectiongroupFileName4)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath4 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)" + ProcessSections $sectiongroup4 $sectiongroupFilePath4 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup5 in $sectiongroup4.SectionGroup) { + $levelsfromroot = 5 + if ($sectiongroup5.isRecycleBin -ne 'true') { + "#### " + $sectiongroup5.Name + $sectiongroupFileName5 = "$($sectiongroup5.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)" -Name "$($sectiongroupFileName5)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath5 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)\\$($sectiongroupFileName5)" + ProcessSections $sectiongroup5 $sectiongroupFilePath5 + } + } + } + } + } + } } } }