flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] vertical-align not working in Html/SelectableHtml

Open kaiquegazola opened this issue 3 years ago • 1 comments

Describe the bug:

vertical-align property doesn't work as expected.

HTML to reproduce the issue:

<span>3</span><span style="vertical-align: super">x</span><span>-27 = 0<sup>x</sup></span>

Html widget configuration:

Using clean Html or SelectableHtml.

Additional info:

I couldn't find the property vertical-align in the parser file: https://github.com/Sub6Resources/flutter_html/blob/9bf06629d18caff5ad1ec390bb9dcae6ec8119fa/lib/src/css_parser.dart#L10

I try to put it, like this, seems works fine in Html default constructor

case 'vertical-align':
  style.verticalAlign =
      ExpressionMapping.expressionToVerticalAlign(value.first);
  break;

// ... //

static VerticalAlign expressionToVerticalAlign(css.Expression value) {
  if (value is css.LiteralTerm) {
    switch (value.text) {
      case "sub":
        return VerticalAlign.SUB;
      case "super":
        return VerticalAlign.SUPER;
    }
  }
  return VerticalAlign.BASELINE;
}

but that doesn't work with the SelectableHtml constructor, throwing a exception in this cast: https://github.com/Sub6Resources/flutter_html/blob/9bf06629d18caff5ad1ec390bb9dcae6ec8119fa/lib/html_parser.dart#L334

i think its are related to https://github.com/flutter/flutter/issues/38474, since it is merged, it's a leftover? removing this cast, works fine in my test case.

A picture of a cute animal (not mandatory but encouraged)

kaiquegazola avatar Jul 14 '22 13:07 kaiquegazola

Related #717.

dragnev-dev avatar Aug 19 '22 08:08 dragnev-dev

What is the status on this?

Can someone provide instructions on what could be done to implement this?

IvanVnucec avatar Oct 28 '22 17:10 IvanVnucec

Still in progress. The code provided in the initial comment should be sufficient for a pull request, if someone would like to open one. SelectableHtml is being removed in 3.0.0 anyways.

Sub6Resources avatar Nov 02 '22 17:11 Sub6Resources