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

fixes #337 broken ToC import in Notion #340

Merged
merged 5 commits into from
Jan 3, 2025

Conversation

felciabatta
Copy link
Contributor

Issue

As in #337, table of contents import is broken:

  • there are no links
  • the indentation structure is not preserved

Solution

  1. extend convertLinksToObsidian to format ToC heading links
  2. recreate indentation using unordered lists by recursively appending each item

@felciabatta
Copy link
Contributor Author

felciabatta commented Dec 20, 2024

Original in Notion

toc-notion

Before & After (Render)

toc-before toc-after

Before & After (Source)

toc-before-src toc-after-src

Copy link
Contributor

@tgrosinger tgrosinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a couple small questions.

src/formats/notion/convert-to-md.ts Outdated Show resolved Hide resolved
src/formats/notion/convert-to-md.ts Show resolved Hide resolved
src/formats/notion/convert-to-md.ts Outdated Show resolved Hide resolved
@felciabatta
Copy link
Contributor Author

Thanks! Just a couple small questions.

No worries, will have look through this later in the week :)

@tgrosinger
Copy link
Contributor

This is looking great. I just noticed though that "A Toggle Heading 2" and "A Toggle Heading 3" do not show up in the TOC. I'm not very familiar with Notion. Should those have been included?

@felciabatta
Copy link
Contributor Author

felciabatta commented Jan 3, 2025

This is looking great. I just noticed though that "A Toggle Heading 2" and "A Toggle Heading 3" do not show up in the TOC. I'm not very familiar with Notion. Should those have been included?

Oh, that's interesting, I did not notice!
However, this is expected: I just checked and those two toggle headings do not appear within Notion.

I think the reason is simply because they are "hidden" inside "A Toggle Heading 1", so the nested headings are interpreted as invisible to the TOC.
That seems like a strange choice to me so I'm not sure if it's a bug or feature in Notion, but it is the native behaviour.

@tgrosinger
Copy link
Contributor

Got it, thanks for checking.

@tgrosinger tgrosinger merged commit b786f00 into obsidianmd:master Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants