Changeset 36057 for main


Ignore:
Timestamp:
2022-02-14T14:31:15+13:00 (2 years ago)
Author:
kjdon
Message:

in the whakatohea project, converting the pdfs to paged_pretty_html resulted in unclosed divs in the sections. This is because the <div page=1> was outside the <h2> or <h3> headings. Put these <h> headings on the outside of divs to keep the resulting doc.xml nicer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/PDFv2Plugin.pm

    r35164 r36057  
    581581    # If number of remaining pages >= 10, then create new bucket heading
    582582    # e.g. "Pages 30-40"
     583        my $header_text = ""; #we want the <h2/3> tags to come outside the <div page=1> tag, otherwise we end up with unclosed divs in
     584        # some sections
    583585    if(($page_num % 10) == 1 && ($num_html_pages > 10)) {
    584586        # Double-digit page numbers that start with 2
     
    586588        my $start_range = $page_num - ($page_num % 10) + 1;
    587589        my $end_range = $page_num + 10 - ($page_num % 10);
    588         $page_div .= "<h2 style=\"font-size:1em;font-weight:normal;\">Pages ".$start_range . "-" . $end_range."</h2>\n";
     590        #$page_div .= "<h2 style=\"font-size:1em;font-weight:normal;\">Pages ".$start_range . "-" . $end_range."</h2>\n";
     591            $header_text = "<h2 style=\"font-size:1em;font-weight:normal;\">Pages ".$start_range . "-" . $end_range."</h2>\n";
    589592    }
    590593
     
    592595    # Whether we're starting a new bucket or not, add a simpler heading: just the pagenumber, "Page #"
    593596    # However, this should be <H3> when there are buckets and <H2> when there aren't any.
     597        my $hx="h2";
    594598    if($num_html_pages > 10) {
    595         $page_div .= "<h3 style=\"font-size:1em;font-weight:normal;\">Page ".$page_num."</h3>\n";       
    596     } else { # PDF has less than 10 pages in total
    597         $page_div .= "<h2 style=\"font-size:1em;font-weight:normal;\">Page ".$page_num."</h2>\n";       
    598     }
     599            $hx = "h3";
     600        }
     601        #$page_div .= "<$hx style=\"font-size:1em;font-weight:normal;\">Page ".$page_num."</$hx>\n";       
     602        $header_text .= "<$hx style=\"font-size:1em;font-weight:normal;\">Page ".$page_num."</$hx>\n";
     603        $page_div = $header_text . $page_div;
    599604    }
    600605
Note: See TracChangeset for help on using the changeset viewer.