{"action":"created","issue":{"url":"https://api.github.com/repos/Raizlabs/BonMot/issues/346","repository_url":"https://api.github.com/repos/Raizlabs/BonMot","labels_url":"https://api.github.com/repos/Raizlabs/BonMot/issues/346/labels{/name}","comments_url":"https://api.github.com/repos/Raizlabs/BonMot/issues/346/comments","events_url":"https://api.github.com/repos/Raizlabs/BonMot/issues/346/events","html_url":"https://github.com/Raizlabs/BonMot/issues/346","id":347681191,"node_id":"MDU6SXNzdWUzNDc2ODExOTE=","number":346,"title":"Styling Embedded <a> tags whilst making them clickable","user":{"login":"russnettle","id":5123908,"node_id":"MDQ6VXNlcjUxMjM5MDg=","avatar_url":"https://avatars0.githubusercontent.com/u/5123908?v=4","gravatar_id":"","url":"https://api.github.com/users/russnettle","html_url":"https://github.com/russnettle","followers_url":"https://api.github.com/users/russnettle/followers","following_url":"https://api.github.com/users/russnettle/following{/other_user}","gists_url":"https://api.github.com/users/russnettle/gists{/gist_id}","starred_url":"https://api.github.com/users/russnettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russnettle/subscriptions","organizations_url":"https://api.github.com/users/russnettle/orgs","repos_url":"https://api.github.com/users/russnettle/repos","events_url":"https://api.github.com/users/russnettle/events{/privacy}","received_events_url":"https://api.github.com/users/russnettle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-05T08:56:17Z","updated_at":"2018-08-06T20:33:06Z","closed_at":null,"author_association":"NONE","body":"Hey -  I wonder if someone can help clarify if this is possible...\r\n\r\nI am using HTML tags to style my text with a custom XMLStyler  and this is working fine for something similar to:\r\n`<strong>Some text</strong><a href=\"https://www.website.com>link</a>\"`\r\nhowever the html I am styling is coming through with links embedded within tags such as \r\n`<strong>Some text <a href=\"https://www.website.com>link</a></strong>\"`\r\nI am able to add styles to the embedded link, however the link is not tappable.\r\n\r\nMy styler looks like : \r\n\r\n```swift\r\nclass HTMLStyler: XMLStyler {\r\nvar body = StringStyle(\r\n            .font(UIFont(titillium: weight, size: 14)),\r\n            .color(.red),\r\n            .lineSpacing(-3),\r\n            .paragraphSpacingAfter(14)\r\n        )\r\nfunc style(forElement name: String, attributes: [String: String], currentStyle: StringStyle) -> StringStyle? {\r\n switch name {\r\n case \"strong\":\r\n                let bolder = body.byAdding(\r\n                    .xmlRules([\r\n                        .style(\"em\", body.byAdding(.font(UIFont(boldFont: .boldItalic, size: 14))))\r\n                    ])\r\n                )\r\n                return bolder\r\ncase \"a\":\r\n                guard let href = attributes[\"href\"],\r\n                    let url = URL(string: href) else {\r\n                        return body\r\n                }\r\n                \r\n                return body.byAdding(.link(url))\r\n            default:\r\n                return body\r\n            }\r\n }\r\n```\r\n\r\nThe problem I have is that the strong tag is picked up for the styling and returns the style before the 'a'  tag, which means the .link(url) is not attached\r\n\r\nIs there a way to get around this? maybe triggering a new styler  somehow in the xml rules for the parent tag?\r\n```swift\r\n     case \"strong\":\r\n                let bolder = body.byAdding(\r\n                    .xmlRules([\r\n                        .style(\"em\", body.byAdding(.font(UIFont(boldFont: .boldItalic, size: 14)))),\r\n//awesome method here to pass link attributes to new styler and return styled actionable link here?\r\n\r\n                    ])\r\n                )\r\n                return bolder\r\n```\r\nI have been stuck on this for a while and the only way I can think to get around it if it doesn't work is to manually parse the string and close off the HTML tag prior to styling - which I would really like to avoid\r\n\r\nThanks so much - great framework that does everything else that I need "},"comment":{"url":"https://api.github.com/repos/Raizlabs/BonMot/issues/comments/410843955","html_url":"https://github.com/Raizlabs/BonMot/issues/346#issuecomment-410843955","issue_url":"https://api.github.com/repos/Raizlabs/BonMot/issues/346","id":410843955,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDg0Mzk1NQ==","user":{"login":"russnettle","id":5123908,"node_id":"MDQ6VXNlcjUxMjM5MDg=","avatar_url":"https://avatars0.githubusercontent.com/u/5123908?v=4","gravatar_id":"","url":"https://api.github.com/users/russnettle","html_url":"https://github.com/russnettle","followers_url":"https://api.github.com/users/russnettle/followers","following_url":"https://api.github.com/users/russnettle/following{/other_user}","gists_url":"https://api.github.com/users/russnettle/gists{/gist_id}","starred_url":"https://api.github.com/users/russnettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russnettle/subscriptions","organizations_url":"https://api.github.com/users/russnettle/orgs","repos_url":"https://api.github.com/users/russnettle/repos","events_url":"https://api.github.com/users/russnettle/events{/privacy}","received_events_url":"https://api.github.com/users/russnettle/received_events","type":"User","site_admin":false},"created_at":"2018-08-06T20:33:06Z","updated_at":"2018-08-06T20:33:06Z","author_association":"NONE","body":"Thanks @ZevEisenberg appreciate it - I am currently looking to have to write reg ex to parse the html and close / reopen any styling tags around link before it hits the styler. I wondered if I was just missing something in BonMot that would get around this ? "}}
{"actor":{"display_login":"russnettle"}}