Extend the parsing for glossary items

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
tipsen
Posts: 10
Joined: Mon Jul 02, 2007 10:11 am

Extend the parsing for glossary items

Post by tipsen »

I thought about extending the parsing for glossary items in the file Glossary.php but couldn't figure out how to modify the regular expression...

Glossary item:
IMAP = "Internet Message Access Protocol"

"IMAP server" is parsed correctly but "IMAP-server" is not parsed - I would like to allow for glossary items in the faq-entries to be followed by a hypen ("-") and still be parsed correctly and equipped with an explanation!

I think the function insertItemsIntoContent() from the file Glossary.php should be modified but can't figure out how to do it - can anybody help me out?
tipsen
Posts: 10
Joined: Mon Jul 02, 2007 10:11 am

Extended parsing of glossary/dictionary items

Post by tipsen »

I've modified the file .\inc\Glossary.php - more specifically the function insertItemsIntoContent(), line 129:

// c. the glossary item could be everywhere as a distinct word
.'(\s+)('.$item['item'].')\b' // <-- new line
//.'(\s+)('.$item['item'].')(\s+)' <-- old line

I read about the regular expression syntax on this page:

http://dk.php.net/manual/en/reference.p ... syntax.php

And tried using a word boundary {\b} instead of a white space character class {(\s+)}- notice a word boundary can't be used inside a character class!

Result is that the following instances of FAQ are also matched:
FAQ-...
FAQ. ....
FAQ, ...
FAQ's ...

Regards, Tommy Ipsen
Post Reply