Skip to content

Commit fbda8c5

Browse files
committed
onenote: add more test files
1 parent 3c289d7 commit fbda8c5

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

docs/formats/onenote.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source_app: OneNote
77
## General Information
88

99
- [Website](https://www.onenote.com/)
10-
- Typical extension: `.zip`
10+
- Typical extension: `.zip` or folder of `.zip` files
1111

1212
## Instructions
1313

jimmy/formats/onenote.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
class Converter(converter.BaseConverter):
1515
accepted_extensions = [".zip"]
16+
accept_folder = True
1617

1718
def __init__(self, config):
1819
super().__init__(config)
@@ -135,9 +136,9 @@ def convert_section_and_toc(self, file_or_folder: Path, parent: imf.Notebook):
135136
# HTML -> Markdown
136137
self.convert_section_to_markdown(intermediate_html_folder, parent)
137138

138-
def convert_notebook(self):
139+
def convert_notebook(self, root_path: Path):
139140
# Only single notebooks can be exported.
140-
notebook_path = common.get_single_child_folder(self.root_path)
141+
notebook_path = common.get_single_child_folder(root_path)
141142

142143
root_notebook = imf.Notebook(notebook_path.stem)
143144
self.logger.debug(f'Converting notebook: "{root_notebook.title}"')
@@ -155,12 +156,20 @@ def convert_notebook(self):
155156
continue
156157
self.convert_section_and_toc(item, root_notebook)
157158

158-
def convert(self, _file_or_folder: Path):
159+
def convert_file_or_folder(self, file_or_folder: Path):
160+
if file_or_folder.is_file():
161+
self.convert_notebook(self.root_path)
162+
else:
163+
for onenote_zip in file_or_folder.glob("*.zip"):
164+
root_path = common.extract_zip(onenote_zip)
165+
self.convert_notebook(root_path)
166+
167+
def convert(self, file_or_folder: Path):
159168
# notebook > section > page
160169
shutil_path = shutil.which("one2html")
161170
if shutil_path is None:
162171
self.logger.error('"one2html" binary not found.')
163172
return
164173
self.logger.debug(f"Using one2html from: {shutil_path}")
165174
self.logger.debug(f'temp_folder: "{self.temp_folder}"')
166-
self.convert_notebook()
175+
self.convert_file_or_folder(file_or_folder)

test/test_convert.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def format_test(self, test_input: Path):
185185
[["notion/test_6/notion-testspace.zip"]],
186186
[["obsidian/test_1_frontmatter/vault"]],
187187
[["onenote/test_1_frontmatter/OneDrive_2025-09-28.zip"]],
188+
[["onenote/test_2/onenoters"]],
188189
# can't test with frontmatter - git doesn't preserve timestamps
189190
# https://github.com/actions/checkout/issues/364#issuecomment-812618265
190191
[["qownnotes/test_1/note_folder"]],

0 commit comments

Comments
 (0)