[Xerte-dev] FW: Xenith/XOT Glossary regexps
Julian Tenney
Julian.Tenney at nottingham.ac.uk
Mon Oct 15 15:10:57 BST 2012
Just forwarding this to the list for everyone's info: Fay can use it in the Xenith code, I'm not sure if I can integrate it into engine as this is (I guess) javascript and not the actionscript RegExp engine (although the expressions should work in both...). I'll try..
-----Original Message-----
From: Smith, John [mailto:J.J.Smith at gcu.ac.uk]
Sent: 14 October 2012 17:26
To: julian.tenney at nottingham.ac.uk; Fay.Cross at nottingham.ac.uk; ronm at mitchellmedia.co.uk; reijnders at tor.nl
Subject: Xenith/XOT Glossary regexps
Importance: High
Hi guys,
Great to meet you all and I've been looking through the xenith code to see where I can contribute. Also, have been looking through the archives and came across the regexp problem for the glossary. Since i'm only today on the list proper not sure whether a reply will go through to the correct place so sending to you all to see if it helps...
Not sure whether this has been fixed yet but it seems the problem is partly caused by /b requiring a word boundary and there being no word boundary on the very first word. Also, seem to remember somewhere that /b can in some cases match international characters in the middle of words which might not be the desired effect...
I have changed the regexp to this "\sTERM[^\s]*|^TERM[^\s]*" in the xenith.js code as so:
// function makes every glossary word found into a link function insertGlossaryTag(node) {
var temp = node.nodeValue;
for (var k=0; k<glossary.length; k++) {
// ** see recent emails on list about regular expression stuff **
//var regExp = new RegExp(" " + glossary[k].word + " ", "ig");
var regExp = new RegExp('\\s' + glossary[k].word + '[^\\s]*|^' + glossary[k].word + '[^\\s]*', 'gi');
temp = temp.replace(regExp, ' <a class="glossary" href="#" title="' + glossary[k].definition + '">' + glossary[k].word + '</a> ');
}
node.nodeValue = temp;
}
and now it seems to match all the words, no matter where they are and irrespective of spaces. See attached screenshots - you can see there are no spaces before any words and only some have a space after. Probably needs further testing to go into xot though...
Will start adding to the list soon...
Regards,
John Smith | Learning Technologist
Room A251, Govan Mbeki Building | School of Health & Life Sciences | Glasgow Caledonian University Cowcaddens Road | Glasgow | G4 0BA
Glasgow Caledonian University is a registered Scottish charity, number SC021474
Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009.
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
Winner: Times Higher Education’s Outstanding Support for Early Career Researchers of the Year 2010, GCU as a lead with Universities Scotland partners.
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,15691,en.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glossary.png
Type: image/png
Size: 44903 bytes
Desc: glossary.png
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121015/acfcc280/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glossary2.png
Type: image/png
Size: 55972 bytes
Desc: glossary2.png
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121015/acfcc280/attachment-0003.png>
More information about the Xerte-dev
mailing list