Skip to content

What is the correct structure of a code block? #2160

Answered by 12joan
12joan asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for your reply!

The current implementation of unwrapCodeBlock, without withoutNormalizing, replaces a correctly-structured code block with [], removing it entirely.

With withoutNormalizing, it unwraps the first code_line to an orphaned text node, which is removed upon normalization. The second code_line remains in the code block.

Before normalization
    [
      {
        "text": "line 1"
      },
      {
        "type": "code_block",
        "children": [
          {
            "type": "code_line",
            "children": [
              {
                "text": "line 2"
              }
            ]
          }
        ]
      }
    ]
After normalization
    [
      {
        

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

12joan
Jan 26, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by zbeyens
Comment options

12joan
Jan 26, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

12joan
Jan 26, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

12joan
Jan 27, 2023
Maintainer Author

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants