OneNoteExporter icon indicating copy to clipboard operation
OneNoteExporter copied to clipboard

Wrap media paths with <>

Open fercrcode opened this issue 3 years ago • 5 comments

If there are any spaces in the path to media files, those can't be parsed and loaded into the .md file. Simply wrapping the file paths with <> in markdown would solve the issue.

Example:

  • Current behaviour: ![](media/FILENAME with SPACES.file) ----> Broken link in .md
  • Proposed solution: ![](<media/FILENAME with SPACES.file>)

Using <> for file paths in markdown:

fercrcode avatar Jun 16 '22 08:06 fercrcode

Hey! Thanks for the report and looking for a solution. I've implemented this (for markdown flavors which use the ![]() syntax, such as plain or Pandoc markdown) in commit https://github.com/alopezrivera/owo/commit/eb2fc69f378b4d039988fffb7e6552fa9d18408b.

Let me know if it works for you :)

Side note

Consider as well that GitHub-flavored markdown has a different syntax, as folllows,

<img src="media/owo test-image1.jpeg" style="width:2.27361in;height:1.70764in" />

which supports paths with spaces by default as well as keeping image size information. The markdown test in the tests directory renders well both in GitHub and VSCode. To use GitHub flavored markdown, set conversion in line 66 of your config.ps1 to

$conversion = 'markdown_github-simple_tables-multiline_tables-grid_tables+pipe_tables'

alopezrivera avatar Jun 17 '22 12:06 alopezrivera

Wonderful, thanks a lot @alopezrivera ! I will test the fix when I have time and will report back. Also good to know that other mD flavours should be a bit more robust.

During my own testing I also realised that spaces in the notebook names (as in, the actual name as seen from OneDrive web, not the "local" name that can be changed in app) cause an error during Onenote->docx conversion, thus failing to attempt the markdown conversion. Multiple spaces in page names (>4 ?, not sure) also result in a higher level failure (where not only the markdown file won't be produced, but also other outputs such as .pdf prints).

As I said earlier, I will test the media path file and provide more detail on the rest of issues later on. Thanks again for everything!

fercrcode avatar Jun 17 '22 12:06 fercrcode

Cool! Let me know if the figure names work when you test :)

Thanks for the heads up about notebook names. If you will, please submit a new issue for that if you have the time. I'd appreciafe if you add some more information about the notebook names causing issues and such so I can replicate them and see what's going on. Thanks in advance!

alopezrivera avatar Jun 17 '22 17:06 alopezrivera

Alright, I'm back after some more tests. Thanks again for supporting the tool btw! :)

So, after the latest commits the file paths still don't appear to be flanked by <>. I looked into the commit and, from my very limited knowledge, I believe that should have fixed it. The only thing I could think off would be some shenanigans with variable names or config options, but sadly I don't enough about powershell to suggest a fix....

For reference, see below my config options: $docxReuse = 1 $docxKeep = 2 $docxNamingConvention = 1 $prefixFolders = 1 $muFileNameAndFolderNameMaxLength = 255 $mediaLocation = 1

$conversion = 'markdown-simple_tables-multiline_tables-grid_tables+pipe_tables' $markupPack = ''

$headerTimestamp = 1 $keepEscape = 1 $keepEmptyListItems = 1 $newlineCharacter = 1

$exportPDF = 2

Again, thank you for everything; I really wish I could implement the changes myself via a pull request. I also feel sorry for having mistreated OWO with my messed up old and badly named/organised notebooks :(

fercrcode avatar Jun 18 '22 15:06 fercrcode

Alright so, there's two errors that could be happening there:

  1. The replacement is not working correctly at the Markup Pack level
  2. As you are setting markupPack='' in your config, owo tried to get a default Markup Pack (which should be MarkupPack1) for markdown, failed, and thus no replacement is taking place

To cross off the second I've added support for all markups supported by Pandoc in commit https://github.com/alopezrivera/owo/commit/c8bc293086fda36bba8ad845828a4fc9055cd1f5. This means that owo will correctly identify the file format and provide a default Markup Pack for all of them.

The issue persisted, so after some trial and error I've implemented a brute force regex solution to wrap media paths in <> in commit https://github.com/alopezrivera/owo/commit/8477bd08d321cd1cb0cdc50601c828e711c17af0. It's working well in my machine using

$conversion = 'markdown-simple_tables-multiline_tables-grid_tables+pipe_tables'

alopezrivera avatar Jun 18 '22 23:06 alopezrivera