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

div style properties overrule inner span style properties #49

Closed
michvllni opened this issue May 15, 2020 · 2 comments
Closed

div style properties overrule inner span style properties #49

michvllni opened this issue May 15, 2020 · 2 comments

Comments

@michvllni
Copy link

Hi again, sorry for coming up with another issue.

I'm using tinyMCE to generate the HTML code, and unfortunately, tinyMCE generates font-size properties even in the surrounding divs and even if they aren't even needed.
For both examples, I used the test site you provided.
So, when trying to convert this

<div style="font-size: 7pt;"><span style="font-size: 11pt;">asda<strong>sd</strong>dad</span></div>
<div style="font-size: 7pt;">&nbsp;</div>
<div style="font-size: 7pt;"><span style="font-size: 11pt;">ublubub</span></div>
<div style="font-size: 7pt;">&nbsp;</div>
<div style="font-size: 7pt;"><span style="font-size: 11pt;">asdasd</span></div>
<div style="font-size: 7pt;">&nbsp;</div>
<div style="font-size: 7pt;"><span style="font-size: 11pt;">kl&ouml;asd<em>asd<u>asdasd</u></em></span></div>
<div style="font-size: 7pt;">&nbsp;</div>

I get the following result:

[
  {
    "text": [
      {
        "text": "asda",
        "style": [
          "html-span"
        ]
      },
      {
        "text": "sd",
        "style": [
          "html-strong",
          "html-span"
        ],
        "bold": true
      },
      {
        "text": "dad",
        "style": [
          "html-span"
        ]
      }
    ],
    "style": [
      "html-span",
      "html-div"
    ],
    "fontSize": 7
  },
  {
    "text": " ",
    "fontSize": 7,
    "style": [
      "html-div"
    ]
  },
  {
    "text": "ublubub",
    "style": [
      "html-span",
      "html-div"
    ],
    "fontSize": 7
  },
  {
    "text": " ",
    "fontSize": 7,
    "style": [
      "html-div"
    ]
  },
  {
    "text": "asdasd",
    "style": [
      "html-span",
      "html-div"
    ],
    "fontSize": 7
  },
  {
    "text": " ",
    "fontSize": 7,
    "style": [
      "html-div"
    ]
  },
  {
    "text": [
      {
        "text": "klöasd",
        "style": [
          "html-span"
        ]
      },
      {
        "text": [
          {
            "text": "asd",
            "style": [
              "html-em",
              "html-span"
            ],
            "italics": true
          },
          {
            "text": "asdasd",
            "style": [
              "html-u",
              "html-em",
              "html-span"
            ],
            "decoration": "underline",
            "italics": true
          }
        ],
        "italics": true,
        "style": [
          "html-em",
          "html-span"
        ]
      }
    ],
    "style": [
      "html-span",
      "html-div"
    ],
    "fontSize": 7
  },
  {
    "text": " ",
    "fontSize": 7,
    "style": [
      "html-div"
    ]
  }
]

And it looks like this:
image

where the font size is 7 instead of the 11 of the span.

Additionally, <br> tags cause some weird behavior as well. It appears to variate the font-size in some lines, but not in all.

Example:

<div style="font-family: segoe ui; font-size: 7pt;"><span style="font-size: 11pt;">asda<strong>sd</strong>dad</span><br></div>
<div style="font-family: segoe ui; font-size: 7pt;">&nbsp;<br></div>
<div style="font-family: segoe ui; font-size: 7pt;"><span style="font-size: 11pt;">ublubub</span><br></div>
<div style="font-family: segoe ui; font-size: 7pt;">&nbsp;<br></div>
<div style="font-family: segoe ui; font-size: 7pt;"><span style="font-size: 11pt;">asdasd</span><br></div>
<div style="font-family: segoe ui; font-size: 7pt;">&nbsp;<br></div>
<div style="font-family: segoe ui; font-size: 7pt;"><span style="font-size: 11pt;">kl&ouml;asd<em>asd<u>asdasd</u></em></span><br></div>
<div style="font-family: segoe ui; font-size: 7pt;">&nbsp;<br></div>

And the output:

[
  {
    "text": [
      {
        "text": [
          {
            "text": "asda",
            "style": [
              "html-span"
            ]
          },
          {
            "text": "sd",
            "style": [
              "html-strong",
              "html-span"
            ],
            "bold": true
          },
          {
            "text": "dad",
            "style": [
              "html-span"
            ]
          }
        ],
        "style": [
          "html-span"
        ],
        "fontSize": 11
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": " "
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": "ublubub",
        "style": [
          "html-span"
        ],
        "fontSize": 11
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": " "
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": "asdasd",
        "style": [
          "html-span"
        ],
        "fontSize": 11
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": " "
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": [
          {
            "text": "klöasd",
            "style": [
              "html-span"
            ]
          },
          {
            "text": [
              {
                "text": "asd",
                "style": [
                  "html-em",
                  "html-span"
                ],
                "italics": true
              },
              {
                "text": "asdasd",
                "style": [
                  "html-u",
                  "html-em",
                  "html-span"
                ],
                "decoration": "underline",
                "italics": true
              }
            ],
            "italics": true,
            "style": [
              "html-em",
              "html-span"
            ]
          }
        ],
        "style": [
          "html-span"
        ],
        "fontSize": 11
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  },
  {
    "text": [
      {
        "text": " "
      },
      "\n"
    ],
    "style": [
      "html-div"
    ],
    "fontFamily": "segoeui",
    "fontSize": 7
  }
]

which then looks like this:
image

@Aymkdn Aymkdn closed this as completed in 31c7751 May 15, 2020
@Aymkdn
Copy link
Owner

Aymkdn commented May 15, 2020

I've just published v1.3.0 that should resolve this issue.

@michvllni
Copy link
Author

Thank you again for your fast fix :)

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

2 participants