[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[EP-tech] Building citations based on condition with Regular Expression
Hi Stefan,
You're right - it doesn't.
I don't think there is a simple way to achieve what you are trying to do with the EPScript methods available:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FEPScript&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=6WmaXySYkbA79f%2B9HbXwZUjyXB8z0EQvMVjE1gYotUw%3D&reserved=0
If you look in EPrints::Script::Compiler::tokenise you'll see the different characters that EPScript expects - it doesn't include RegExps.
You could inject a method to EPrints::Script::Compiled that returns a boolean for use in a test, or even rendered xhtml.
I used this approach here:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L11-L29&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=umpdLUMGwG5SmWltAyEefzVfazgXF0DsYUAJMbivVmI%3D&reserved=0 (documentation)
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L117-L149&data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C00410c57aef148c56c9508d7473f588b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&sdata=KJrng0saNTF6Lr%2BL9VeE4ROkuonSW4MTgekvvu6HG7w%3D&reserved=0 (method added to EPrints::Script::Compiled)
Let me know if that helps - or if you want some more explanation.
You *could* inject a method that took a RegExp as a parameter - you would need to be careful about compiling the regex from this string if you do!
Cheers,
John
From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Stefan Wellsandt via Eprints-tech
Sent: 02 October 2019 14:27
To: eprints-tech at ecs.soton.ac.uk
Subject: [EP-tech] Building citations based on condition with Regular Expression
Hello,
I want to use a regular expression to assemble a part in a citation. This script (see below) throws me an error - I assume the EprintsScript does not know RegExp.
<when test="type.one_of('conference_item','editor_conference_proceeding')">
In: Proceedings of the
<choose>
<when test="event_title =~ \International\">
<if test="event_title"><print expr="event_title"/></if>
</when>
<otherwise>
<if test="event_type"><print expr="event_type"/></if> on <if test="event_title"><print expr="event_title"/></if>
</otherwise>
</choose>
</when>
What is the easiest way to fix this problem?
Best regards
Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20191002/7df4258d/attachment-0001.html