EBook-Tools

 view release on metacpan or  search on metacpan

lib/EBook/Tools/EReader.pm  view on Meta::CPAN

                # This doesn't work?  Need to rewrite for RHS eval?
                $pmlcode =~ s/= $//x;
                $text =~ s#\Q$pmlcode\E
                           ="(.*?)" (.*?) \Q $pmlcode \E
                          #$replacement->[0]$2$replacement->[1]#gsx;
            }
            else
            {
                $text =~ s#\Q$pmlcode\E (.*?) \Q$pmlcode\E
                          #$replacement->[0]$1$replacement->[1]#gsx;
            }
        }
        else
        {
            if($pmlcode =~ / = $/x)
            {
                $text =~ s#\Q$pmlcode\E "(.*?)"
                          #$replacement#gsx;
            }
            else
            {
                $text =~ s#\Q$pmlcode\E
                          #$replacement#gsx;
            }

        }
    } # while(my ($pmlcode,$replacement) = each(%pmlcodes) )

    # Strip leftover \n codes
    $text =~ s#\\n
              ##gsx;

    # Horizontal rules
    $text =~ s!\\w="(.*?)"
              !<hr width="$1" />!gsx;

    # Images
    $text =~ s!\\m="(.*?)"
              !<img src="${filebase}_img/$1" />!gsx;

    # Anchors and references
    $text =~ s!\\q="(.*?)"(.*?)\\q
              !<a href="#$1">$2</a>!gsx;
    $text =~ s!\\Q="(.*?)"
              !<a id="$1"></a>!gsx;

    # Footnotes and sidebars
    $text =~ s!\\Fn="(.*?)"(.*?)\\Fn
              !<a id="$1-ref" href="#$1">$2</a>!gsx;
    $text =~ s!\\Sd="(.*?)"(.*?)\\Sd
              !<a id="$1-ref" href="#$1">$2</a>!gsx;

    # Double-newlines after page breaks
    $text =~ s#("page-break-after: always" />)#$1\n\n#g;

    return $text;
}

########## END CODE ##########

=head1 BUGS AND LIMITATIONS

=over

=item * HTML conversion doesn't handle handle the \T command used to
        indent.

=item * HTML conversion may be suboptimal in many ways.

Most notably, most linebreaks are handled as <br />, and without any
heed to whether those linebreaks occur inside of some other element.
Validation is extremely unlikely.

=back

=head1 AUTHOR

Zed Pobre <zed@debian.org>

=head1 LICENSE AND COPYRIGHT

Copyright 2008 Zed Pobre

Licensed to the public under the terms of the GNU GPL, version 2

=cut

1;



( run in 1.657 second using v1.01-cache-2.11-cpan-39bf76dae61 )