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

OneNotes notes with folded/collapsed areas not converted #99

Open
SomeMichael opened this issue Feb 15, 2024 · 4 comments
Open

OneNotes notes with folded/collapsed areas not converted #99

SomeMichael opened this issue Feb 15, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@SomeMichael
Copy link

Describe the bug
When one uses folding/collapsing in OneNote onenote-md-exporter misses the folded/collapsed content when converting.
OneNote-Example:
OneNote

Results:
Folded content is not included.
Joplin_Folded
Joplin_Unfolded

To Reproduce
Convert the following OneNote file:
Test_OneNote2Joplin.zip

Expected behavior
Also convert content in the folded sections.

Desktop (please complete the following information):

  • OneNodeMdExporter version : v1.3.0, v1.4.0
  • Windows version : Windows 11 64 bits
  • Office Version : Office Pro Plus 2016

Additional context
I tried to find a way to automatically unfold these section looking here, but couldn't find anything (But I'm not an expert one these things :))
It might be possible using getonetastic?
My problem is that my OneNote collection of Notes is quite big. Resulting in 7000 files (also attachments included, though) on Joplin side. So checking everything manually is some work... ;-)

Many thanks for any kind of help!

@SomeMichael SomeMichael added the bug Something isn't working label Feb 15, 2024
@alxnbl
Copy link
Owner

alxnbl commented Feb 15, 2024

Hello @SomeMichael , thank you for the detailed feedback.
Indeed I knew this limitation which comes from a behavior of OneNote API. I don't think I will have time to determine if and how it would be possible to unfold automatically paragraph during page export.
However in your case, as you suggested, find a OneNote plugin that can do that for you seams a good approach. I don't know much theses plugins, but maybe you can find help on some OneNote community forums like https://www.reddit.com/r/OneNote/ .

@alxnbl alxnbl added enhancement New feature or request and removed bug Something isn't working labels Feb 15, 2024
@SomeMichael
Copy link
Author

Thanks for your answer, @alxnbl. I think will getonetastic a try, then.

Maybe it would be a good idea to add this limitation here?

@alxnbl
Copy link
Owner

alxnbl commented Feb 18, 2024

Indeed, I added the limitation to the readme !

@SomeMichael
Copy link
Author

Just if anyone runs into the same issue and finds this thread. I came up with this Powershell script to expand all outlines in a notebook:

$OneNote = New-Object -ComObject OneNote.Application

[string]$nbid = ""
[xml]$nbh = ""

$OneNote.OpenHierarchy('FullPath2NotebookFolder', "", [ref]$nbid)
$OneNote.GetHierarchy($nbid, [Microsoft.Office.Interop.OneNote.HierarchyScope]::hsPages, [ref]$nbh)

foreach ($page in $nbh.Notebook.Section.Page ) {

    $page.ParentNode.Name + " " + $page.Name
    
    [xml]$pagexml = ""
    $OneNote.GetPageContent($page.ID, [ref]$pagexml)

    $write = ""
    foreach ($el in $pagexml.GetElementsByTagName("one:OE")) {
        
        if ($el.collapsed -eq "1") {

            Write-Host "	Outline expanded!"
            $el.removeAttribute("collapsed")
            $write = "updatepage"

        }
    }

    if ($write -ne "") {
        $OneNote.UpdatePageContent($pagexml.OuterXml.ToString())
    }
}

Replace FullPath2NotebookFolder with the full path to the folder containing the *.one files of your notebook!

Please run this script using Powershell 5.* . Powershell 6 and above have issues explained here. I couldn't figure out how to get it running in Powershell 7.*.

Please make a backup of your *.one files prior to running the script! I'm not a very experienced programmer, so expect some errors when you run the script ;-)

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