{"action":"created","comment":{"url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/comments/32577872","id":32577872,"diff_hunk":"@@ -1,11 +1,274 @@\n 'use strict';\n-var parser = require('./generated-parser.js');\n+\n var escapeHtml = require('escape-html');\n+var beautify = require('./beautify.js');\n+var Tokenizer = require('./tokenizer.js');\n+var Emitter = require('./emitter.js')\n \n-exports.list = function (ecmarkdown) {\n-    return parser.parse(ecmarkdown.trim() + '\\n', { startRule: 'list' });\n+exports.document = function (ecmarkdown) {\n+  return beautify(Emitter.document(parse(ecmarkdown)));\n };\n \n+exports.list = exports.document;\n+\n exports.fragment = function (ecmarkdown) {\n-    return parser.parse(escapeHtml(ecmarkdown.trim()), { startRule: 'fragment' });\n+  return beautify(Emitter.fragment(parse(escapeHtml(ecmarkdown))));\n };\n+\n+\n+// Ecmarkdown is parsed according to the following:\n+// * A document is composed of multiple paragraphs (parseDocument)\n+// * A paragraph can be either a list or non-list (parseParagraph)\n+//   * A list is composed of many list items. Each list item is a segment (parseList & parseListItem)\n+//   * A non-list is a segment (parseNonList)\n+// * A segment is a list of chars (literal text) and formats (*, |, etc.) (parseSegment)\n+// * formats are also a segment\n+//\n+// The `contents` property of a chars node is a string. In all other nodes, it's an array.\n+function parse(emd) {","path":"lib/ecmarkdown.js","position":32,"original_position":32,"commit_id":"6708a377758234b4b7b7eb21caa601db300eee33","original_commit_id":"6708a377758234b4b7b7eb21caa601db300eee33","user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"body":"Maybe move everything here into a `parse.js`?","created_at":"2015-06-16T22:17:49Z","updated_at":"2015-06-16T22:17:49Z","html_url":"https://github.com/domenic/ecmarkdown/pull/22#discussion_r32577872","pull_request_url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/comments/32577872"},"html":{"href":"https://github.com/domenic/ecmarkdown/pull/22#discussion_r32577872"},"pull_request":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22","id":34517152,"html_url":"https://github.com/domenic/ecmarkdown/pull/22","diff_url":"https://github.com/domenic/ecmarkdown/pull/22.diff","patch_url":"https://github.com/domenic/ecmarkdown/pull/22.patch","issue_url":"https://api.github.com/repos/domenic/ecmarkdown/issues/22","number":22,"state":"open","locked":false,"title":"Hand-written parser","user":{"login":"bterlson","id":11236,"avatar_url":"https://avatars.githubusercontent.com/u/11236?v=3","gravatar_id":"","url":"https://api.github.com/users/bterlson","html_url":"https://github.com/bterlson","followers_url":"https://api.github.com/users/bterlson/followers","following_url":"https://api.github.com/users/bterlson/following{/other_user}","gists_url":"https://api.github.com/users/bterlson/gists{/gist_id}","starred_url":"https://api.github.com/users/bterlson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bterlson/subscriptions","organizations_url":"https://api.github.com/users/bterlson/orgs","repos_url":"https://api.github.com/users/bterlson/repos","events_url":"https://api.github.com/users/bterlson/events{/privacy}","received_events_url":"https://api.github.com/users/bterlson/received_events","type":"User","site_admin":false},"body":"Haven't really vetted this hard except to confirm it's significantly faster for me. I expect there to be some minor issues and perhaps major feedback on the implementation so I'm starting a PR :)\r\n\r\nSemantic delta vs. the old parser:\r\n\r\n1. Comments in lists are handled differently.\r\n2. Some minor bug fix (see test output)\r\n3. Nesting is supported for some formats (perhaps not necessary now but seemed like a capability we might want in the future)\r\n4. Support for documents rather than paragraphs. Documents are 0 or more paragraphs, where paragraphs can be either text or lists. The API has a breaking change that reflects this change (`list` replaced with `document`). Fragment remains.\r\n\r\nLMK any thoughts. I'm not an expert at parsers so I may be making obvious mistakes. Obviously I have decided to eschew comments for now to preserve this implementation's mysterious yet oddly compelling appeal ;)","created_at":"2015-05-01T02:09:58Z","updated_at":"2015-06-16T22:17:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4beef1cfd69f91463ff152b90c3042b47ff8677","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22/commits","review_comments_url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22/comments","review_comment_url":"https://api.github.com/repos/domenic/ecmarkdown/pulls/comments{/number}","comments_url":"https://api.github.com/repos/domenic/ecmarkdown/issues/22/comments","statuses_url":"https://api.github.com/repos/domenic/ecmarkdown/statuses/6708a377758234b4b7b7eb21caa601db300eee33","head":{"label":"bterlson:master","ref":"master","sha":"6708a377758234b4b7b7eb21caa601db300eee33","user":{"login":"bterlson","id":11236,"avatar_url":"https://avatars.githubusercontent.com/u/11236?v=3","gravatar_id":"","url":"https://api.github.com/users/bterlson","html_url":"https://github.com/bterlson","followers_url":"https://api.github.com/users/bterlson/followers","following_url":"https://api.github.com/users/bterlson/following{/other_user}","gists_url":"https://api.github.com/users/bterlson/gists{/gist_id}","starred_url":"https://api.github.com/users/bterlson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bterlson/subscriptions","organizations_url":"https://api.github.com/users/bterlson/orgs","repos_url":"https://api.github.com/users/bterlson/repos","events_url":"https://api.github.com/users/bterlson/events{/privacy}","received_events_url":"https://api.github.com/users/bterlson/received_events","type":"User","site_admin":false},"repo":{"id":34885774,"name":"ecmarkdown","full_name":"bterlson/ecmarkdown","owner":{"login":"bterlson","id":11236,"avatar_url":"https://avatars.githubusercontent.com/u/11236?v=3","gravatar_id":"","url":"https://api.github.com/users/bterlson","html_url":"https://github.com/bterlson","followers_url":"https://api.github.com/users/bterlson/followers","following_url":"https://api.github.com/users/bterlson/following{/other_user}","gists_url":"https://api.github.com/users/bterlson/gists{/gist_id}","starred_url":"https://api.github.com/users/bterlson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bterlson/subscriptions","organizations_url":"https://api.github.com/users/bterlson/orgs","repos_url":"https://api.github.com/users/bterlson/repos","events_url":"https://api.github.com/users/bterlson/events{/privacy}","received_events_url":"https://api.github.com/users/bterlson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bterlson/ecmarkdown","description":"A shorthand language for writing ECMAScript-style algorithms, inspired by Markdown","fork":true,"url":"https://api.github.com/repos/bterlson/ecmarkdown","forks_url":"https://api.github.com/repos/bterlson/ecmarkdown/forks","keys_url":"https://api.github.com/repos/bterlson/ecmarkdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bterlson/ecmarkdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bterlson/ecmarkdown/teams","hooks_url":"https://api.github.com/repos/bterlson/ecmarkdown/hooks","issue_events_url":"https://api.github.com/repos/bterlson/ecmarkdown/issues/events{/number}","events_url":"https://api.github.com/repos/bterlson/ecmarkdown/events","assignees_url":"https://api.github.com/repos/bterlson/ecmarkdown/assignees{/user}","branches_url":"https://api.github.com/repos/bterlson/ecmarkdown/branches{/branch}","tags_url":"https://api.github.com/repos/bterlson/ecmarkdown/tags","blobs_url":"https://api.github.com/repos/bterlson/ecmarkdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bterlson/ecmarkdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bterlson/ecmarkdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/bterlson/ecmarkdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bterlson/ecmarkdown/statuses/{sha}","languages_url":"https://api.github.com/repos/bterlson/ecmarkdown/languages","stargazers_url":"https://api.github.com/repos/bterlson/ecmarkdown/stargazers","contributors_url":"https://api.github.com/repos/bterlson/ecmarkdown/contributors","subscribers_url":"https://api.github.com/repos/bterlson/ecmarkdown/subscribers","subscription_url":"https://api.github.com/repos/bterlson/ecmarkdown/subscription","commits_url":"https://api.github.com/repos/bterlson/ecmarkdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/bterlson/ecmarkdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/bterlson/ecmarkdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/bterlson/ecmarkdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/bterlson/ecmarkdown/contents/{+path}","compare_url":"https://api.github.com/repos/bterlson/ecmarkdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bterlson/ecmarkdown/merges","archive_url":"https://api.github.com/repos/bterlson/ecmarkdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bterlson/ecmarkdown/downloads","issues_url":"https://api.github.com/repos/bterlson/ecmarkdown/issues{/number}","pulls_url":"https://api.github.com/repos/bterlson/ecmarkdown/pulls{/number}","milestones_url":"https://api.github.com/repos/bterlson/ecmarkdown/milestones{/number}","notifications_url":"https://api.github.com/repos/bterlson/ecmarkdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bterlson/ecmarkdown/labels{/name}","releases_url":"https://api.github.com/repos/bterlson/ecmarkdown/releases{/id}","created_at":"2015-05-01T01:57:08Z","updated_at":"2015-05-01T01:57:30Z","pushed_at":"2015-06-16T00:54:13Z","git_url":"git://github.com/bterlson/ecmarkdown.git","ssh_url":"git@github.com:bterlson/ecmarkdown.git","clone_url":"https://github.com/bterlson/ecmarkdown.git","svn_url":"https://github.com/bterlson/ecmarkdown","homepage":null,"size":133,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"domenic:master","ref":"master","sha":"397fd2436fea962a43f5b2e91d936795272d81cc","user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"repo":{"id":23796186,"name":"ecmarkdown","full_name":"domenic/ecmarkdown","owner":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/domenic/ecmarkdown","description":"A shorthand language for writing ECMAScript-style algorithms, inspired by Markdown","fork":false,"url":"https://api.github.com/repos/domenic/ecmarkdown","forks_url":"https://api.github.com/repos/domenic/ecmarkdown/forks","keys_url":"https://api.github.com/repos/domenic/ecmarkdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/domenic/ecmarkdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/domenic/ecmarkdown/teams","hooks_url":"https://api.github.com/repos/domenic/ecmarkdown/hooks","issue_events_url":"https://api.github.com/repos/domenic/ecmarkdown/issues/events{/number}","events_url":"https://api.github.com/repos/domenic/ecmarkdown/events","assignees_url":"https://api.github.com/repos/domenic/ecmarkdown/assignees{/user}","branches_url":"https://api.github.com/repos/domenic/ecmarkdown/branches{/branch}","tags_url":"https://api.github.com/repos/domenic/ecmarkdown/tags","blobs_url":"https://api.github.com/repos/domenic/ecmarkdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/domenic/ecmarkdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/domenic/ecmarkdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/domenic/ecmarkdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/domenic/ecmarkdown/statuses/{sha}","languages_url":"https://api.github.com/repos/domenic/ecmarkdown/languages","stargazers_url":"https://api.github.com/repos/domenic/ecmarkdown/stargazers","contributors_url":"https://api.github.com/repos/domenic/ecmarkdown/contributors","subscribers_url":"https://api.github.com/repos/domenic/ecmarkdown/subscribers","subscription_url":"https://api.github.com/repos/domenic/ecmarkdown/subscription","commits_url":"https://api.github.com/repos/domenic/ecmarkdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/domenic/ecmarkdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/domenic/ecmarkdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/domenic/ecmarkdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/domenic/ecmarkdown/contents/{+path}","compare_url":"https://api.github.com/repos/domenic/ecmarkdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/domenic/ecmarkdown/merges","archive_url":"https://api.github.com/repos/domenic/ecmarkdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/domenic/ecmarkdown/downloads","issues_url":"https://api.github.com/repos/domenic/ecmarkdown/issues{/number}","pulls_url":"https://api.github.com/repos/domenic/ecmarkdown/pulls{/number}","milestones_url":"https://api.github.com/repos/domenic/ecmarkdown/milestones{/number}","notifications_url":"https://api.github.com/repos/domenic/ecmarkdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/domenic/ecmarkdown/labels{/name}","releases_url":"https://api.github.com/repos/domenic/ecmarkdown/releases{/id}","created_at":"2014-09-08T15:24:19Z","updated_at":"2015-04-10T20:55:01Z","pushed_at":"2015-06-16T00:54:13Z","git_url":"git://github.com/domenic/ecmarkdown.git","ssh_url":"git@github.com:domenic/ecmarkdown.git","clone_url":"https://github.com/domenic/ecmarkdown.git","svn_url":"https://github.com/domenic/ecmarkdown","homepage":null,"size":388,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22"},"html":{"href":"https://github.com/domenic/ecmarkdown/pull/22"},"issue":{"href":"https://api.github.com/repos/domenic/ecmarkdown/issues/22"},"comments":{"href":"https://api.github.com/repos/domenic/ecmarkdown/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/domenic/ecmarkdown/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/domenic/ecmarkdown/statuses/6708a377758234b4b7b7eb21caa601db300eee33"}}}}