nigelhorne / ged2site

Create a family tree website from a Gedcom file
https://genealogy.nigelhorne.com
GNU General Public License v2.0
36 stars 4 forks source link

INDI NOTE ref CONC CONT -> <p> #121

Open jhannah opened 1 month ago

jhannah commented 1 month ago

Thoughts about HTML transformation:

0 @I1072@ INDI
1 NAME Benjamin Millard /Hannah/
1 SEX M
1 NOTE @X122@
...
0 @X122@ NOTE
1 CONC Compiled by James Bradley Hannah, 19 APRIL 2023 and updated 7 MAY 2024:
1 CONT Nicknamed Ben or Bennie, Benjamin was the youngest of six children born to John Robert and Zylpha Alzada (Byers) while living at “the Hannah farm” south of Mt. Pleasant, Iowa on “old Highway 218.” Friends and family recall him as
1 CONC  tall and slender, fun-loving, and athletic. His high school report cards with grades of mostly As and Bs was consistent with his great love of reading. He married Luella Jean Long on her 19th birthday, September 30, 1923.
1 CONC  Tragically, he suffered an early death, as recorded in the Mt. Pleasant News under the headline, “Large Crowd Attends Service For Ben Hannah,” reading in part: 
1 CONT
1 CONT Friends, relatives, and sympathetic acquaintances completely filled the First Methodist Church [roughly 300 persons] for the memorial service for Benjamin Millard Hannah, truck driver from Mt. Pleasant who lost his life when the
1 CONC  gasoline transport he was driving was involved in a crash nine miles north of Fairfield, in the fog Monday morning…(He) was born November 29, 1920, in Henry County, Iowa. He lost his life February 19, 1951 at the age of thirty
1 CONC  years, two months, and twenty days. Surviving him are his wife, the former Jean Long; three small sons, Johnny, Steven, and Jimmie; his mother, Zylpha Hannah; and four sisters, Mrs. Hamilton Williams, Mt. Pleasant; Mrs. Dale
1 CONC  Cammack, Salem; Mrs. Fred Perrenoud, Winfield; and Mrs. C.A. Hoffman, Minot, N. Dak. His father and a brother, Wayne, preceded him in death, the latter losing his life in a Pennsylvania plane crash, July 4. 1944.

Current render: http://jays.net/genealogy/static-site/I1072.html

Currently the entire note is a single <p> tag, and each CONT adds a <br>. But multiple <br>s in a row are suppressed, so there's no way to get a paragraph break?

My theory is that each CONT should be it's own <p> tag, and each CONC should be appended to previous CONT content with a space. (Currently spaces are not added, causing the HTML to read, for example: September 30, 1923.Tragically,)

nigelhorne commented 1 month ago

Try it now, please.

jhannah commented 1 month ago

From master df7ab4a5f9e297d2e03d173d6ea833e529f68172:

nigelhorne commented 1 month ago

I believe that is an issue with full_value() within the Gedcom::Item class, it removes the spaces before ged2site even sees the string. This sample program demonstrates it. It may be worth raising a bug report with the author of that module - unless you can think of a work-around within ged2site.

#!/usr/bin/env perl

use strict;
use warnings;
use Gedcom;
use File::Temp;

