{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/book/pulls/comments/115495294","pull_request_review_id":37036932,"id":115495294,"diff_hunk":"@@ -0,0 +1,70 @@\n+use std::io;\n+use std::io::{Read, Write};\n+\n+fn main () {\n+    let mut is_in_code_block = false;\n+    let mut is_in_inline_code = false;\n+    let mut is_in_html_tag = false;\n+\n+    let mut buffer = String::new();\n+    if let Err(e) = io::stdin().read_to_string(&mut buffer) {\n+        panic!(e);\n+    }\n+\n+    for line in buffer.lines() {\n+\n+        // check if inside code block\n+        if line.starts_with(\"```\") {\n+            is_in_code_block = !is_in_code_block;\n+        }\n+        if is_in_code_block {\n+            write!(io::stdout(), \"{}\\n\", line).unwrap();\n+        }\n+        else {\n+            let mut modified_line = &mut String::new();\n+            let mut previous_char = std::char::REPLACEMENT_CHARACTER;\n+            let mut chars_in_line = line.chars();\n+\n+            while let Some(possible_match) = chars_in_line.next() {\n+                let char_to_push;\n+                // check if inside inline code\n+                if possible_match == '`' {\n+                    is_in_inline_code = !is_in_inline_code;\n+                }\n+                // check if inside html tag\n+                if possible_match == '<' && !is_in_inline_code {\n+                    is_in_html_tag = true;\n+                }\n+                if possible_match == '>' {\n+                    is_in_html_tag = false;\n+                }\n+\n+                // replace with right/left apostrophe/quote\n+                if possible_match == '\\'' && !is_in_inline_code && !is_in_html_tag {\n+                    if previous_char.is_alphanumeric() || previous_char == '‘' {\n+                        char_to_push = '’';\n+                    }\n+                    else {\n+                        char_to_push = '‘';\n+                    }\n+                }\n+                else if possible_match == '\"'  && !is_in_inline_code && !is_in_html_tag {\n+                    if previous_char.is_alphanumeric() || previous_char == '“' {","path":"second-edition/tools/src/bin/convert_quotes.rs","position":52,"original_position":52,"commit_id":"1b1842d4d101aa76f6a15219be1b9653b97e1875","original_commit_id":"1b1842d4d101aa76f6a15219be1b9653b97e1875","user":{"login":"carols10cents","id":193874,"avatar_url":"https://avatars1.githubusercontent.com/u/193874?v=3","gravatar_id":"","url":"https://api.github.com/users/carols10cents","html_url":"https://github.com/carols10cents","followers_url":"https://api.github.com/users/carols10cents/followers","following_url":"https://api.github.com/users/carols10cents/following{/other_user}","gists_url":"https://api.github.com/users/carols10cents/gists{/gist_id}","starred_url":"https://api.github.com/users/carols10cents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carols10cents/subscriptions","organizations_url":"https://api.github.com/users/carols10cents/orgs","repos_url":"https://api.github.com/users/carols10cents/repos","events_url":"https://api.github.com/users/carols10cents/events{/privacy}","received_events_url":"https://api.github.com/users/carols10cents/received_events","type":"User","site_admin":false},"body":"Aha. I think I see the problem with the closing double quotes-- the ones that are incorrect have punctuation (`.`, `,`, `+`) just before the closing double quote, and punctuation isn't alphanumeric. What if we check for the previous character not being a space (and not being at the beginning of the line)? Could you try that and see if it fixes the places that aren't right and keeps the places that are right?","created_at":"2017-05-09T13:55:40Z","updated_at":"2017-05-09T13:55:40Z","html_url":"https://github.com/rust-lang/book/pull/654#discussion_r115495294","pull_request_url":"https://api.github.com/repos/rust-lang/book/pulls/654","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/book/pulls/comments/115495294"},"html":{"href":"https://github.com/rust-lang/book/pull/654#discussion_r115495294"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/book/pulls/654"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/book/pulls/654","id":118280989,"html_url":"https://github.com/rust-lang/book/pull/654","diff_url":"https://github.com/rust-lang/book/pull/654.diff","patch_url":"https://github.com/rust-lang/book/pull/654.patch","issue_url":"https://api.github.com/repos/rust-lang/book/issues/654","number":654,"state":"open","locked":false,"title":"Script to convert apostrophes and quotes to proper format in text files.","user":{"login":"lancelafontaine","id":1548285,"avatar_url":"https://avatars1.githubusercontent.com/u/1548285?v=3","gravatar_id":"","url":"https://api.github.com/users/lancelafontaine","html_url":"https://github.com/lancelafontaine","followers_url":"https://api.github.com/users/lancelafontaine/followers","following_url":"https://api.github.com/users/lancelafontaine/following{/other_user}","gists_url":"https://api.github.com/users/lancelafontaine/gists{/gist_id}","starred_url":"https://api.github.com/users/lancelafontaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lancelafontaine/subscriptions","organizations_url":"https://api.github.com/users/lancelafontaine/orgs","repos_url":"https://api.github.com/users/lancelafontaine/repos","events_url":"https://api.github.com/users/lancelafontaine/events{/privacy}","received_events_url":"https://api.github.com/users/lancelafontaine/received_events","type":"User","site_admin":false},"body":"Applied to all markdown files in `second-edition/nostarch` like this (:warning: overwrites original files :warning:):\r\n\r\n```\r\nfor f in ./second-edition/nostarch/**/*.md; do; cat \"$f\" | ./second-edition/target/debug/convert_quotes | tee \"$f\"; done;\r\n```\r\n\r\nAfter I had corrected a couple typos in the original markdown files (unclosed inline code blocks), I manually inspected the text content of all chapters + the diff, and everything looks good to me 👍 .\r\n\r\nThere were a few small issues with the original script, and after a few small tweaks, I've found that it seems to work well in all instances. If the script is applied and you notice some errors in the output, from what I've seen, it's most likely something wrong in the formatting of the file (check that all inline code & HTML tags are being closed).\r\n\r\nSince the apostrophes and quotes in HTML tags aren't being modified, all apostrophes in HTML comments throughout the files are also not being converted.\r\n\r\n","created_at":"2017-04-29T16:37:20Z","updated_at":"2017-05-09T13:55:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e776529dcb89a18156e9c72c7e16ac47331bc365","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/book/pulls/654/commits","review_comments_url":"https://api.github.com/repos/rust-lang/book/pulls/654/comments","review_comment_url":"https://api.github.com/repos/rust-lang/book/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/book/issues/654/comments","statuses_url":"https://api.github.com/repos/rust-lang/book/statuses/1b1842d4d101aa76f6a15219be1b9653b97e1875","head":{"label":"lancelafontaine:master","ref":"master","sha":"1b1842d4d101aa76f6a15219be1b9653b97e1875","user":{"login":"lancelafontaine","id":1548285,"avatar_url":"https://avatars1.githubusercontent.com/u/1548285?v=3","gravatar_id":"","url":"https://api.github.com/users/lancelafontaine","html_url":"https://github.com/lancelafontaine","followers_url":"https://api.github.com/users/lancelafontaine/followers","following_url":"https://api.github.com/users/lancelafontaine/following{/other_user}","gists_url":"https://api.github.com/users/lancelafontaine/gists{/gist_id}","starred_url":"https://api.github.com/users/lancelafontaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lancelafontaine/subscriptions","organizations_url":"https://api.github.com/users/lancelafontaine/orgs","repos_url":"https://api.github.com/users/lancelafontaine/repos","events_url":"https://api.github.com/users/lancelafontaine/events{/privacy}","received_events_url":"https://api.github.com/users/lancelafontaine/received_events","type":"User","site_admin":false},"repo":{"id":89661448,"name":"book","full_name":"lancelafontaine/book","owner":{"login":"lancelafontaine","id":1548285,"avatar_url":"https://avatars1.githubusercontent.com/u/1548285?v=3","gravatar_id":"","url":"https://api.github.com/users/lancelafontaine","html_url":"https://github.com/lancelafontaine","followers_url":"https://api.github.com/users/lancelafontaine/followers","following_url":"https://api.github.com/users/lancelafontaine/following{/other_user}","gists_url":"https://api.github.com/users/lancelafontaine/gists{/gist_id}","starred_url":"https://api.github.com/users/lancelafontaine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lancelafontaine/subscriptions","organizations_url":"https://api.github.com/users/lancelafontaine/orgs","repos_url":"https://api.github.com/users/lancelafontaine/repos","events_url":"https://api.github.com/users/lancelafontaine/events{/privacy}","received_events_url":"https://api.github.com/users/lancelafontaine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lancelafontaine/book","description":"The Rust Programming Language","fork":true,"url":"https://api.github.com/repos/lancelafontaine/book","forks_url":"https://api.github.com/repos/lancelafontaine/book/forks","keys_url":"https://api.github.com/repos/lancelafontaine/book/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lancelafontaine/book/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lancelafontaine/book/teams","hooks_url":"https://api.github.com/repos/lancelafontaine/book/hooks","issue_events_url":"https://api.github.com/repos/lancelafontaine/book/issues/events{/number}","events_url":"https://api.github.com/repos/lancelafontaine/book/events","assignees_url":"https://api.github.com/repos/lancelafontaine/book/assignees{/user}","branches_url":"https://api.github.com/repos/lancelafontaine/book/branches{/branch}","tags_url":"https://api.github.com/repos/lancelafontaine/book/tags","blobs_url":"https://api.github.com/repos/lancelafontaine/book/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lancelafontaine/book/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lancelafontaine/book/git/refs{/sha}","trees_url":"https://api.github.com/repos/lancelafontaine/book/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lancelafontaine/book/statuses/{sha}","languages_url":"https://api.github.com/repos/lancelafontaine/book/languages","stargazers_url":"https://api.github.com/repos/lancelafontaine/book/stargazers","contributors_url":"https://api.github.com/repos/lancelafontaine/book/contributors","subscribers_url":"https://api.github.com/repos/lancelafontaine/book/subscribers","subscription_url":"https://api.github.com/repos/lancelafontaine/book/subscription","commits_url":"https://api.github.com/repos/lancelafontaine/book/commits{/sha}","git_commits_url":"https://api.github.com/repos/lancelafontaine/book/git/commits{/sha}","comments_url":"https://api.github.com/repos/lancelafontaine/book/comments{/number}","issue_comment_url":"https://api.github.com/repos/lancelafontaine/book/issues/comments{/number}","contents_url":"https://api.github.com/repos/lancelafontaine/book/contents/{+path}","compare_url":"https://api.github.com/repos/lancelafontaine/book/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lancelafontaine/book/merges","archive_url":"https://api.github.com/repos/lancelafontaine/book/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lancelafontaine/book/downloads","issues_url":"https://api.github.com/repos/lancelafontaine/book/issues{/number}","pulls_url":"https://api.github.com/repos/lancelafontaine/book/pulls{/number}","milestones_url":"https://api.github.com/repos/lancelafontaine/book/milestones{/number}","notifications_url":"https://api.github.com/repos/lancelafontaine/book/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lancelafontaine/book/labels{/name}","releases_url":"https://api.github.com/repos/lancelafontaine/book/releases{/id}","deployments_url":"https://api.github.com/repos/lancelafontaine/book/deployments","created_at":"2017-04-28T02:56:26Z","updated_at":"2017-04-28T02:56:29Z","pushed_at":"2017-04-29T16:23:14Z","git_url":"git://github.com/lancelafontaine/book.git","ssh_url":"git@github.com:lancelafontaine/book.git","clone_url":"https://github.com/lancelafontaine/book.git","svn_url":"https://github.com/lancelafontaine/book","homepage":"http://rust-lang.github.io/book/","size":15593,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"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":"rust-lang:master","ref":"master","sha":"da7d1e9650e60fba1151675688d9245ac9e62e71","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars2.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":47854924,"name":"book","full_name":"rust-lang/book","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars2.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/book","description":"The Rust Programming Language","fork":false,"url":"https://api.github.com/repos/rust-lang/book","forks_url":"https://api.github.com/repos/rust-lang/book/forks","keys_url":"https://api.github.com/repos/rust-lang/book/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/book/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/book/teams","hooks_url":"https://api.github.com/repos/rust-lang/book/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/book/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/book/events","assignees_url":"https://api.github.com/repos/rust-lang/book/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/book/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/book/tags","blobs_url":"https://api.github.com/repos/rust-lang/book/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/book/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/book/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/book/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/book/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/book/languages","stargazers_url":"https://api.github.com/repos/rust-lang/book/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/book/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/book/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/book/subscription","commits_url":"https://api.github.com/repos/rust-lang/book/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/book/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/book/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/book/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/book/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/book/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/book/merges","archive_url":"https://api.github.com/repos/rust-lang/book/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/book/downloads","issues_url":"https://api.github.com/repos/rust-lang/book/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/book/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/book/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/book/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/book/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/book/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/book/deployments","created_at":"2015-12-11T22:49:49Z","updated_at":"2017-05-09T07:20:52Z","pushed_at":"2017-05-09T13:08:13Z","git_url":"git://github.com/rust-lang/book.git","ssh_url":"git@github.com:rust-lang/book.git","clone_url":"https://github.com/rust-lang/book.git","svn_url":"https://github.com/rust-lang/book","homepage":"https://doc.rust-lang.org/nightly/book/","size":17918,"stargazers_count":827,"watchers_count":827,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":215,"mirror_url":null,"open_issues_count":91,"forks":215,"open_issues":91,"watchers":827,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/book/pulls/654"},"html":{"href":"https://github.com/rust-lang/book/pull/654"},"issue":{"href":"https://api.github.com/repos/rust-lang/book/issues/654"},"comments":{"href":"https://api.github.com/repos/rust-lang/book/issues/654/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/book/pulls/654/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/book/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/book/pulls/654/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/book/statuses/1b1842d4d101aa76f6a15219be1b9653b97e1875"}}}}
{"actor":{"display_login":"carols10cents"}}