diff -Nur a21glossary-0.4.11/class.tx_a21glossary.php a21glossary/class.tx_a21glossary.php
--- a21glossary-0.4.11/class.tx_a21glossary.php 2010-02-08 17:11:45.000000000 +0100
+++ a21glossary/class.tx_a21glossary.php 2010-02-08 17:09:48.000000000 +0100
@@ -108,10 +108,24 @@
}
// replace all words except the content within tags
/* old version, does not work with characters >128 properly (e.g. german umlauts): $searchArray[] = '/'.'(?!<.*?)\b'.preg_quote($row['shortcut']?$row['shortcut']:$row['short'],'/').'\b(?![^<>]*?>)'.'/us'.$caseSensitive; */
+ // Check 700 characters only to prevent an hang-up of preg_replace(), if no `)');
+ $tempSearch = '(?<=\s|[[:punct:]])'.$this->a21quote($row['shortcut']?$row['shortcut']:$row['short'],'/').'(?=\s|[[:punct:]])';
if ($generateLink) { // if a link should be generated, then replace at this point only the words wich are already wrapped in a link (we make no nested links!)
- $searchArray[] = '/'.'(?!a21quote($row['shortcut']?$row['shortcut']:$row['short'],'/').'(?=\s|[[:punct:]])(?![^<>]*?>)(?=.*<\/a>)'.'/'.$caseSensitive.$PCREmodifiersLink;
+ $searchArray[] = '/'.$tempSearch
+ .'(?=[^>]*?<)' // Is inside an HTML tag?
+ .'(?='.PREG_NOT_A_TAG.'{0,'.PREG_MAX_CHARS.'}?' // Is an `'? Means that it is nested between `shortcut'
} else { // normal procedure: all words not within of tags, wich are divided by whitespace or punctuation signs will be replaced
- $searchArray[] = '/'.'(?!<.*?)(?<=\s|[[:punct:]])'.$this->a21quote($row['shortcut']?$row['shortcut']:$row['short'],'/').'(?=\s|[[:punct:]])(?![^<>]*?>)'.'/'.$caseSensitive.$PCREmodifiers;
+ $searchArray[] = '/'.$tempSearch
+ .'(?=[^>]*?<|$)' // Is inside an HTML tag?
+ .'/'.$caseSensitive.$PCREmodifiersLink;
}
// if the page language is identical with the language of the glossary word or is not defined at all, then the lang attribute will not be shown
// if the language of the word is defined and different to the current page language, then the lang attribute is added
@@ -138,8 +152,14 @@
$replaceArray[] = $result;
// if the record is marked to be linkable or the HTML element is configured to be linkable, then wrap the result in a link to
if ($generateLink) {
- // the same condition as above, additionally the word must not be wrapped in a link (?!.*<\/a>) - otherwise we would produce nested links
- $searchArray[] = '/'.'(?!a21quote($row['shortcut']?$row['shortcut']:$row['short'],'/').'(?=\s|[[:punct:]])(?![^<>]*?>)(?!.*<\/a>)/'.$caseSensitive.$PCREmodifiersLink;
+ $searchArray[] = '/'.$tempSearch
+ .'(?=[^>]*?<)' // Is inside an HTML tag?
+ .'(?='
+ .'('.PREG_NOT_A_END_TAG.'{'.PREG_MAX_CHARS.'}?)' // We are using a link if there is no `'
+ .'|('.PREG_NOT_A_END_TAG.'{0,'.PREG_MAX_CHARS.'}?' // Is an `' tags
+ .')'.'/'.$caseSensitive.$PCREmodifiersLink;
+
$replaceArray[] = $cObj->typolink($result,$conf['typolink.']);
}
}