EPrints Technical Mailing List Archive

Message: #02783


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Paragraph in abstract field


Hi,

In your local conf, add:

$c->{render_paras} = sub {
        my( $session, $field, $value, $object ) = @_;

        my $frag = $session->make_doc_fragment;

        # normalise newlines
        $value =~ s/(\r\n|\n|\r)/\n/gs;

        my @paras = split( /\n\n/, $value );
        foreach my $para( @paras )
        {
                $para =~ s/^\s*\n?//;
                $para =~ s/\n?\s*$//;
                next if $para eq "";

                my $p = $session->make_element( "p", class=>"ep_field_para" );

                my @lines = split( /\n/, $para );
                for( my $i=0; $i<scalar( @lines ); $i++ )
                {
                        $p->appendChild( $session->make_text( $lines[$i] ) );
                        $p->appendChild( $session->make_element( "br" ) ) unless $i == $#lines;
                }

                $frag->appendChild( $p );
        }

        return $frag;
}


Then in your eprint_fields:

{
    name=>'abstract',
#etc
    render_value => 'render_paras'
}

Seb


On 14/03/14 13:14, Lourdes Calvo Montero wrote:
Hi all,

we have upgraded to 3.3.12, is there any way to render paragraphs inside the abstract field?

Thanks

Lourdes


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/