{"action":"created","issue":{"url":"https://api.github.com/repos/yihui/knitr/issues/1049","labels_url":"https://api.github.com/repos/yihui/knitr/issues/1049/labels{/name}","comments_url":"https://api.github.com/repos/yihui/knitr/issues/1049/comments","events_url":"https://api.github.com/repos/yihui/knitr/issues/1049/events","html_url":"https://github.com/yihui/knitr/issues/1049","id":84573338,"number":1049,"title":"knitr markdown produces trailing whitespace for figures","user":{"login":"chiphogg","id":1819744,"avatar_url":"https://avatars.githubusercontent.com/u/1819744?v=3","gravatar_id":"","url":"https://api.github.com/users/chiphogg","html_url":"https://github.com/chiphogg","followers_url":"https://api.github.com/users/chiphogg/followers","following_url":"https://api.github.com/users/chiphogg/following{/other_user}","gists_url":"https://api.github.com/users/chiphogg/gists{/gist_id}","starred_url":"https://api.github.com/users/chiphogg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chiphogg/subscriptions","organizations_url":"https://api.github.com/users/chiphogg/orgs","repos_url":"https://api.github.com/users/chiphogg/repos","events_url":"https://api.github.com/users/chiphogg/events{/privacy}","received_events_url":"https://api.github.com/users/chiphogg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-03T13:46:42Z","updated_at":"2015-06-09T20:54:46Z","closed_at":null,"body":"When I write a `.Rmd` file, the resulting `.md` file has a space at the end of the line:\r\n\r\n`![plot of example](figure/example.png) `\r\n\r\nIt should have no space:\r\n\r\n`![plot of example](figure/example.png)`\r\n\r\n(Okay, apparently Github markdown strips the trailing space so that the above two examples look identical.  That's what I want you to do, too!  :)\r\n\r\nThis is mainly an aesthetic problem, but it also creates friction with some of the tools I use at work."},"comment":{"url":"https://api.github.com/repos/yihui/knitr/issues/comments/110501419","html_url":"https://github.com/yihui/knitr/issues/1049#issuecomment-110501419","issue_url":"https://api.github.com/repos/yihui/knitr/issues/1049","id":110501419,"user":{"login":"yihui","id":163582,"avatar_url":"https://avatars.githubusercontent.com/u/163582?v=3","gravatar_id":"","url":"https://api.github.com/users/yihui","html_url":"https://github.com/yihui","followers_url":"https://api.github.com/users/yihui/followers","following_url":"https://api.github.com/users/yihui/following{/other_user}","gists_url":"https://api.github.com/users/yihui/gists{/gist_id}","starred_url":"https://api.github.com/users/yihui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yihui/subscriptions","organizations_url":"https://api.github.com/users/yihui/orgs","repos_url":"https://api.github.com/users/yihui/repos","events_url":"https://api.github.com/users/yihui/events{/privacy}","received_events_url":"https://api.github.com/users/yihui/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T20:54:46Z","updated_at":"2015-06-09T20:54:46Z","body":"I'm a little surprised that this space can matter. Anyway, I might be able to fix it at some point, but not now. That said, I guess you can define a `plot` hook on top of the default hook to remove the space.\r\n\r\n```r\r\nlocal({\r\n  library(knitr)\r\n  hook_plot = knit_hooks$get('plot')\r\n  knit_hooks$set(plot = function(x, options) {\r\n    res = hook_plot(x, options)\r\n    gsub(' $', '', res)\r\n  })\r\n})\r\n```"}}