{"action":"created","issue":{"url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/69","labels_url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/69/comments","events_url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/69/events","html_url":"https://github.com/CouscousPHP/Couscous/pull/69","id":52588129,"number":69,"title":"Table of contents extracted from Markdown documents","user":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CouscousPHP/Couscous/labels/enhancement","name":"enhancement","color":"bfe5bf"}],"state":"open","locked":false,"assignee":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2014-12-21T06:43:17Z","updated_at":"2015-02-08T20:45:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CouscousPHP/Couscous/pulls/69","html_url":"https://github.com/CouscousPHP/Couscous/pull/69","diff_url":"https://github.com/CouscousPHP/Couscous/pull/69.diff","patch_url":"https://github.com/CouscousPHP/Couscous/pull/69.patch"},"body":"A new step extracts a table of contents from Markdown documents (list of headers) and makes it available as file metadata. Uses the latest changes in [commonmark](https://github.com/thephpleague/commonmark) (we end up with 2 Markdown parser because this one doesn't support Markdown Extra).\r\n\r\nWith this new step, we now have this metadata available in Twig layouts:\r\n\r\n```twig\r\n<h1>{{ tableOfContents.title }}</h1>\r\n<p>\r\n    Table of contents:\r\n</p>\r\n<ul>\r\n    {% for header in tableOfContents.getHeaders(2) %}\r\n        <li>{{ header }}</li>\r\n    {% endfor %}\r\n</ul>\r\n```\r\n\r\nAPI of `tableOfContents`:\r\n\r\n- `title`: the title of the current document (i.e. header of level 1)\r\n- `getHeaders($level)`: returns the list of headers (`string[]`)\r\n\r\nTODO:\r\n\r\n- [ ] Documentation\r\n- [x] Require a stable dependency in `composer.json` (i.e. wait for a new release of [commonmark](https://github.com/thephpleague/commonmark))\r\n- [x] ~~Should the metadata key be `document` instead of `tableOfContents`?~~ (no)\r\n- [ ] The headers list should be indexed by the header `id` (so that we can link to it). The problem is that I'm not sure CommonMark doesn't support Markdown Extra (which allows to define headers ID), and what if headers IDs are not defined? Related to #39\r\n- [ ] waiting for a new stable release now that thephpleague/commonmark#38 is fixed"},"comment":{"url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/comments/73430693","html_url":"https://github.com/CouscousPHP/Couscous/pull/69#issuecomment-73430693","issue_url":"https://api.github.com/repos/CouscousPHP/Couscous/issues/69","id":73430693,"user":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"created_at":"2015-02-08T20:45:33Z","updated_at":"2015-02-08T20:45:33Z","body":"@wysow yep I've tried a few times already but this is quite a challenge honestly.\r\n\r\nAlso, I had a look at https://github.com/dshafik/markua and about Markua itself and it looks quite cool! The good thing is that Markua *seems* to include all Markdown Extra, + a few features like the \"asides\" that are the just perfect for writing documentation (which makes a lot of sense since Markua has been invented for Leanpub for writing books…).\r\n\r\nSo my POV is let's use Markua instead, which would cover both Markdown and Markdown Extra. That means contributing to https://github.com/dshafik/markua to implement missing features (actually the main things we need are tables and headers IDs). If that project is not maintain anymore, we can also fork it to our organization…\r\n\r\nWhat do you think? If you want to have a look into that you are most welcome, honestly I was a bit lost with the API of CommonMark…"}}