[Xerte-dev] Re: Glossary
Pat Lockley
patrick.lockley at googlemail.com
Fri Oct 5 11:25:33 BST 2012
ergh reg exp support over email
1) Not sure you need to second set of brackets (but not sure on this AS reg
exp code) - the $2 seems a bit spurious, but it might be the square brackets
2) In some regexps - the full stop . - means "any character", and ? means
choice, so these might need escaping to work properly
3) logically a reg exp is case sensitive
4) The \b is word boundary - so should cover words in sentences and words
at the beginning of a sentence
On Fri, Oct 5, 2012 at 11:20 AM, Julian Tenney <
Julian.Tenney at nottingham.ac.uk> wrote:
> You tell me:****
>
> ** **
>
> if (Glossary.enabled && highlight != false){****
>
> for (var i = 0; i<Glossary.terms.length; i++) {****
>
> //new code with regexp****
>
> var re = new RegExp('\\b(' + Glossary.terms[i] + ')([.,!? -])',
> 'gi');****
>
> myText = myText.replace(re, '<font color =
> "'+STYLES.glossaryColour+'"><a class="glossary" href =
> "asfunction:_root.engine.rootIcon.showGlosTerm,'+i+'">$1</a></font>$2');**
> **
>
> }****
>
> }****
>
> ** **
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [mailto:
> xerte-dev-bounces at lists.nottingham.ac.uk] *On Behalf Of *Pat Lockley
> *Sent:* 05 October 2012 10:03
> *To:* For Xerte technical developers
> *Subject:* [Xerte-dev] Re: Glossary****
>
> ** **
>
> is it case sensitive as well?****
>
> On Fri, Oct 5, 2012 at 9:57 AM, Pat Lockley <
> patrick.lockley at googlemail.com> wrote:****
>
> speaking as the Nottingham person who was tasked with writing regular
> expressions ;)
>
> I would assume that would be the case****
>
> ** **
>
> On Fri, Oct 5, 2012 at 9:57 AM, Ron Mitchell <ronm at mitchellmedia.co.uk>
> wrote:****
>
> It seems like as Fay mentioned only terms with a space either side are
> picked up?****
>
> ****
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [mailto:
> xerte-dev-bounces at lists.nottingham.ac.uk] *On Behalf Of *Ron Mitchell
> *Sent:* 05 October 2012 09:53
> *To:* 'For Xerte technical developers'
> *Subject:* [Xerte-dev] Re: Glossary****
>
> ****
>
> You can have them they're all free! ;-)****
>
> ****
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [
> mailto:xerte-dev-bounces at lists.nottingham.ac.uk<xerte-dev-bounces at lists.nottingham.ac.uk>]
> *On Behalf Of *Tom Reijnders
> *Sent:* 05 October 2012 09:49
> *To:* For Xerte technical developers
> *Subject:* [Xerte-dev] Re: Glossary****
>
> ****
>
> I agree, that works. But I want:
>
> xerte
> xot
> moodle
>
> to work.
>
> I added a space after each word, and that doesn't work, only 'xerte ' gets
> highlighted. I have it working, but I want to understand why.****
>
> Op 5-10-2012 10:44, Ron Mitchell schreef:****
>
> That's curious Tom****
>
> I changed the text on each page to:****
>
> about xerte and****
>
> ****
>
> about xot and****
>
> ****
>
> about moodle and****
>
> ****
>
> and the links get created and work on each page
> http://vle.jisctechdis.ac.uk/xot/play.php?template_id=143****
>
> ****
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [
> mailto:xerte-dev-bounces at lists.nottingham.ac.uk<xerte-dev-bounces at lists.nottingham.ac.uk>]
> *On Behalf Of *Tom Reijnders
> *Sent:* 05 October 2012 09:38
> *To:* For Xerte technical developers
> *Subject:* [Xerte-dev] Re: Glossary****
>
> ****
>
> I agree, but it was not sufficient. Somehow the second and third word in
> Ron's example still did not get highlighted for me.
> To fix this issue I had to add the \r to the RegExp.
>
> And to fix the other issue I had to remove the \\b, but that bothers me,
> because I don't know why it was in there and what it is supposed to do....
>
> Tom****
>
> Op 5-10-2012 10:34, Fay Cross schreef:****
>
> I think it’s a problem with the regular expression – if you add a space
> after each word before you do a line break it will highlight the word but
> if it’s at the end of a line/ sentence like your examples it won’t.****
>
> ****
>
> I think it’s looking for “ xot “ rather than just “xot” to avoid things
> like *cat*alogue happening if you have the word cat in the glossary.****
>
> ****
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [
> mailto:xerte-dev-bounces at lists.nottingham.ac.uk<xerte-dev-bounces at lists.nottingham.ac.uk>]
> *On Behalf Of *Ron Mitchell
> *Sent:* 05 October 2012 09:33
> *To:* 'For Xerte technical developers'
> *Subject:* [Xerte-dev] Re: Glossary****
>
> ****
>
> Hi Tom****
>
> is this XOT or xerte?****
>
> I can't get the Glossary to work in XOT at all - am I missing something
> stupid?...****
>
> ****
>
> As a test I added the following:****
>
> ****
>
> Then a plain text page with****
>
> ****
>
> ****
>
> and a text and graphics page with the same words****
>
> ****
>
> ****
>
> But neither page shows any clickable links
> http://vle.jisctechdis.ac.uk/xot/play.php?template_id=143****
>
> ****
>
> ****
>
> *From:* xerte-dev-bounces at lists.nottingham.ac.uk [
> mailto:xerte-dev-bounces at lists.nottingham.ac.uk<xerte-dev-bounces at lists.nottingham.ac.uk>]
> *On Behalf Of *Tom Reijnders
> *Sent:* 05 October 2012 08:34
> *To:* xerte-dev at lists.nottingham.ac.uk
> *Subject:* [Xerte-dev] Glossary****
>
> ****
>
> Julain,
>
> I suppose this is one for you:
>
> I have a teacher that wants to create a kind of dictionary, so he's
> created a big glossary, and then for each letter a separate text page
> containing a list of the terms.
>
> However, the terms are not all transformed into a link.
> 1. The regular expression doesn't like the sentence ending on a 'newline',
> I've added '\r' to the set of characters that may 'end' a term in the
> RegExp of line 6662 (or the teacher has to add a space at the end of the
> term.
>
> That still is not enough, it will only transform the first term to a link.
> I had to remove the \\b from the regexp. I tried to find a manual page to
> figure out what \\b means in RegExp, but I can't find it. Do you have any
> idea what the \\b is doing there?
>
> For quick reference I needed to change this:
>
> if (Glossary.enabled && highlight != false){
> for (var i = 0; i<Glossary.terms.length; i++) {
> //new code with regexp
> var re = new RegExp('\\b(' + Glossary.terms[i] +
> ')([.,!? -])', 'gi');
> myText = myText.replace(re, '<font color =
> "'+STYLES.glossaryColour+'"><a class="glossary" href =
> "asfunction:_root.engine.rootIcon.showGlosTerm,'+i+'">$1</a></font>$2');
> }
> }
>
> into this:
>
> if (Glossary.enabled && highlight != false){
> for (var i = 0; i<Glossary.terms.length; i++) {
> //new code with regexp
> var re = new RegExp('(' + Glossary.terms[i] + ')([.,!?
> -\n\r])', 'gi');
> myText = myText.replace(re, '<font color =
> "'+STYLES.glossaryColour+'"><a class="glossary" href =
> "asfunction:_root.engine.rootIcon.showGlosTerm,'+i+'">$1</a></font>$2');
> }
> }****
>
> -- ****
>
> --****
>
> ****
>
> ** **
>
> Tom Reijnders****
>
> TOR Informatica****
>
> Chopinlaan 27****
>
> 5242HM Rosmalen****
>
> Tel: 073 5226191****
>
> Fax: 073 5226196****
>
> ****
>
> ****
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do not
> use, copy or disclose the information contained in this message or in any
> attachment. Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham. ****
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses which could damage your
> computer system: you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation. ****
>
>
>
> ****
>
> _______________________________________________****
>
> Xerte-dev mailing list****
>
> Xerte-dev at lists.nottingham.ac.uk****
>
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev****
>
> ****
>
> This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.****
>
> ****
>
> This message has been checked for viruses but the contents of an attachment****
>
> may still contain software viruses which could damage your computer system:****
>
> you are advised to perform your own checks. Email communications with the****
>
> University of Nottingham may be monitored as permitted by UK legislation.****
>
> ****
>
> ** **
>
> -- ****
>
> --****
>
> ****
>
> Tom Reijnders****
>
> TOR Informatica****
>
> Chopinlaan 27****
>
> 5242HM Rosmalen****
>
> Tel: 073 5226191****
>
> Fax: 073 5226196****
>
> ****
>
> ** **
>
> _______________________________________________****
>
> Xerte-dev mailing list****
>
> Xerte-dev at lists.nottingham.ac.uk****
>
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev****
>
> ****
>
> This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.****
>
> ****
>
> This message has been checked for viruses but the contents of an attachment****
>
> may still contain software viruses which could damage your computer system:****
>
> you are advised to perform your own checks. Email communications with the****
>
> University of Nottingham may be monitored as permitted by UK legislation.****
>
> ****
>
> ****
>
> -- ****
>
> --****
>
> ****
>
> Tom Reijnders****
>
> TOR Informatica****
>
> Chopinlaan 27****
>
> 5242HM Rosmalen****
>
> Tel: 073 5226191****
>
> Fax: 073 5226196****
>
> ****
>
>
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do
> not use, copy or disclose the information contained in this message or in
> any attachment. Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
> ****
>
> ** **
>
> ** **
>
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do
> not use, copy or disclose the information contained in this message or in
> any attachment. Any views or opinions expressed by the author of this
> email do not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121005/fe925948/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 24301 bytes
Desc: not available
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121005/fe925948/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 25252 bytes
Desc: not available
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121005/fe925948/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 19713 bytes
Desc: not available
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20121005/fe925948/attachment-0005.jpg>
More information about the Xerte-dev
mailing list