{"action":"created","issue":{"url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/31","repository_url":"https://api.github.com/repos/iabudiab/HTMLKit","labels_url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/31/comments","events_url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/31/events","html_url":"https://github.com/iabudiab/HTMLKit/issues/31","id":322034818,"number":31,"title":"Plain text?","user":{"login":"guidedways","id":202437,"avatar_url":"https://avatars2.githubusercontent.com/u/202437?v=4","gravatar_id":"","url":"https://api.github.com/users/guidedways","html_url":"https://github.com/guidedways","followers_url":"https://api.github.com/users/guidedways/followers","following_url":"https://api.github.com/users/guidedways/following{/other_user}","gists_url":"https://api.github.com/users/guidedways/gists{/gist_id}","starred_url":"https://api.github.com/users/guidedways/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidedways/subscriptions","organizations_url":"https://api.github.com/users/guidedways/orgs","repos_url":"https://api.github.com/users/guidedways/repos","events_url":"https://api.github.com/users/guidedways/events{/privacy}","received_events_url":"https://api.github.com/users/guidedways/received_events","type":"User","site_admin":false},"labels":[{"id":303219227,"url":"https://api.github.com/repos/iabudiab/HTMLKit/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-10T18:30:28Z","updated_at":"2018-05-10T20:34:48Z","closed_at":null,"author_association":"NONE","body":"This looks like a powerful library to navigate around HTML nodes, however what would be the simplest method of obtaining cleaned up 'plain text' from HTML input? I'd like it to preserve any 'invalid' non-html tags such as `John Do <john@do.com>` and not try and parse it as `NSAttributedString`'s `initWithHTML` does."},"comment":{"url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/comments/388177205","html_url":"https://github.com/iabudiab/HTMLKit/issues/31#issuecomment-388177205","issue_url":"https://api.github.com/repos/iabudiab/HTMLKit/issues/31","id":388177205,"user":{"login":"iabudiab","id":5612057,"avatar_url":"https://avatars3.githubusercontent.com/u/5612057?v=4","gravatar_id":"","url":"https://api.github.com/users/iabudiab","html_url":"https://github.com/iabudiab","followers_url":"https://api.github.com/users/iabudiab/followers","following_url":"https://api.github.com/users/iabudiab/following{/other_user}","gists_url":"https://api.github.com/users/iabudiab/gists{/gist_id}","starred_url":"https://api.github.com/users/iabudiab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iabudiab/subscriptions","organizations_url":"https://api.github.com/users/iabudiab/orgs","repos_url":"https://api.github.com/users/iabudiab/repos","events_url":"https://api.github.com/users/iabudiab/events{/privacy}","received_events_url":"https://api.github.com/users/iabudiab/received_events","type":"User","site_admin":false},"created_at":"2018-05-10T20:34:48Z","updated_at":"2018-05-10T20:34:48Z","author_association":"OWNER","body":"@guidedways Hey there. Let me see if I understood you correctly.\r\n\r\nYou want to input a HTML string and have all _HTML_ tags stripped, as in `This is an <b>email</b>: John Do <john@do.com>` should return `This is an email: John Do <john@do.com>`?\r\n\r\nIf so, then the easiest way to do it, is to escape all HTML reserved characters to prevent interpreting them as HTML. In your case:\r\n\r\n```swift\r\nlet element: HTMLElement = HTMLElement(tagName: \"div\")\r\nelement.innerHTML = \"This is an <b>email</b>: John Do &lt;john@do.com&gt;\"\r\nprint(\"\\(element.textContent)\")\r\n// This is an email: John Do <john@do.com>\r\n```\r\n\r\n### Some Details\r\n\r\n`innerHTML` in `HTMLKit` behaves like it would in a browser, i.e. it sets the HTML content of an element to the string that is passed. The string is then interpreted as a HTML fragment and is parsed inside the element as its parent context.\r\n\r\nWhat does it mean? Well, your input gets parsed to this DOM:\r\n\r\n```\r\n<div>This is an  <b>email</b>: John Do <john@do.com></john@do.com></div>\r\n```\r\n\r\nTake a look here for more info: [MDN Element.innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)\r\n\r\n**Does this answer you question? Do you have any followup questions?**\r\n"}}
{"actor":{"display_login":"iabudiab"}}