my $str =<< 'EOF';
0 @I1072@ INDI
1 NAME Benjamin Millard /Hannah/
1 SEX M
1 NOTE @X122@
0 @X122@ NOTE
1 CONC Compiled by James Bradley Hannah, 19 APRIL 2023 and updated 7 MAY 2024:
1 CONT Nicknamed Ben or Bennie, Benjamin was the youngest of six children born to John Robert and Zylpha Alzada (Byers) while living at “the Hannah farm” south of Mt. Pleasant, Iowa on “old Highway 218.” Friends and family recall him as
1 CONC  tall and slender, fun-loving, and athletic. His high school report cards with grades of mostly As and Bs was consistent with his great love of reading. He married Luella Jean Long on her 19th birthday, September 30, 1923.
1 CONC  Tragically, he suffered an early death, as recorded in the Mt. Pleasant News under the headline, “Large Crowd Attends Service For Ben Hannah,” reading in part: 
1 CONT
1 CONT Friends, relatives, and sympathetic acquaintances completely filled the First Methodist Church [roughly 300 persons] for the memorial service for Benjamin Millard Hannah, truck driver from Mt. Pleasant who lost his life when the
1 CONC  gasoline transport he was driving was involved in a crash nine miles north of Fairfield, in the fog Monday morning…(He) was born November 29, 1920, in Henry County, Iowa. He lost his life February 19, 1951 at the age of thirty
1 CONC  years, two months, and twenty days. Surviving him are his wife, the former Jean Long; three small sons, Johnny, Steven, and Jimmie; his mother, Zylpha Hannah; and four sisters, Mrs. Hamilton Williams, Mt. Pleasant; Mrs. Dale
1 CONC  Cammack, Salem; Mrs. Fred Perrenoud, Winfield; and Mrs. C.A. Hoffman, Minot, N. Dak. His father and a brother, Wayne, preceded him in death, the latter losing his life in a Pennsylvania plane crash, July 4. 1944.
EOF

my($fh, $filename) = File::Temp::tempfile();
print $fh $str;
close $fh;

my $ged = Gedcom->new($filename);
my $ben = $ged->get_individual('I1072');
my @notes = $ben->get_record('NOTE');

foreach my $note(@notes) {
    if($note) {
        if(ref($note) eq 'Gedcom::Record') {
            $note = $note->full_value();    # Include CONC records
            if(my $n = $ged->resolve_xref($note)) {
                $note = $n->full_value();
            }
            print __LINE__, ": $note\n";
        }
    }
}

unlink($filename);
jhannah commented 1 month ago

Oh dear. Looks like someone cough 🙂 already raised that issue in 2017? https://github.com/pjcj/Gedcom.pm/issues/21 No response... Should I... also fork Gedcom.pm? Seek PAUSE CO-MAINT since there hasn't been a release since 2019?

nigelhorne commented 1 month ago

I'd forgotten about that one. I rather think Paul has moved on from supporting the Gedcom module. It would be great if he were to ok co-ownership.

jhannah commented 4 weeks ago

Huh. Well, I changed Gedcom.pm to make myself happy. But that makes the tests unhappy:

t/Basic.pm
1   NOTE Line 1
2     CONT Line 2
2     CONT Lin
2     CONC e 3
2     CONT Line 
2     CONC 4

prove -Ilib t/basic.t
t/basic.t .. 1/1533 # Test 113 got: "Line 1\nLine 2\nLin e 3\nLine 4" (t/Basic.pm at line 31 fail #113)
#     Expected: "Line 1\nLine 2\nLine 3\nLine 4"
#     Line 3 is changed:
#      - "Line 3\n"
#      + "Lin e 3\n"
#  t/Basic.pm line 31 is:     &Test::ok(@a)
t/basic.t .. Failed 1/1533 subtests

Not sure who/where is the authoritative specification nowadays... If it's here https://github.com/FamilySearch/GEDCOM/blob/a6c05e160cb61d959fae7b7dcbea19e332e6684f/changelog.md?plain=1#L36 then CONC doesn't even exist anymore (deprecated).

So... uhh... I guess this'll just be another hack specific to me? In another fork of mine?

jhannah commented 3 weeks ago

I'd forgotten about that one. I rather think Paul has moved on from supporting the Gedcom module. It would be great if he were to ok co-ownership.

Currently PAUSE says Gedcom has 0 co-maintainers. Shall I request he add NHORNE and JHANNAH?

nigelhorne commented 3 weeks ago

That would be great, if Paul is unable or uninterested to keep up the maintenance.

jhannah commented 3 weeks ago

heh. Over in Python land, looks like there's quite a mess of competing parsers of GEDCOM, focusing on various versions of the GEDCOM specs. https://pypi.org/search/?q=gedcom ... I wonder if they all agree on a specific source of specification truth?