notion-to-md
notion-to-md copied to clipboard
Toggle summary may be truncated
Hello,
I'm trying to convert a Notion /toggle
's summary properly, but it is truncated.
This :
is converted as :
<summary>Les principes de base du fonctionnement des Fablabs ont été définis par la </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 ?
Correct me if I got your requirement wrong. You want to render the annotations as well in the toggle summary ?
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 ?
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.
Directly producing HTML is not this package's purpose but outputting
andis probably the only way this can be done.
Remember HTML is also supported in markdown docs :)