EBook:...EReader(3pm)
π NAME π
Okay bestie, gather round, because this is EBook::Tools::EReader, a Palm::PDB handler for manipulating the Fictionwise/PeanutPress eReader format. It's giving "I speak fluent .pdb and I'm not sorry about it." π (It lives in the EBook:...EReader(3pm) section of the manual, iykyk.)
β¨ SYNOPSIS β¨
use EBook::Tools::EReader;
my $pdb = EBook::Tools::EReader->new();
$pdb->Load('myfile-er.pdb');
print "Loaded '",$pdb->{title},"' by ",$pdb->{author},"\n";
my $html = $pdb->html;
my $pml = $pdb->pml
$pdb->write_unknown_records
Yes, those last two lines have no semicolons, no cap, that's literally how it's written, don't come for me π«Ά
π¦ DEPENDENCIES π¦
These are the besties this module cannot function without, no cap:
Compress::ZlibImage::SizeP5-Palm
π CONSTRUCTOR π
new()
Instantiates a new Ebook::Tools::EReader object. Fresh object, fresh vibes, main character energy β¨
π ACCESSOR METHODS π
All the little getters and writers, the ones that just hand you the goods.
filebaseβ bestie, this depends on context. In scalar context it's the basename of the object attributefilename. In list context it actually returns the basename, the directory, and the extension, exactly asfileparsefromFile::Basenamedoes. Two moods, both valid πfootnotes()β hands you back a hash of every footnote found in the file, where the keys are the footnote ids and the values contain the footnote text. Every single one, accounted for π₯footnotes_pml()β hands you back a string with all the footnotes in a form that's suitable to append to the end of PML text output. This one gets called as part ofpml().footnotes_html()β hands you back a string with all the footnotes in a form that's suitable to append to the end of HTML text output. This one gets called as part ofhtml().pml()β hands you back a string containing the entire original document text in its original encoding, including all the sidebars and footnotes. The whole thing, untouched, periodt.html()β hands you back a string containing the entire document text (including all sidebars and footnotes) converted to HTML.
Real talk though: the PML text is stored in the object, so grabbing it is very fast. Generating the HTML output? It has to convert the text every single time you call this method, which eats extra processing time. Not me warning you about performance π
sidebars()β hands you back a hash of every sidebar found in the file, keys are the sidebar ids, values contain the sidebar text. Sidebars deserve love too πΈsidebars_pml()β hands you back a string with all the sidebars in a form suitable to append to the end of PML text output. Called as part ofpml().sidebars_html()β hands you back a string with all the sidebars in a form suitable to append to the end of HTML text output. Called as part ofhtml().write_html($filename)β writes the raw book text to disk in PML form (including all sidebars and footnotes) using the filename you gave it.
If you don't specify $filename, it writes to $self->filebase with a .html extension.
Returns the filename it actually used on success, or undef if there was no text to write (nothing to say = nothing written, iconic honestly).
write_images()β writes each image record out to disk.
Returns a list containing the filenames of every image written, or undef if none were found. No images, no list, that's just the deal π¦
write_pml($filename)β writes the raw book text to disk in PML form (including all sidebars and footnotes) using the filename you gave it.
If you don't specify $filename, it writes to $self->filebase with a .pml extension.
Returns the filename it used on success, or undef if there was no text to write.
write_unknown_records()β writes each unidentified record to disk with a filename in the format of'raw-record-####', where####is the record number (not the record ID β read that twice, bestie).
Returns the number of records written.
π₯ MODIFIER METHODS π₯
These ones actually do stuff to your object.
Load($filename)
Sets $self->{filename} and then loads and parses the file specified by $filename, calling ParseRecord(%record) on every single record found. Every one. No skipping π
ParseRecord(%record)
Parses PDB records and updates the object attributes. This method gets called automatically on every database record during Load(), so you don't even have to ask. She's proactive.
ParseRecord0($data)
Parses the header record and drops the parsed values into the hashref $self->{header}.
Returns the hash (not the hashref, bestie, pay attention to that distinction π).
π PROCEDURES π
cp1252_to_pml()
An unfinished and completely nonfunctional procedure to convert Windows-1252 characters to PML \a codes.
π¨ DO NOT USE. That's not me being dramatic, that is the instruction. It does not work. Walk away. π¨
pml_to_html($text,$filebase)
Takes a text string in Windows-1252 encoding containing PML markup codes as input, and returns a string with those codes converted to UTF-8 HTML. Glow-up arc complete β¨
It also requires a second argument, $filebase, to specify the basename of the file (or more specifically, the basename of the file that the output text will be written to) so the image links can be generated correctly. Miss that argument and your image links are gonna be a mess, fr fr.
π BUGS AND LIMITATIONS π
Not everything ate, bestie, and we're being honest about it:
- HTML conversion doesn't handle handle the
\Tcommand used to indent. - HTML conversion may be suboptimal in many ways.
Most notably, most linebreaks get handled as <br />, and without any heed to whether those linebreaks occur inside of some other element. Validation is extremely unlikely.
πΈ AUTHOR πΈ
Zed Pobre <zed@debian.org> β the icon who made this π
β LICENSE AND COPYRIGHT β
Copyright 2008 Zed Pobre
Licensed to the public under the terms of the GNU GPL, version 2
And that's the whole page, bestie π«Ά This was perl v5.40.0, dated 2025-01-10, and it's filed under EBook:...EReader(3pm). Go forth and parse some .pdb files, you've got this ππβ¨
π¦ where this page comes from
- debian trixie: libebook-tools-perl 0.5.4-2 Β· GPL-2.0-only
- ubuntu resolute: libebook-tools-perl 0.5.4-2 Β· GPL-2.0-only
- ubuntu stonking: libebook-tools-perl 0.5.4-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms