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

Question: Handling multiple/nested tags #121

Open
marcusway opened this issue Jul 26, 2020 · 0 comments
Open

Question: Handling multiple/nested tags #121

marcusway opened this issue Jul 26, 2020 · 0 comments

Comments

@marcusway
Copy link

marcusway commented Jul 26, 2020

Hello!

  1. Thanks for this library; it's great.
  2. I'm wondering what the best way is for dealing with with nested tags. for instance, if i have <strong><em>Hello!</em></strong>, I'd like for "Hello!" to be both bolded and italicized, but the most deeply nested tag wins the day with my current approach (i.e. the hello example is italicized but not bolded). This is what I have:
let baseStyle = Style {...}

let boldStyle = baseStyle.byAdding {
    $0.traitVariants = $0.traitVariants?.union(.bold) ?? .bold;
    // have also tried $0.traitVariants = .bold, same effect
}

let italicStyle = baseStyle.byAdding {
    $0.traitVariants = $0.traitVariants?.union(.italic) ?? .italic
    // have also tried $0.traitVariants = .italic, same effect

}

let xmlStyle = SyleXML(base: baseStyle, ["strong": strongStyle, "em": italicStyle])

I'm a bit of an iOS noob; any direction here is much appreciated.

Thanks again!

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

1 participant