pjcj / Gedcom.pm

Gedcom - a Perl module to manipulate Gedcom genealogy files
http://www.pjcj.net/perl.html
27 stars 10 forks source link

full_value handling of CONC on FindMyPast Gedcoms #21

Open nigelhorne opened 6 years ago

nigelhorne commented 6 years ago

This is a bug in FMP not in Gedcom, but since they are very unlikely to help I thought it best asking here for help.

In Item.pm there is this code:


sub full_value {
    my $self = shift;
    my $value = $self->{value};
    $value =~ s/[\r\n]+$// if defined $value;
    for my $item (@{$self->_items}) {
        my $v = defined $item->{value} ? $item->{value} : "";
        $v =~ s/[\r\n]+$//;
        $value .= "\n$v" if $item->{tag} eq "CONT";
        $value .=    $v  if $item->{tag} eq "CONC";
    }
    $value
}

The problem is that if a NOTE record (and perhaps others) or CONC record ends with a space, FMP (and perhaps ACOM) strips it which means that words can run on. I don't know how, but somehow it would be great if that could be worked around.

Maybe something horrible such as this:

        $value .= "\n$v" if $item->{tag} eq "CONT";
        $value .= ' '  if(($item->{tag} eq 'CONC') && ($value !~ /\s$/));  # Work around FMP
        $value .=    $v  if $item->{tag} eq "CONC";
pjcj commented 1 week ago

@nigelhorne jhannah I've finally carved out a little time to look at Gedcom.pm and created a solution for this.

I don't really want to add anything that always runs, since I think the current behaviour is compliant with the GEDCOM standard and I wouldn't like to break that. But perl has a long and illustrious history of working around broken software. So I have essentially added the proposed fix behind a feature flag.

When you create your GEDCOM object you can specify the option add_conc_space and if that value is true then a space will be added to the value before the CONC value is added, if one is not already there.

I think this is what's needed. The fix is on the dev branch if you'd like to take a look. If it does what's needed I'll make a new release.

nigelhorne commented 1 week ago

Thanks, I'll take a look. I understand. In the real world, we have to realise that, sadly, genealogy websites do not adhere to the Gedcom standard, sigh.