{"action":"created","comment":{"url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/comments/73976821","id":73976821,"diff_hunk":"@@ -58,4 +58,20 @@\n      * @return options defined in document.\r\n      */\r\n     Map<Object, Object> getOptions();\r\n+\r\n+    /**\r\n+     * Gets the current counter with the given name and increases its value.\r\n+     * @param name\r\n+     * @return\r\n+     */\r\n+    int getCounter(String name);\r","path":"asciidoctorj-core/src/main/java/org/asciidoctor/ast/Document.java","position":10,"original_position":10,"commit_id":"66769ccd9c147c203f3240957bf5dba2d8244a77","original_commit_id":"66769ccd9c147c203f3240957bf5dba2d8244a77","user":{"login":"mojavelinux","id":79351,"avatar_url":"https://avatars.githubusercontent.com/u/79351?v=3","gravatar_id":"","url":"https://api.github.com/users/mojavelinux","html_url":"https://github.com/mojavelinux","followers_url":"https://api.github.com/users/mojavelinux/followers","following_url":"https://api.github.com/users/mojavelinux/following{/other_user}","gists_url":"https://api.github.com/users/mojavelinux/gists{/gist_id}","starred_url":"https://api.github.com/users/mojavelinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mojavelinux/subscriptions","organizations_url":"https://api.github.com/users/mojavelinux/orgs","repos_url":"https://api.github.com/users/mojavelinux/repos","events_url":"https://api.github.com/users/mojavelinux/events{/privacy}","received_events_url":"https://api.github.com/users/mojavelinux/received_events","type":"User","site_admin":false},"body":"I think these methods should be named getAndIncrementCounter so we clearly communicate that this is a mutable operation.","created_at":"2016-08-08T23:45:54Z","updated_at":"2016-08-08T23:45:54Z","html_url":"https://github.com/asciidoctor/asciidoctorj/pull/493#discussion_r73976821","pull_request_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493","_links":{"self":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/comments/73976821"},"html":{"href":"https://github.com/asciidoctor/asciidoctorj/pull/493#discussion_r73976821"},"pull_request":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493"}}},"pull_request":{"url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493","id":78574717,"html_url":"https://github.com/asciidoctor/asciidoctorj/pull/493","diff_url":"https://github.com/asciidoctor/asciidoctorj/pull/493.diff","patch_url":"https://github.com/asciidoctor/asciidoctorj/pull/493.patch","issue_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/493","number":493,"state":"open","locked":false,"title":"Added method Document.getCounter. Interaction with using counters in …","user":{"login":"robertpanzer","id":1163662,"avatar_url":"https://avatars.githubusercontent.com/u/1163662?v=3","gravatar_id":"","url":"https://api.github.com/users/robertpanzer","html_url":"https://github.com/robertpanzer","followers_url":"https://api.github.com/users/robertpanzer/followers","following_url":"https://api.github.com/users/robertpanzer/following{/other_user}","gists_url":"https://api.github.com/users/robertpanzer/gists{/gist_id}","starred_url":"https://api.github.com/users/robertpanzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertpanzer/subscriptions","organizations_url":"https://api.github.com/users/robertpanzer/orgs","repos_url":"https://api.github.com/users/robertpanzer/repos","events_url":"https://api.github.com/users/robertpanzer/events{/privacy}","received_events_url":"https://api.github.com/users/robertpanzer/received_events","type":"User","site_admin":false},"body":"…the Document not possible yet\r\n\r\nFixes #488.\r\n\r\nAdded methods `Document.getCounter(counterName)` and `Document.getCounter(counterName, initialValue)` to the API.\r\n\r\nThe interaction with using the {counter:mycounter} macro is not possible though.\r\n\r\nIf I've understood it correctly the counters are finally stored in an attribute having the name of the counter on the Document.\r\nAll Document attributes are restored after for example BlockMacros are called in Document#parse.\r\nThe counter macro however is invoked in the conversion phase by the Substitutor after the attributes have been reset. Therefore the counter restarts at 1 again.\r\n\r\nThe first test reflects this behavior.\r\n\r\nWith a TreeProcessor it works a bit better in so far as the document can continue using the counters as the reset happens before the invocation of the Treeprocessors.\r\nBut I'd guess that when having a counter in the document, then reusing the same counter in a TreeProcessor will result in the counter sequence 2, 1.\r\n\r\nWhen using counters both in a processor and the document, I think it would be better to make the processor insert the text `{counter:foocounter}` instead of invoking the method on the Document.\r\n\r\nTo wrap it up I wonder if it makes sense at all to invoke this API from an extension and if it has already been used by Ruby extensions.\r\n(Maybe I completely missed a point, that's also perfectly possible)","created_at":"2016-07-23T15:32:12Z","updated_at":"2016-08-08T23:45:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b63693a367c626c16470bfa1e56aa0d4af27e874","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493/commits","review_comments_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493/comments","review_comment_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/comments{/number}","comments_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/493/comments","statuses_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/statuses/66769ccd9c147c203f3240957bf5dba2d8244a77","head":{"label":"robertpanzer:counter_api","ref":"counter_api","sha":"66769ccd9c147c203f3240957bf5dba2d8244a77","user":{"login":"robertpanzer","id":1163662,"avatar_url":"https://avatars.githubusercontent.com/u/1163662?v=3","gravatar_id":"","url":"https://api.github.com/users/robertpanzer","html_url":"https://github.com/robertpanzer","followers_url":"https://api.github.com/users/robertpanzer/followers","following_url":"https://api.github.com/users/robertpanzer/following{/other_user}","gists_url":"https://api.github.com/users/robertpanzer/gists{/gist_id}","starred_url":"https://api.github.com/users/robertpanzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertpanzer/subscriptions","organizations_url":"https://api.github.com/users/robertpanzer/orgs","repos_url":"https://api.github.com/users/robertpanzer/repos","events_url":"https://api.github.com/users/robertpanzer/events{/privacy}","received_events_url":"https://api.github.com/users/robertpanzer/received_events","type":"User","site_admin":false},"repo":{"id":27998582,"name":"asciidoctorj","full_name":"robertpanzer/asciidoctorj","owner":{"login":"robertpanzer","id":1163662,"avatar_url":"https://avatars.githubusercontent.com/u/1163662?v=3","gravatar_id":"","url":"https://api.github.com/users/robertpanzer","html_url":"https://github.com/robertpanzer","followers_url":"https://api.github.com/users/robertpanzer/followers","following_url":"https://api.github.com/users/robertpanzer/following{/other_user}","gists_url":"https://api.github.com/users/robertpanzer/gists{/gist_id}","starred_url":"https://api.github.com/users/robertpanzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertpanzer/subscriptions","organizations_url":"https://api.github.com/users/robertpanzer/orgs","repos_url":"https://api.github.com/users/robertpanzer/repos","events_url":"https://api.github.com/users/robertpanzer/events{/privacy}","received_events_url":"https://api.github.com/users/robertpanzer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robertpanzer/asciidoctorj","description":"Java bindings for Asciidoctor. Asciidoctor on the JVM!","fork":true,"url":"https://api.github.com/repos/robertpanzer/asciidoctorj","forks_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/forks","keys_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/teams","hooks_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/hooks","issue_events_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/issues/events{/number}","events_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/events","assignees_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/assignees{/user}","branches_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/branches{/branch}","tags_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/tags","blobs_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/git/refs{/sha}","trees_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/statuses/{sha}","languages_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/languages","stargazers_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/stargazers","contributors_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/contributors","subscribers_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/subscribers","subscription_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/subscription","commits_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/commits{/sha}","git_commits_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/git/commits{/sha}","comments_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/comments{/number}","issue_comment_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/issues/comments{/number}","contents_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/contents/{+path}","compare_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/merges","archive_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/downloads","issues_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/issues{/number}","pulls_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/pulls{/number}","milestones_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/milestones{/number}","notifications_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/labels{/name}","releases_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/releases{/id}","deployments_url":"https://api.github.com/repos/robertpanzer/asciidoctorj/deployments","created_at":"2014-12-14T15:33:22Z","updated_at":"2015-05-05T14:13:31Z","pushed_at":"2016-07-29T13:03:02Z","git_url":"git://github.com/robertpanzer/asciidoctorj.git","ssh_url":"git@github.com:robertpanzer/asciidoctorj.git","clone_url":"https://github.com/robertpanzer/asciidoctorj.git","svn_url":"https://github.com/robertpanzer/asciidoctorj","homepage":"http://asciidoctor.org","size":2443,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"asciidoctor:asciidoctorj-1.6.0","ref":"asciidoctorj-1.6.0","sha":"fc02f3314e6bd548d3926394bc198d4b0e1c2e44","user":{"login":"asciidoctor","id":3137042,"avatar_url":"https://avatars.githubusercontent.com/u/3137042?v=3","gravatar_id":"","url":"https://api.github.com/users/asciidoctor","html_url":"https://github.com/asciidoctor","followers_url":"https://api.github.com/users/asciidoctor/followers","following_url":"https://api.github.com/users/asciidoctor/following{/other_user}","gists_url":"https://api.github.com/users/asciidoctor/gists{/gist_id}","starred_url":"https://api.github.com/users/asciidoctor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asciidoctor/subscriptions","organizations_url":"https://api.github.com/users/asciidoctor/orgs","repos_url":"https://api.github.com/users/asciidoctor/repos","events_url":"https://api.github.com/users/asciidoctor/events{/privacy}","received_events_url":"https://api.github.com/users/asciidoctor/received_events","type":"Organization","site_admin":false},"repo":{"id":8862411,"name":"asciidoctorj","full_name":"asciidoctor/asciidoctorj","owner":{"login":"asciidoctor","id":3137042,"avatar_url":"https://avatars.githubusercontent.com/u/3137042?v=3","gravatar_id":"","url":"https://api.github.com/users/asciidoctor","html_url":"https://github.com/asciidoctor","followers_url":"https://api.github.com/users/asciidoctor/followers","following_url":"https://api.github.com/users/asciidoctor/following{/other_user}","gists_url":"https://api.github.com/users/asciidoctor/gists{/gist_id}","starred_url":"https://api.github.com/users/asciidoctor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asciidoctor/subscriptions","organizations_url":"https://api.github.com/users/asciidoctor/orgs","repos_url":"https://api.github.com/users/asciidoctor/repos","events_url":"https://api.github.com/users/asciidoctor/events{/privacy}","received_events_url":"https://api.github.com/users/asciidoctor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/asciidoctor/asciidoctorj","description":":coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!","fork":false,"url":"https://api.github.com/repos/asciidoctor/asciidoctorj","forks_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/forks","keys_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/teams","hooks_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/hooks","issue_events_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/events{/number}","events_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/events","assignees_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/assignees{/user}","branches_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/branches{/branch}","tags_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/tags","blobs_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/git/refs{/sha}","trees_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/statuses/{sha}","languages_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/languages","stargazers_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/stargazers","contributors_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/contributors","subscribers_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/subscribers","subscription_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/subscription","commits_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/commits{/sha}","git_commits_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/git/commits{/sha}","comments_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/comments{/number}","issue_comment_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/comments{/number}","contents_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/contents/{+path}","compare_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/merges","archive_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/downloads","issues_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues{/number}","pulls_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls{/number}","milestones_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/milestones{/number}","notifications_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/labels{/name}","releases_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/releases{/id}","deployments_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/deployments","created_at":"2013-03-18T19:36:27Z","updated_at":"2016-08-04T23:16:09Z","pushed_at":"2016-08-03T06:47:07Z","git_url":"git://github.com/asciidoctor/asciidoctorj.git","ssh_url":"git@github.com:asciidoctor/asciidoctorj.git","clone_url":"https://github.com/asciidoctor/asciidoctorj.git","svn_url":"https://github.com/asciidoctor/asciidoctorj","homepage":"http://asciidoctor.org","size":2546,"stargazers_count":181,"watchers_count":181,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":74,"mirror_url":null,"open_issues_count":61,"forks":74,"open_issues":61,"watchers":181,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493"},"html":{"href":"https://github.com/asciidoctor/asciidoctorj/pull/493"},"issue":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/493"},"comments":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/493/comments"},"review_comments":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493/comments"},"review_comment":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/pulls/493/commits"},"statuses":{"href":"https://api.github.com/repos/asciidoctor/asciidoctorj/statuses/66769ccd9c147c203f3240957bf5dba2d8244a77"}}}}
{"actor":{"display_login":"mojavelinux"}}