{"action":"closed","issue":{"url":"https://api.github.com/repos/reinderien/mimic/issues/2","labels_url":"https://api.github.com/repos/reinderien/mimic/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/reinderien/mimic/issues/2/comments","events_url":"https://api.github.com/repos/reinderien/mimic/issues/2/events","html_url":"https://github.com/reinderien/mimic/issues/2","id":112191728,"number":2,"title":"Context-aware replacement algorithms that preserve syntax colouring","user":{"login":"KarolS","id":1790750,"avatar_url":"https://avatars.githubusercontent.com/u/1790750?v=3","gravatar_id":"","url":"https://api.github.com/users/KarolS","html_url":"https://github.com/KarolS","followers_url":"https://api.github.com/users/KarolS/followers","following_url":"https://api.github.com/users/KarolS/following{/other_user}","gists_url":"https://api.github.com/users/KarolS/gists{/gist_id}","starred_url":"https://api.github.com/users/KarolS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarolS/subscriptions","organizations_url":"https://api.github.com/users/KarolS/orgs","repos_url":"https://api.github.com/users/KarolS/repos","events_url":"https://api.github.com/users/KarolS/events{/privacy}","received_events_url":"https://api.github.com/users/KarolS/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-19T17:18:02Z","updated_at":"2015-10-19T19:52:52Z","closed_at":"2015-10-19T19:52:52Z","body":"Consider the following example:\r\n\r\n```python\r\ndef add_prefix(s):\r\n    return \"prefix\" + s #comment\r\n```\r\n\r\nRunning it through mimic would create code that looks totally different under syntax colouring:\r\n\r\n```python\r\ndеf add_prefix(ѕ):\r\n    rеturn ＂prefix\" + s #comment\r\n```\r\n\r\nAnother similar example is given in the current README.\r\n\r\n A context-aware algorithm would:\r\n\r\n* preserve keywords (`def` and `return` in this case)\r\n\r\n* preserve quotation marks\r\n\r\n* preserve parentheses\r\n\r\n* preserve symbols in contexts, in which they cannot be replaced by a homograph\r\n\r\nso that most editors would display the code with identical colours.\r\n\r\nIn the example above, the only tokens eligible for mangling would be identifiers (`add_prefix` and `s`), comment contents and contents of the string constant."}}