{"action":"opened","number":35,"pull_request":{"url":"https://api.github.com/repos/rstudio/htmltools/pulls/35","id":54065424,"html_url":"https://github.com/rstudio/htmltools/pull/35","diff_url":"https://github.com/rstudio/htmltools/pull/35.diff","patch_url":"https://github.com/rstudio/htmltools/pull/35.patch","issue_url":"https://api.github.com/repos/rstudio/htmltools/issues/35","number":35,"state":"open","locked":false,"title":"Don't put newlines around inline tags","user":{"login":"wch","id":86978,"avatar_url":"https://avatars.githubusercontent.com/u/86978?v=3","gravatar_id":"","url":"https://api.github.com/users/wch","html_url":"https://github.com/wch","followers_url":"https://api.github.com/users/wch/followers","following_url":"https://api.github.com/users/wch/following{/other_user}","gists_url":"https://api.github.com/users/wch/gists{/gist_id}","starred_url":"https://api.github.com/users/wch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wch/subscriptions","organizations_url":"https://api.github.com/users/wch/orgs","repos_url":"https://api.github.com/users/wch/repos","events_url":"https://api.github.com/users/wch/events{/privacy}","received_events_url":"https://api.github.com/users/wch/received_events","type":"User","site_admin":false},"body":"Fixes #19. This PR isn't ready yet but I wanted to put it up for some discussion before doing more on it.\r\n\r\nOne unequivocally good thing is that I switched from `readLines` to `readChar`, which improves performance a LOT when there are long lines. (I've run into this when serializing long JSON strings. Good thing we have nice profiling tools now :). For example, running this code with master vs. this branch:\r\n\r\n```R\r\nsizes <- round(runif(1e2, 1000, 100000))\r\nstrings <- lapply(sizes, function(size) {\r\n  paste0(\r\n    sample(c(letters, LETTERS), size, replace = TRUE),\r\n    collapse = \"\"\r\n  )\r\n})\r\n\r\ntag <- do.call(div, strings)\r\n\r\nsystem.time({\r\n  as.character(tag)\r\n})\r\n\r\n# master:\r\n#    user  system elapsed \r\n#   0.560   0.000   0.562 \r\n\r\n# New code:\r\n#    user  system elapsed \r\n#   0.176   0.004   0.188 \r\n```\r\n\r\nIf the strings are very short, there's no noticeable performance difference.\r\n\r\n\r\nThe next part is the actual change in output. The current changes satisfy a bunch of tests (at the end of this post) but introduces some possibly undesirable behavior. For example, consider the following:\r\n\r\n```R\r\nas.character(span(\"a\", \"b\"))\r\n```\r\n\r\nOn master, this renders as:\r\n\r\n```html\r\n<span>\r\n  a\r\n  b\r\n</span>\r\n```\r\n\r\nOn this branch, it renders as:\r\n\r\n```html\r\n<span>ab</span>\r\n```\r\n\r\nI would say in general that this is desirable, except for the fact that it could change the appearance of HTML from existing code that's out there. So we need to decide if that's what we really want to do.\r\n\r\nBecause of changes like this, the current PR breaks a lot of existing tests.\r\n\r\nThis PR does pass the following (not yet committed) tests:\r\n\r\n```R\r\n# Convert tag object to plain character string\r\ntextify <- function(x) {\r\n  renderTags(x)$html[1]\r\n}\r\n\r\nexpect_identical(\r\ntextify(div(\"x\")),\r\n\"<div>x</div>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(span(\"x\")),\r\n\"<span>x</span>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(div(span(\"x\"))),\r\n\"<div>\r\n  <span>x</span>\r\n</div>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(span(div(\"x\"))),\r\n\"<span>\r\n  <div>x</div>\r\n</span>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(div(div(\"x\"))),\r\n\"<div>\r\n  <div>x</div>\r\n</div>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(span(span(\"x\"))),\r\n\"<span><span>x</span></span>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(div(span(\"x\"), span(\"x\"))),\r\n\"<div>\r\n  <span>x</span><span>x</span>\r\n</div>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(span(div(\"x\"), span(\"x\"), span(\"x\"))),\r\n\"<span>\r\n  <div>x</div>\r\n  <span>x</span><span>x</span>\r\n</span>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(span(span(\"x\"), div(\"x\"), span(\"x\"))),\r\n\"<span><span>x</span>\r\n  <div>x</div>\r\n  <span>x</span>\r\n</span>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(div(span(\"x\"), div(\"x\"), span(\"x\"))),\r\n\"<div>\r\n  <span>x</span>\r\n  <div>x</div>\r\n  <span>x</span>\r\n</div>\"\r\n)\r\n\r\nexpect_identical(\r\ntextify(div(span(\"x\", div(\"x\")))),\r\n\"<div>\r\n  <span>x\r\n    <div>x</div>\r\n  </span>\r\n</div>\"\r\n)\r\n```\r\n","created_at":"2015-12-18T05:02:44Z","updated_at":"2015-12-18T05:02:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rstudio/htmltools/pulls/35/commits","review_comments_url":"https://api.github.com/repos/rstudio/htmltools/pulls/35/comments","review_comment_url":"https://api.github.com/repos/rstudio/htmltools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rstudio/htmltools/issues/35/comments","statuses_url":"https://api.github.com/repos/rstudio/htmltools/statuses/cea06a102347e51293dad020e6474ecf41fee567","head":{"label":"rstudio:inline-tags","ref":"inline-tags","sha":"cea06a102347e51293dad020e6474ecf41fee567","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":18398793,"name":"htmltools","full_name":"rstudio/htmltools","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/htmltools","description":"","fork":false,"url":"https://api.github.com/repos/rstudio/htmltools","forks_url":"https://api.github.com/repos/rstudio/htmltools/forks","keys_url":"https://api.github.com/repos/rstudio/htmltools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/htmltools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/htmltools/teams","hooks_url":"https://api.github.com/repos/rstudio/htmltools/hooks","issue_events_url":"https://api.github.com/repos/rstudio/htmltools/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/htmltools/events","assignees_url":"https://api.github.com/repos/rstudio/htmltools/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/htmltools/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/htmltools/tags","blobs_url":"https://api.github.com/repos/rstudio/htmltools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/htmltools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/htmltools/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/htmltools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/htmltools/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/htmltools/languages","stargazers_url":"https://api.github.com/repos/rstudio/htmltools/stargazers","contributors_url":"https://api.github.com/repos/rstudio/htmltools/contributors","subscribers_url":"https://api.github.com/repos/rstudio/htmltools/subscribers","subscription_url":"https://api.github.com/repos/rstudio/htmltools/subscription","commits_url":"https://api.github.com/repos/rstudio/htmltools/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/htmltools/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/htmltools/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/htmltools/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/htmltools/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/htmltools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/htmltools/merges","archive_url":"https://api.github.com/repos/rstudio/htmltools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/htmltools/downloads","issues_url":"https://api.github.com/repos/rstudio/htmltools/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/htmltools/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/htmltools/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/htmltools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/htmltools/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/htmltools/releases{/id}","created_at":"2014-04-03T10:11:03Z","updated_at":"2015-08-04T03:53:31Z","pushed_at":"2015-12-18T04:39:01Z","git_url":"git://github.com/rstudio/htmltools.git","ssh_url":"git@github.com:rstudio/htmltools.git","clone_url":"https://github.com/rstudio/htmltools.git","svn_url":"https://github.com/rstudio/htmltools","homepage":null,"size":215,"stargazers_count":13,"watchers_count":13,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":9,"forks":9,"open_issues":9,"watchers":13,"default_branch":"master"}},"base":{"label":"rstudio:master","ref":"master","sha":"66348c672e4b56b2c4229e125f614c50ab16346f","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":18398793,"name":"htmltools","full_name":"rstudio/htmltools","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/htmltools","description":"","fork":false,"url":"https://api.github.com/repos/rstudio/htmltools","forks_url":"https://api.github.com/repos/rstudio/htmltools/forks","keys_url":"https://api.github.com/repos/rstudio/htmltools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/htmltools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/htmltools/teams","hooks_url":"https://api.github.com/repos/rstudio/htmltools/hooks","issue_events_url":"https://api.github.com/repos/rstudio/htmltools/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/htmltools/events","assignees_url":"https://api.github.com/repos/rstudio/htmltools/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/htmltools/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/htmltools/tags","blobs_url":"https://api.github.com/repos/rstudio/htmltools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/htmltools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/htmltools/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/htmltools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/htmltools/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/htmltools/languages","stargazers_url":"https://api.github.com/repos/rstudio/htmltools/stargazers","contributors_url":"https://api.github.com/repos/rstudio/htmltools/contributors","subscribers_url":"https://api.github.com/repos/rstudio/htmltools/subscribers","subscription_url":"https://api.github.com/repos/rstudio/htmltools/subscription","commits_url":"https://api.github.com/repos/rstudio/htmltools/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/htmltools/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/htmltools/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/htmltools/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/htmltools/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/htmltools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/htmltools/merges","archive_url":"https://api.github.com/repos/rstudio/htmltools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/htmltools/downloads","issues_url":"https://api.github.com/repos/rstudio/htmltools/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/htmltools/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/htmltools/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/htmltools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/htmltools/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/htmltools/releases{/id}","created_at":"2014-04-03T10:11:03Z","updated_at":"2015-08-04T03:53:31Z","pushed_at":"2015-12-18T04:39:01Z","git_url":"git://github.com/rstudio/htmltools.git","ssh_url":"git@github.com:rstudio/htmltools.git","clone_url":"https://github.com/rstudio/htmltools.git","svn_url":"https://github.com/rstudio/htmltools","homepage":null,"size":215,"stargazers_count":13,"watchers_count":13,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":9,"forks":9,"open_issues":9,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rstudio/htmltools/pulls/35"},"html":{"href":"https://github.com/rstudio/htmltools/pull/35"},"issue":{"href":"https://api.github.com/repos/rstudio/htmltools/issues/35"},"comments":{"href":"https://api.github.com/repos/rstudio/htmltools/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/rstudio/htmltools/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/rstudio/htmltools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rstudio/htmltools/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/rstudio/htmltools/statuses/cea06a102347e51293dad020e6474ecf41fee567"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":139,"deletions":61,"changed_files":1}}