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

Children blocks with custom transformers are not included in the output of blocksToMarkdown #98

Open
andrew-polk opened this issue Aug 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@andrew-polk
Copy link

This recent change broke all children with custom transformers when using blocksToMarkdown.

I understand the change was made to prevent some duplicate markdown from being created (#62), but I think a different solution is needed.

Consider the simple use case of a numbered list with sub items.

  1. One
    1. Sub one

If I call blocksToMarkdown on the first item, my numbered_list_item custom transformer used to be called for both items and both items would end up in the output.

Now, the child never makes it to the output at all.

This is true of any child with a custom transformer.

Was this an oversight?
Or did you intend that if a custom transformer was used that the transformer should be responsible for handling the type and all its children?
If the latter, could you provide an example of how this can most easily be accomplished?

@souvikinator
Copy link
Owner

souvikinator commented Aug 26, 2023

Hi Andrew. I tried replicating the issue.

Considering bulleted_list_items

  1. One
    i sub one

and following a custom transformer.

n2m.setCustomTransformer("numbered_list_item", async (block) => {
  // deal with the block and it's children as per your need
  console.log(block);
});

Custom transformer deals with that specific block type and one has to deal with the children of that block.

When the custom transformer doesn't return anything (like in the above snippet), it should parse the numbered_list_items normally. However, on replicating the issue it doesn't work as intended.

Before proceeding I would like to confirm if this is the problem you are facing.

I understand the change was made to prevent some duplicate markdown from being created (#62), but I think a different solution is needed.

Definitely, this is the issue and I am trying to come up with a alternative solution/

@kmlbgn
Copy link

kmlbgn commented Dec 11, 2023

Clearly it is a huge tradeoff being made here as there is a higher need for child handling than synced block handling I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants