Skip to content

Instantly share code, notes, and snippets.

@jesusbagpuss jesusbagpuss/example.pl
Last active Mar 6, 2018

Embed
What would you like to do?
EPrints: render reference test in paragraphs
{
name => 'referencetext',
type => 'longtext',
input_rows => 15,
render_value => sub {
my( $session , $field , $value ) = @_; # see: https://wiki.eprints.org/w/Category:EPrints_Metadata_Fields#Rendering_Properties
my $frag = $session->make_doc_fragment;
# split value on a double-new line (possibly with other whitespace in between
foreach my $para ( split /\n[\r\s]*\n/, $value )
{
my $p = $session->make_element( "p", class=>"referencetext" );
# split text on new lines - rendering each one as a line-break
foreach my $subpara ( split /\n[\r\s\n]*/, $para )
{
$p->appendChild( $session->make_text( $subpara ) );
$p->appendChild( $session->make_element( "br" ) );
}
$frag->appendChild( $p );
}
return $frag;
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.