Max Tsepkov
2011-Oct-26 22:04 UTC
Object-oriented PHP implementation is coming, looking for parties
Hello, list. My name is Max, I'm a web developer. I found Markdown convention very useful, I use it everywhere nowadays. Michel Fortin's markdown-php seems to be the only available PHP implementation. And, judging by number of people using it, it works well :) But there is many thing that's keep it from being perfect: * One large file with functions not being sorted in a logical way. It makes it hard to understand how it works. * Despite the fact that it contains classes, it isn't coded object-oriented. Which greatly affect, again, clarity and re-usability. * Script is coded in early ages of PHP, doesn't make use of its new features and uses obsolete ones. * It's written much like a Python program. PHP doesn't work that way. To give Markdown in PHP a new look, I've designed a library, which I named markdown-oo-php oo-php stands for object-oriented php. It's designed to be easy to use and extend. There is two components Text and Filter. Text is an entity user works with, it represents text being processed. E.g.: echo new Markdown_Text($plaintext); Filter is a superclass and set of specific filters which does actual parsing. Each specific filter is an object which transforms a single markdown element to xhtml. Examples of filters are: Markdown_Filter_Hr, Markdown_Filter_Linebreak, Markdown_Filter_ListBulleted. When user wants to transform markdown these filters are running one by one resulting to html. By default, one more special filter is run. It will pass given text to original Markdown.pl 1.0.1 This way we get parsed markdown even if some filters are not implemented yet. This feature requires perl, of course. It can be disabled: Markdown_Filter::useFallbackFilter(false); Such design allows users to write their own filters, hook into the process, write plugins etc. We can compose any chain of filters resulting into different versions, extra features and other goodies. You can find source along with documentation at GitHub: https://github.com/garygolden/markdown-oo-php You're most welcome to comment, contribute and, of course, spread the word. cheers ;) -- Max Tsepkov (a.k.a. Gary Golden) A freelancing web engineer http://www.garygolden.me
Alan Hogan
2011-Oct-26 22:29 UTC
Object-oriented PHP implementation is coming, looking for parties
Michel is awesome and so is PHP Markdown (Extra). The only problem I know about is that certain, very long documents will fail completely. IIRC, this was a side-effect of its PCRE parsing ? a bug or limitation of the regex implementation in PHP. Max, are you using a grammar, as has been discussed on this list recently, or regexes? That is, might your parser be susceptible to the same bug? Alan Hogan On Oct 26, 2011, at 3:04 PM, Max Tsepkov wrote:> Hello, list. > My name is Max, I'm a web developer. > > I found Markdown convention very useful, I use it everywhere nowadays. > Michel Fortin's markdown-php seems to be the only available PHP implementation. > And, judging by number of people using it, it works well :) > > But there is many thing that's keep it from being perfect: > > * One large file with functions not being sorted in a logical way. > It makes it hard to understand how it works. > * Despite the fact that it contains classes, it isn't coded > object-oriented. Which greatly affect, again, clarity and > re-usability. > * Script is coded in early ages of PHP, doesn't make use of its new > features and uses obsolete ones. > * It's written much like a Python program. PHP doesn't work that way. > > > To give Markdown in PHP a new look, I've designed a library, which I > named markdown-oo-php > oo-php stands for object-oriented php. It's designed to be easy to use > and extend. > > There is two components Text and Filter. > Text is an entity user works with, it represents text being processed. E.g.: > > echo new Markdown_Text($plaintext); > > Filter is a superclass and set of specific filters which does actual parsing. > Each specific filter is an object which transforms a single markdown > element to xhtml. > Examples of filters are: Markdown_Filter_Hr, > Markdown_Filter_Linebreak, Markdown_Filter_ListBulleted. > > When user wants to transform markdown these filters are running one by > one resulting to html. > By default, one more special filter is run. It will pass given text to > original Markdown.pl 1.0.1 > This way we get parsed markdown even if some filters are not implemented yet. > This feature requires perl, of course. It can be disabled: > > Markdown_Filter::useFallbackFilter(false); > > Such design allows users to write their own filters, hook into the > process, write plugins etc. > We can compose any chain of filters resulting into different versions, > extra features and other goodies. > > You can find source along with documentation at GitHub: > https://github.com/garygolden/markdown-oo-php > > You're most welcome to comment, contribute and, of course, spread the word. > > cheers ;) > > -- > Max Tsepkov (a.k.a. Gary Golden) > A freelancing web engineer > http://www.garygolden.me > _______________________________________________ > Markdown-Discuss mailing list > Markdown-Discuss at six.pairlist.net > http://six.pairlist.net/mailman/listinfo/markdown-discuss-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20111026/3f5c6451/attachment.html>