{"action":"created","issue":{"url":"https://api.github.com/repos/moovweb/gokogiri/issues/83","labels_url":"https://api.github.com/repos/moovweb/gokogiri/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/moovweb/gokogiri/issues/83/comments","events_url":"https://api.github.com/repos/moovweb/gokogiri/issues/83/events","html_url":"https://github.com/moovweb/gokogiri/issues/83","id":74158970,"number":83,"title":"Trim surrounding whitespace for Node.Content()","user":{"login":"aggrolite","id":546036,"avatar_url":"https://avatars.githubusercontent.com/u/546036?v=3","gravatar_id":"","url":"https://api.github.com/users/aggrolite","html_url":"https://github.com/aggrolite","followers_url":"https://api.github.com/users/aggrolite/followers","following_url":"https://api.github.com/users/aggrolite/following{/other_user}","gists_url":"https://api.github.com/users/aggrolite/gists{/gist_id}","starred_url":"https://api.github.com/users/aggrolite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aggrolite/subscriptions","organizations_url":"https://api.github.com/users/aggrolite/orgs","repos_url":"https://api.github.com/users/aggrolite/repos","events_url":"https://api.github.com/users/aggrolite/events{/privacy}","received_events_url":"https://api.github.com/users/aggrolite/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-07T23:15:26Z","updated_at":"2015-05-08T02:20:33Z","closed_at":null,"body":"Hi,\r\n\r\nDoes gokogiri currently support trimming leading and trailing whitespace from a `Node`'s `Content` (text content) before it is returned?\r\n\r\nFor example, I've used a Perl library in the past that allows me to do something like `$node->as_text` and `$node->as_trimmed_text`. The latter function automatically removes surrounding whitespace (`s/^\\s*|\\s*$/`) before returning the node's text content.\r\n\r\nIf this desired behavior is not currently built in, I would happily provide a patch. For example, a new field for `type Node` could be introduced, say `ContentTrimmed`.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/moovweb/gokogiri/issues/comments/100076650","html_url":"https://github.com/moovweb/gokogiri/issues/83#issuecomment-100076650","issue_url":"https://api.github.com/repos/moovweb/gokogiri/issues/83","id":100076650,"user":{"login":"jbowtie","id":40857,"avatar_url":"https://avatars.githubusercontent.com/u/40857?v=3","gravatar_id":"","url":"https://api.github.com/users/jbowtie","html_url":"https://github.com/jbowtie","followers_url":"https://api.github.com/users/jbowtie/followers","following_url":"https://api.github.com/users/jbowtie/following{/other_user}","gists_url":"https://api.github.com/users/jbowtie/gists{/gist_id}","starred_url":"https://api.github.com/users/jbowtie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbowtie/subscriptions","organizations_url":"https://api.github.com/users/jbowtie/orgs","repos_url":"https://api.github.com/users/jbowtie/repos","events_url":"https://api.github.com/users/jbowtie/events{/privacy}","received_events_url":"https://api.github.com/users/jbowtie/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T02:20:33Z","updated_at":"2015-05-08T02:20:33Z","body":"You're better off simply calling `strings.TrimSpace` on the returned content unless you want to fight with XML whitespace rules and the idiosyncrasies of node aggregation. For example, do you still want to trim if an element is marked `xml:space=\"preserve\"`, or when dealing with CDATA nodes?\r\n\r\nYou have to particularly careful when dealing with mixed content document formats like HTML or DOCX - leading or trailing whitespace is generally significant and can cause issues if you try and strip it out. That's why XSLT forces you to use the `normalize-space` function instead of conveniently doing it for you."}}