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

Overlapping marks generate invalid HTML #33

Closed
adrichel opened this issue Mar 15, 2023 · 3 comments
Closed

Overlapping marks generate invalid HTML #33

adrichel opened this issue Mar 15, 2023 · 3 comments

Comments

@adrichel
Copy link

Hello,

there seems to be an issue with the Tiptap JSON to HTML conversion when using overlapping styles like this:

image

JSON input:

{
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "content": [
        {
          "type": "text",
          "marks": [
            {
              "type": "bold"
            }
          ],
          "text": "lorem "
        },
        {
          "type": "text",
          "marks": [
            {
              "type": "bold"
            },
            {
              "type": "italic"
            }
          ],
          "text": "ipsum"
        },
        {
          "type": "text",
          "marks": [
            {
              "type": "italic"
            }
          ],
          "text": " dolor"
        }
      ]
    }
  ]
}

HTML output:

<p><strong>lorem <em>ipsum</strong> dolor</em></p>

Expected HTML output:

<p><strong>lorem <em>ipsum</em></strong><em> dolor</em></p>

For easy reproduction:

(new Tiptap\Editor)
  ->setContent([
      "type" => "doc",
      "content" => [
          [
              "type" => "paragraph",
              "content" => [
                  [
                      "type" => "text",
                      "marks" => [
                          [
                              "type" => "bold"
                          ]
                      ],
                      "text" => "lorem "
                  ],
                  [
                      "type" => "text",
                      "marks" => [
                          [
                              "type" => "bold"
                          ],
                          [
                              "type" => "italic"
                          ]
                      ],
                      "text" => "ipsum"
                  ],
                  [
                      "type" => "text",
                      "marks" => [
                          [
                              "type" => "italic"
                          ]
                      ],
                      "text" => " dolor"
                  ]
              ]
          ]
      ]
  ])
  ->getHTML();

Thanks in advance :)

@helloiamlukas
Copy link

Any updates on this?

@hivokas
Copy link

hivokas commented Jun 3, 2023

Having similar issue.

Expected:

<strong>You can include a link:  </strong><a href="https://example.com"><strong>Example</strong></a>

Actual:

<strong>You can include a link:  <a href="https://example.com">Example</strong></a>

@timoisik
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants