wolfpet / kitchen

Open Source Threaded Discussion project
6 stars 3 forks source link

ENH: Implement BB code parser in PHP #2

Closed iamranger closed 9 years ago

iamranger commented 9 years ago

Rationale: C code is complex, and hard to extend or maintain.

A somewhat spirited attempt to do this was made in func.php - see bbcode_format() function. Unfortunately, this code fails on larger messages due to poorly written regular expressions that deal with images and URLs.

Use this text to test the parser (courtesy of user nester):

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/1512807_1121676571191781_5947557411248636530_n.jpg?oh=e94c3ed015ab849f124123e3e6181132&oe=55CE1195] "Borislav Bereza: А пеньюар и стринги со стразиками у этого байкера лежали под косметикой? "

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/s720x720/11060012_1060869080593259_194878016738303321_n.jpg?oh=358a16ac93fa713127c31eaf16a2b717&oe=5597F156 ]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xtf1/v/t1.0-9/11008059_10153211623189675_2181594901055475590_n.jpg?oh=b6569962d04fca00ae514f4ebac2e0b8&oe=55D84369]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xfp1/v/t1.0-9/11188472_883607178347043_3842020112123079218_n.jpg?oh=724e3076ac1d9590d1db9562bc7af6c8&oe=55D75DA8]

[img=http://f.ptcdn.info/354/011/000/1382690312-GayBikers-o.jpg]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/11178290_838752912865795_3679088534349170178_n.jpg?oh=c97d04c149edf9351c0e4155e240a329&oe=55D78B39]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xaf1/v/t1.0-9/22429_884688901573193_280838852842772981_n.jpg?oh=a2072fb08e9d670932254013cd32331b&oe=55E52061]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/11133756_924728047580097_2445405144625191236_n.jpg?oh=c406ba7de2a4b2287a21b5f720ce2eb1&oe=55D60E06]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/s720x720/11110458_10153211711499675_8588228834684206101_n.jpg?oh=652e629761b1cdd34e01742387a67735&oe=559E40E3]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/11182255_1001107136581188_1904981970736315353_n.jpg?oh=97bdf5cecf6fbdd0632f4c61a8c7ba71&oe=55D5271C]

[img=https://scontent-lga.xx.fbcdn.net/hphotos-xtp1/v/t1.0-9/11110277_477377232419405_6774940781334030724_n.jpg?oh=e3cdbdf9de90539a3c1f4b8077d9635d&oe=55D39AA4] "Ночные волки" возвращаются в Москву после тщательного досмотра на границе ))

iamranger commented 9 years ago

Currently testing in production and everything is looking good.