{"action":"opened","issue":{"url":"https://api.github.com/repos/thephpleague/html-to-markdown/issues/72","labels_url":"https://api.github.com/repos/thephpleague/html-to-markdown/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/html-to-markdown/issues/72/comments","events_url":"https://api.github.com/repos/thephpleague/html-to-markdown/issues/72/events","html_url":"https://github.com/thephpleague/html-to-markdown/issues/72","id":115293824,"number":72,"title":"Use an intermediate AST","user":{"login":"colinodell","id":202034,"avatar_url":"https://avatars.githubusercontent.com/u/202034?v=3","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},"labels":[{"url":"https://api.github.com/repos/thephpleague/html-to-markdown/labels/commonmark-compatibility","name":"commonmark-compatibility","color":"207de5"},{"url":"https://api.github.com/repos/thephpleague/html-to-markdown/labels/feature%20request","name":"feature request","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"colinodell","id":202034,"avatar_url":"https://avatars.githubusercontent.com/u/202034?v=3","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},"milestone":null,"comments":0,"created_at":"2015-11-05T14:25:10Z","updated_at":"2015-11-05T14:25:10Z","closed_at":null,"body":"Some of the issues being reported are caused by (or related to) one of the following:\r\n\r\n1. Converting HTML directly to a string\r\n2. Not doing a great job of tracking element depth\r\n3. Storing the resulting MD in the DOM tree\r\n\r\nWe'll need a major revamp of the codebase to address the issues that these things cause.  I therefore propose implementing an AST as an intermediate conversion step, similar to how league/commonmark works.\r\n\r\nSo basically as we traverse the DOM tree, we simultaneously build an AST which mirrors it (using the same Nodes and sub-classes from league/commonmark).  This part should be fairly straight-forward.  Once the AST is build, we pass that along to renderers which convert that AST representation into the final markdown.\r\n\r\nIn the long term, perhaps we could eventually merge the two codebases into a single library, which would be awesome!  (This wouldn't be done for at least two major versions though)"}}