{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/commonmark/issues/257","repository_url":"https://api.github.com/repos/thephpleague/commonmark","labels_url":"https://api.github.com/repos/thephpleague/commonmark/issues/257/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/commonmark/issues/257/comments","events_url":"https://api.github.com/repos/thephpleague/commonmark/issues/257/events","html_url":"https://github.com/thephpleague/commonmark/issues/257","id":167507543,"node_id":"MDU6SXNzdWUxNjc1MDc1NDM=","number":257,"title":"Usage question: How to implement more robust parsers?","user":{"login":"okdana","id":122095,"node_id":"MDQ6VXNlcjEyMjA5NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/122095?v=4","gravatar_id":"","url":"https://api.github.com/users/okdana","html_url":"https://github.com/okdana","followers_url":"https://api.github.com/users/okdana/followers","following_url":"https://api.github.com/users/okdana/following{/other_user}","gists_url":"https://api.github.com/users/okdana/gists{/gist_id}","starred_url":"https://api.github.com/users/okdana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okdana/subscriptions","organizations_url":"https://api.github.com/users/okdana/orgs","repos_url":"https://api.github.com/users/okdana/repos","events_url":"https://api.github.com/users/okdana/events{/privacy}","received_events_url":"https://api.github.com/users/okdana/received_events","type":"User","site_admin":false},"labels":[{"id":127602079,"node_id":"MDU6TGFiZWwxMjc2MDIwNzk=","url":"https://api.github.com/repos/thephpleague/commonmark/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-26T02:25:42Z","updated_at":"2018-09-18T12:57:45Z","closed_at":"2018-09-18T12:57:45Z","author_association":"NONE","body":"Hello!\n\nI'm trying to extend CommonMark, just for simple things like auto-linking ticket numbers and user names. I found the [Twitter handle example](http://commonmark.thephpleague.com/customization/inline-parsing/#example-1---twitter-handles), and it's conceptually very similar to what i need to do — just look for a special character, make sure the following characters meet some very simple requirements, and then replace the text by a hyperlink.\n\nUnfortunately the example is very naïve. For one thing, the parser will try to link handles that occur inside of hyperlinks:\n\n``` markdown\nThis is [a @twitter handle](/test) inside a hyperlink.\n```\n\nbecomes\n\n``` html\n<p>This is <a href=\"/test\">a <a href=\"https://twitter.com/twitter\">@twitter</a> handle</a> inside a hyperlink.</p>\n```\n\nAdditionally, because the parser requires the `@` character to be preceded by a space, Twitter handles won't be linked inside of another in-line element if it's the first character (e.g., `*@twitter*` won't work, but `*foo @twitter bar*` will).\n\nBecause i based my own parsers on this example, they have all of the same limitations. :/\n\nWhen i first saw the `getContainer()` method in the docs my immediate thought was that maybe you could use it to prevent issues like this, like your `TwitterHandleParser` could call `getContainer()` to see whether it's inside of a link or emphasis or whatever and act accordingly. But i guess it's not like that — with the way parsers work it doesn't seem there's any way to know what the _immediate_ container of a character is, just the nearest block container. Is that right?\n\nI was looking through the code trying to figure out a solution and i noticed that emphasis is handled differently from most other in-line elements, in that it uses `DelimiterStack`. I haven't so far been able to figure out exactly what it does for you though. Can it provide more robust behaviour in situations like these? If so, can you expand on how it works? If not, do you know how else one might solve the problem?\n\nThank you!\n"},"comment":{"url":"https://api.github.com/repos/thephpleague/commonmark/issues/comments/422382531","html_url":"https://github.com/thephpleague/commonmark/issues/257#issuecomment-422382531","issue_url":"https://api.github.com/repos/thephpleague/commonmark/issues/257","id":422382531,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjM4MjUzMQ==","user":{"login":"colinodell","id":202034,"node_id":"MDQ6VXNlcjIwMjAzNA==","avatar_url":"https://avatars1.githubusercontent.com/u/202034?v=4","gravatar_id":"","url":"https://api.github.com/users/colinodell","html_url":"https://github.com/colinodell","followers_url":"https://api.github.com/users/colinodell/followers","following_url":"https://api.github.com/users/colinodell/following{/other_user}","gists_url":"https://api.github.com/users/colinodell/gists{/gist_id}","starred_url":"https://api.github.com/users/colinodell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinodell/subscriptions","organizations_url":"https://api.github.com/users/colinodell/orgs","repos_url":"https://api.github.com/users/colinodell/repos","events_url":"https://api.github.com/users/colinodell/events{/privacy}","received_events_url":"https://api.github.com/users/colinodell/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T12:57:45Z","updated_at":"2018-09-18T12:57:45Z","author_association":"MEMBER","body":"Closing due to inactivity."}}
{"actor":{"display_login":"colinodell"}}