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

Support for custom tags #354

Closed
paulocoutinhox opened this issue Jul 17, 2020 · 5 comments
Closed

Support for custom tags #354

paulocoutinhox opened this issue Jul 17, 2020 · 5 comments

Comments

@paulocoutinhox
Copy link

Hi,

I want support custom tags like J. See my example:

E, respondendo Jesus, disse: <J>Não foram dez os limpos? E onde [estão] os nove?</J>

I want paint with red, but the text simply is not rendered.

My code:

Html(
data:
    "<sup>${bibleVerse.verse}</sup> <div>${bibleVerse.text}</div>",
style: {
  "html": FHStyle.Style(
    textAlign: TextAlign.left,
  ),
  "div": FHStyle.Style(
    color: appStore.settingsVerseTextColor,
    fontFamily: appStore.settingsFontFamily,
    fontSize: FontSize(
        appStore.settingsVerseTextFontSize),
    display: FHStyle.Display.INLINE,
  ),
  "sup": FHStyle.Style(
    color: appStore.settingsVerseNumberColor,
    fontFamily: appStore.settingsFontFamily,
    fontSize: FontSize(
        appStore.settingsVerseNumberFontSize),
  ),
  "J": FHStyle.Style(
    color:
        appStore.settingsJesusWordTextColor,
    fontFamily: appStore.settingsFontFamily,
    fontSize: FontSize(
        appStore.settingsVerseTextFontSize),
  ),
),

For common tags work nice, but for J the text is not rendered.

Can you help me?

Thanks.

@paulocoutinhox
Copy link
Author

I solved one problem. The text appear with custom render. But the text is on other line:

Simulator Screen Shot - iPhone 11 Pro Max - 2020-07-17 at 05 19 45

@ryan-berger
Copy link
Collaborator

@prsolucoes We've had requests for this in the past, but I'm not sure if this is what flutter_html is made for. We really want it to be for rendering HTML, not for rendering a web app. I would recommend normalizing your HTML before feeding it through flutter_html

This is also a duplicate of #309

@fehernyul
Copy link

And how can you solve it??

@ryan-berger
Copy link
Collaborator

@fehernyul The only way to do so would be to normalize your HTML. You could regex it, you could parse it and recursively edit the tree, stringify, and then feed it into flutter_html, change the source so it uses standard HTML tags rather than non-standard tags or web component tags. There are many different ways one could go about it

@DFelten
Copy link
Contributor

DFelten commented Sep 10, 2020

An other possibility is to use custom tags and use a custom renderer for them. There you need to define the widget for the corresponding tag. So it's possible to define the behavior yourself.

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