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

Toggle summary may be truncated #46

Open
smor opened this issue Jul 28, 2022 · 4 comments
Open

Toggle summary may be truncated #46

smor opened this issue Jul 28, 2022 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@smor
Copy link
Contributor

smor commented Jul 28, 2022

Hello,

I'm trying to convert a Notion /toggle's summary properly, but it is truncated.

This :
image
is converted as :

<summary>Les principes de base du fonctionnement des Fablabs ont été définis par la&nbsp;</summary>

This is due to https://github.com/souvikinator/notion-to-md/blob/master/src/notion-to-md.ts#L305 handling rich_text[0] only.

Directly producing HTML is not this package's purpose and I'd rather output the full summary as Markdown, but outputting <details> and <summary> is probably the only way this can be done.

Any idea on how to deal with this properly ?

@souvikinator
Copy link
Owner

Correct me if I got your requirement wrong.
You want to render the annotations as well in the toggle summary ?

@smor
Copy link
Contributor Author

smor commented Jul 29, 2022

IMHO the toggle summary should be treated like any other paragraph and be rendered fully with annotations indeed, links, etc. The difficulty lies in keeping a functional Markdown output along with HTML tags required to produce the toggle, right ?

@souvikinator
Copy link
Owner

True, maybe I should treat toggle as paragraph, but I'm sure it's going to break a lot of websites using this package. Any preferred format you have in mind?

I tried using setCustomTransformer like so:

n2m.setCustomTransformer("toggle", async (block) => {
  const { toggle } = block as any;
  // console.log(toggle);
  let toggle_text = "";
  toggle.rich_text.forEach((rich_text: any) => {
    toggle_text += n2m.annotatePlainText(
      rich_text.plain_text,
      rich_text.annotations
    );
  });
  return toggle_text;
});

output:

This is a <u>~~**toggle**~~</u>

however this won't deal with the toggle children.

@souvikinator souvikinator added enhancement New feature or request question Further information is requested and removed enhancement New feature or request labels Jul 30, 2022
@GorvGoyl
Copy link

GorvGoyl commented Sep 22, 2022

Directly producing HTML is not this package's purpose
but outputting

and is probably the only way this can be done.

Remember HTML is also supported in markdown docs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants