Skip to content

Commit

Permalink
Merge pull request #165 from theohbrothers/fix/configuration-add-supp…
Browse files Browse the repository at this point in the history
…ort-for-notesdestpath-config-option-to-contain-spaces

Fix (configuration): Add support for `$notesdestpath` config option to contain spaces
  • Loading branch information
leojonathanoh committed Jul 12, 2023
2 parents 2c0b58f + e60ffcc commit ff55462
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ConvertOneNote2MarkDown-v2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,31 @@ Function Convert-OneNotePage {
# Start-Process has no way of capturing stderr / stdterr to variables, so we need to use temp files.
"Converting docx file to markdown file: $( $pageCfg['filePath'] )" | Write-Verbose
if (!$config['dryRun']['value']) {
$argumentList = @( '-f', 'docx', '-t', $pageCfg['conversion'], '-i', $pageCfg['docxExportFilePath'], '-o', $pageCfg['filePathNormal'], '--wrap=none', '--markdown-headings=atx', "--extract-media=$( $pageCfg['mediaParentPathPandoc'] )" )
$argumentList = @(
'-f'
'docx'
'-t'
$pageCfg['conversion']
'-i'
if ($pageCfg['docxExportFilePath'] -match ' ') {
"`"$( $pageCfg['docxExportFilePath'] )`"" # Add double-quotes to path containing spaces
}else {
$pageCfg['docxExportFilePath']
}
'-o'
if ($pageCfg['filePathNormal'] -match ' ') {
"`"$( $pageCfg['filePathNormal'] )`"" # Add double-quotes to path containing spaces
}else {
$pageCfg['filePathNormal']
}
'--wrap=none'
'--markdown-headings=atx'
if ($pageCfg['mediaParentPathPandoc'] -match ' ') {
"`"--extract-media=$( $pageCfg['mediaParentPathPandoc'] )`"" # Add double-quotes to path containing spaces
}else {
"--extract-media=$( $pageCfg['mediaParentPathPandoc'] )"
}
)
"Command line: pandoc.exe $argumentList" | Write-Verbose
$process = Start-Process -ErrorAction Stop -RedirectStandardError $stderrFile -PassThru -NoNewWindow -Wait -FilePath pandoc.exe -ArgumentList $argumentList # extracts into ./media of the supplied folder
if ($process.ExitCode -ne 0) {
Expand Down

0 comments on commit ff55462

Please sign in to comment.