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

Supporting empty block for spacing #5

Closed
MarcARoberge opened this issue Oct 27, 2021 · 3 comments
Closed

Supporting empty block for spacing #5

MarcARoberge opened this issue Oct 27, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@MarcARoberge
Copy link
Contributor

Hi,

I tried to add empty blocks into a page and when it's converting, it's ignoring it. I tried to activate the breaks option from marked without sucess. Maybe du since the text array from the content is empty?

@nartc
Copy link
Owner

nartc commented Oct 27, 2021

Do you know what an empty block could mean in terms of Notion API? like a ParagraphBlock would have Block#type === 'paragraph'

@MarcARoberge
Copy link
Contributor Author

This is what I am getting

{
    "object": "block",
    "id": "",
    "created_time": "2021-10-27T21:17:00.000Z",
    "last_edited_time": "2021-10-27T21:17:00.000Z",
    "has_children": false,
    "archived": false,
    "type": "paragraph",
    "paragraph": {
      "text": []
    }
  },

@nartc
Copy link
Owner

nartc commented Oct 28, 2021

I think it's related to this PR (markedjs/marked#363) from marked. They trim all non-breaking space between markdown blocks.

ParagraphBlock with empty text: [] should be parsed to: \n\n (https://github.com/nartc/notion-stuff/blob/main/libs/blocks-markdown-parser/src/lib/blocks-markdown-parser.ts#L152). However, due to the issue mentioned above, it just gets removed.

There are a couple of workarounds in the linked issue (eg: customizing a lexer) to handle this. Or if you'd like and if you think it makes sense, I'm welcoming PR to support this from blocks-markdown-parser.

Basically for the PR, I'd like to see:

  • MarkdownParser accepts a new option: emptyParagraphToNonBreakingSpace (I mean you can come up with a better name if you'd like 😅)
  • Based on this new option, and if paragraph.text is an [], then return   instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants