Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap media paths with <> #3

Open
FerranC96 opened this issue Jun 16, 2022 · 5 comments
Open

Wrap media paths with <> #3

FerranC96 opened this issue Jun 16, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@FerranC96
Copy link

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:

@alopezrivera
Copy link
Owner

alopezrivera commented Jun 17, 2022

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 eb2fc69.

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'

@FerranC96
Copy link
Author

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!

@alopezrivera
Copy link
Owner

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!

@FerranC96
Copy link
Author

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 :(

@alopezrivera
Copy link
Owner

alopezrivera commented Jun 18, 2022

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 c8bc293. 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 8477bd0. It's working well in my machine using

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

@alopezrivera alopezrivera added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants