简体   繁体   中英

PHP simple markdown parser to generate List from contents

as we know we have simple editor on wikipedia website and we can make list from content easily for example:

in my text i have this formatted text:

===aaa=== <--- heading one
aaaaaaaaaaaaaaaaaa

====bbb==== <--- child of heading one
bbbbbbbbbbbbbbbbbb

===ccc==== <--- heading two
cccccccccccccccccc

====ddd==== <--- child of heading two as three
dddddddddddddddddd

=====eee==== <--- child of heading three
eeeeeeeeeeeeeeeeee

wikipedia can generate that to:

<ol>
    <li>aaa
        <ol>
            <li>bbb</li>
        </ol>
    </li>
    <li>ccc
        <ol>
            <li>ddd
                <ol>eee</ol>
            </li>
        </ol>
    </li>
</ol>

now i would like to implementing that like with wikipedia , as far its difficult for me to understand how can i implementing that can any body help me to resolve this problem? thanks in advance

You'll have the best luck finding a 3rd party package that support markdown parsing and rendering. Here are some good examples:

https://github.com/GrahamCampbell/Laravel-Markdown

https://github.com/thephpleague/commonmark

https://github.com/erusev/parsedown

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM