Skip to content

Commit ff55462

Browse files
Merge pull request #165 from theohbrothers/fix/configuration-add-support-for-notesdestpath-config-option-to-contain-spaces
Fix (configuration): Add support for `$notesdestpath` config option to contain spaces
2 parents 2c0b58f + e60ffcc commit ff55462

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

ConvertOneNote2MarkDown-v2.ps1

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,31 @@ Function Convert-OneNotePage {
11611161
# Start-Process has no way of capturing stderr / stdterr to variables, so we need to use temp files.
11621162
"Converting docx file to markdown file: $( $pageCfg['filePath'] )" | Write-Verbose
11631163
if (!$config['dryRun']['value']) {
1164-
$argumentList = @( '-f', 'docx', '-t', $pageCfg['conversion'], '-i', $pageCfg['docxExportFilePath'], '-o', $pageCfg['filePathNormal'], '--wrap=none', '--markdown-headings=atx', "--extract-media=$( $pageCfg['mediaParentPathPandoc'] )" )
1164+
$argumentList = @(
1165+
'-f'
1166+
'docx'
1167+
'-t'
1168+
$pageCfg['conversion']
1169+
'-i'
1170+
if ($pageCfg['docxExportFilePath'] -match ' ') {
1171+
"`"$( $pageCfg['docxExportFilePath'] )`"" # Add double-quotes to path containing spaces
1172+
}else {
1173+
$pageCfg['docxExportFilePath']
1174+
}
1175+
'-o'
1176+
if ($pageCfg['filePathNormal'] -match ' ') {
1177+
"`"$( $pageCfg['filePathNormal'] )`"" # Add double-quotes to path containing spaces
1178+
}else {
1179+
$pageCfg['filePathNormal']
1180+
}
1181+
'--wrap=none'
1182+
'--markdown-headings=atx'
1183+
if ($pageCfg['mediaParentPathPandoc'] -match ' ') {
1184+
"`"--extract-media=$( $pageCfg['mediaParentPathPandoc'] )`"" # Add double-quotes to path containing spaces
1185+
}else {
1186+
"--extract-media=$( $pageCfg['mediaParentPathPandoc'] )"
1187+
}
1188+
)
11651189
"Command line: pandoc.exe $argumentList" | Write-Verbose
11661190
$process = Start-Process -ErrorAction Stop -RedirectStandardError $stderrFile -PassThru -NoNewWindow -Wait -FilePath pandoc.exe -ArgumentList $argumentList # extracts into ./media of the supplied folder
11671191
if ($process.ExitCode -ne 0) {

0 commit comments

Comments
 (0)