cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get all headings for table of contents

Wulfheart opened this issue · comments

commented

Hello,

is it possible to get all headings from a string in an extension? I need this for autogenerating a table of contents.

Thank you in advance

There is an implementation of this in yii2-apidoc package:

https://github.com/yiisoft/yii2-apidoc/blob/e56aa1f065e4ece1a68b21de653b02ed0da2dadd/helpers/ApiMarkdown.php#L94-L121

could be useful to extract this into a trait and add it to this package. Happy to review and merge pull requests for this.

@cebe
Hi, I would like to contribute. How should I proceed?

@akshitagupta20 Hi, thanks for offering help. The solution would be a trait, that can be added to a custom markdown class:

<?php

class MyCustomMarkdown extends Markdown
{
     use HeadlineExtractionTrait;
// ..
}

HeadlineExtractionTrait should be a class from this repo and should contain the code similar to the one linked above, providing the collection of headlines as well as a getHeadlines() method.

Hope that is clear, feel free to ask more detailed question.

I am really new with Open-Source and I am very much interested in contributing not just cause of Hacktoberfest, so can you please further guide me how to solve this issue.
If you could spare some time, Es wäre eine große Hilfe.

@cebe
Hi, I would like to contribute. How should I proceed?

I already explained it above, please ask more concrete question.