repository

BlowfishCMS

A small content management system for OpenBSD

version 0.45.6 · ISC · 2026-12-03 · releases

338 lines · 20.8 KB · download this file

package BlowfishCMS::Addon::Resume;
# Resume: a Resume page built from four blocks (the heading with your name and
# contact details, lists of entries such as experience or education, skills,
# and a download panel), filled in on the Resume tab of Site › Add-ons, and the
# same resume as a PDF at /x/resume/NAME.pdf, made on the server from the page's
# blocks each time it's asked for.
#
# Tables: none (the resume is the page's blocks). Blocks: resume_header,
# resume_entries, resume_skills, resume_download. Admin: kind=x-resume (admin
# service). Route: /x/resume/*.pdf (public service).
#
# The PDF uses the PDF standard fonts (Helvetica), so nothing is embedded and
# nothing needs installing. It's plain ASCII (hex text, uncompressed), as the
# public service writes text: about 20 KB for a one-page resume.
use v5.36;
use utf8;
use Unicode::Normalize qw(NFD);
BEGIN { no strict 'refs'; *{$_}=\&{"BlowfishCMS::$_"} for qw(h attempt window_html render_markdown markdown_copy header addon_page page_enabled page_by_slug link_ok) }

my @types=qw(resume_header resume_entries resume_skills resume_download);

# ---- Blocks ------------------------------------------------------------------------------
my @panel=([title=>'Panel title','text',120],[subtitle=>'Panel subtitle','text',160,'optional']);
sub blocks {
    return {
        resume_header=>{label=>'Resume heading',order=>60,group=>'content',about=>'Your name, what you do, how to reach you, and a short summary.',
            fields=>[@panel,[name=>'Your name','text',120],[headline=>'Headline','text',160,'optional; what you do, such as “Systems administrator”'],
                [location=>'Where you are','text',120,'optional'],[email=>'Email','text',200,'optional; shown to everyone, on the page and in the PDF'],
                [phone=>'Phone','text',40,'optional; shown to everyone, on the page and in the PDF'],
                [links=>'Links','items',[[label=>'Label','text',60,'such as “GitHub”'],[url=>'Address','text',300,'https://…']],'optional; your site and profiles'],
                [summary=>'Summary','markdown',3000,'optional; a few lines about you']],
            defaults=>{title=>'resume / cv'},render=>\&header_html},
        resume_entries=>{label=>'Resume entries',order=>61,group=>'content',about=>'Experience, education, projects or certificates: one entry each, with dates and details.',
            fields=>[@panel,[entries=>'Entries','items',[[role=>'Title','text',160,'a job title, degree, project or certificate'],[org=>'Where','text',160,'optional; employer, school or organisation'],
                [dates=>'Dates','text',60,'optional; such as “2021 – now”'],[place=>'Place','text',120,'optional'],[details=>'Details','markdown',2000,'optional; one point per line, each starting with “- ”']]]],
            defaults=>{title=>'experience'},render=>\&entries_html},
        resume_skills=>{label=>'Resume skills',order=>62,group=>'content',about=>'Skills in groups, shown as tags.',
            fields=>[@panel,[groups=>'Groups','items',[[name=>'Group','text',80,'optional; such as “languages”'],[skills=>'Skills','text',600,'separated by commas']]]],
            defaults=>{title=>'skills'},render=>\&skills_html},
        resume_download=>{label=>'Resume download',order=>63,group=>'content',about=>'A button for the PDF of the resume, and links to print it or get in touch.',
            fields=>[@panel,[label=>'Button','text',80],[print=>'A “print” button too','check'],[contact=>'A link to the Contact page, when it’s on','check']],
            defaults=>{title=>'download / contact',label=>'download one-page PDF ↓',print=>0,contact=>1},render=>\&download_html},
    };
}
sub window_options ($d) { return (print_hide=>$d->{print_hide},bg=>($d->{section_bg}//''),pad=>($d->{section_pad}//''),nobar=>($d->{section_bar} || ($d->{section_bg}//'') eq 'none')) }
sub list ($v) { return grep {ref eq 'HASH'} @{ref $v eq 'ARRAY' ? $v : []} }
sub tel ($phone) { my $t=$phone =~ s/[^\d+]//gr;return length $t ? "tel:$t" : '' }
# The contact details, in order: [text, link or '']. For print (the PDF), a
# link shows its address rather than its label.
sub contacts ($d,$print=0) {
    my @c;
    push @c,[$d->{location},''] if length($d->{location}//'');
    push @c,[$d->{email},"mailto:$d->{email}"] if ($d->{email}//'') =~ /\A[^\s@<>"]+@[^\s@<>"]+\z/;
    push @c,[$d->{phone},tel($d->{phone})] if length($d->{phone}//'');
    for (list($d->{links})) {
        my $url=$_->{url}//'';$url="https://$url" if $url =~ /\A[\w.-]+\.[a-z]{2,}(?:[\/?#]\S*)?\z/i;
        next unless link_ok($url);
        my $bare=$url =~ s{\Ahttps?://(?:www\.)?}{}r =~ s{\Amailto:}{}r =~ s{/\z}{}r;
        push @c,[!$print && length($_->{label}//'') ? $_->{label} : $bare,$url];
    }
    return @c;
}
sub header_html ($b,%o) {
    my $d=$b->{data};
    my $body=(length($d->{name}//'') ? '<h1 class="resume-name">'.h($d->{name}).'</h1>' : '')
        .(length($d->{headline}//'') ? '<p class="kicker"><b>'.h($d->{headline}).'</b></p>' : '');
    my @c=contacts($d);
    $body.='<p class="resume-contact">'.join('<span aria-hidden="true"> · </span>',map {length $_->[1] ? '<a href="'.h($_->[1]).'"'.($_->[1] =~ /\Ahttps?:/ ? ' rel="me noopener"' : '').'>'.h($_->[0]).'</a>' : h($_->[0])} @c).'</p>' if @c;
    $body.=markdown_copy($d->{summary});
    return window_html($d->{title},$d->{subtitle},$body,window_options($d));
}
sub entry_heading ($e) { return join ' · ',grep {length} ($e->{role}//''),($e->{org}//'') }
sub entry_meta ($e) { return join ' | ',grep {length} ($e->{dates}//''),($e->{place}//'') }
sub entries_html ($b,%o) {
    my $d=$b->{data};my @e=list($d->{entries});
    return '' unless @e;
    my $body=join '',map {
        '<div class="cv-entry"><h3>'.h(entry_heading($_)).'</h3>'.(length(entry_meta($_)) ? '<p class="cv-meta">'.h(entry_meta($_)).'</p>' : '').(length($_->{details}//'') ? render_markdown($_->{details}) : '').'</div>'
    } @e;
    return window_html($d->{title},$d->{subtitle},$body,window_options($d));
}
sub skills_of ($g) { return grep {length} map {s/\A\s+|\s+\z//gr} split /,/,$g->{skills}//'' }
sub skills_html ($b,%o) {
    my $d=$b->{data};my @g=grep {skills_of($_)} list($d->{groups});
    return '' unless @g;
    my $body=join '',map {'<div>'.(length($_->{name}//'') ? '<p class="kicker">'.h($_->{name}).'</p>' : '').'<div class="skill-row">'.join('',map {'<span class="skill-tag">'.h($_).'</span>'} skills_of($_)).'</div></div>'} @g;
    return window_html($d->{title},$d->{subtitle},$body,window_options($d),body_class=>'stack');
}
# The PDF's address: the name in the heading block, else "resume".
sub pdf_name {
    my $page=addon_page('resume');my ($head)=grep {$_->{type} eq 'resume_header'} @{$page ? $page->{blocks} : []};
    my $n=lc(NFD($head ? $head->{data}{name}//'' : '')) =~ s/\p{Mn}//gr =~ s/[^a-z0-9]+/-/gr =~ s/\A-+|-+\z//gr;
    return substr(length $n ? "$n-resume" : 'resume',0,80).'.pdf';
}
sub contact_page {
    my $p=(attempt {addon_page('contact')}) || page_by_slug('contact');
    return $p && page_enabled($p->{slug}) ? $p->{path} : '';
}
sub download_html ($b,%o) {
    my $d=$b->{data};my $contact=$d->{contact} ? contact_page() : '';
    my $body='<div class="resume-download"><a class="buttonlike" href="/x/resume/'.h(pdf_name()).'" download>'.h(length($d->{label}//'') ? $d->{label} : 'download PDF').'</a>'
        .($d->{print} ? '<button type="button" class="buttonlike print-resume" hidden>print</button>' : '')
        .(length $contact ? '<a class="buttonlike" href="'.h($contact).'">contact me</a>' : '').'</div>';
    return window_html($d->{title},$d->{subtitle},$body,window_options($d));
}

# ---- The Resume tab ------------------------------------------------------------------------
# Its tab is its page in BlowfishCMS's page editor ("screen": "page", 0.29),
# which also offers the resume blocks to a page that has none of them.

# ---- The PDF -----------------------------------------------------------------------------
sub route ($rest) {
    return 0 unless $rest =~ /\A[a-z0-9-]{1,80}\.pdf\z/;
    my $page=addon_page('resume');
    return 0 unless $page && page_enabled($page->{slug});
    my @blocks=grep {my $b=$_;!$b->{data}{print_hide} && grep {$b->{type} eq $_} @types} @{$page->{blocks}};
    my ($head)=grep {$_->{type} eq 'resume_header'} @blocks;
    my $name=$head ? $head->{data}{name}//'' : '';
    my $pdf=BlowfishCMS::Addon::Resume::PDF->new(title=>(length $name ? "$name, resume" : 'Resume'),author=>$name);
    my @group;
    my $flush=sub {
        return unless @group;
        my @left=grep {($_->{width}//'') ne 'right'} @group;my @right=grep {($_->{width}//'') eq 'right'} @group;
        if (@left && @right) {$pdf->columns([map {my $b=$_;sub ($c) {pdf_block($c,$b)}} @left],[map {my $b=$_;sub ($c) {pdf_block($c,$b)}} @right])}
        else {pdf_block($pdf->column,$_) for @group}
        @group=();
    };
    for my $b (@blocks) {
        if (($b->{width}//'full') =~ /\A(?:full|side)\z/) {$flush->();pdf_block($pdf->column,$b)} else {push @group,$b}
    }
    $flush->();
    my $bytes=$pdf->bytes;
    header(200,'application/pdf',"Content-Disposition: inline; filename=\"".pdf_name()."\"\r\nContent-Length: ".length($bytes)."\r\nCache-Control: no-cache\r\nX-Content-Type-Options: nosniff\r\n");
    print $bytes;
    return 1;
}
sub pdf_block ($c,$b) {
    my $d=$b->{data};my $t=$b->{type};
    if ($t eq 'resume_header') {
        $c->text($d->{name},font=>'B',size=>20,after=>3) if length($d->{name}//'');
        $c->text($d->{headline},size=>11,grey=>1,after=>4) if length($d->{headline}//'');
        $c->links([contacts($d,1)],size=>8.5,after=>6);
        $c->markdown($d->{summary},size=>9) if length($d->{summary}//'');
        $c->gap(8);
        return;
    }
    if ($t eq 'resume_entries') {
        my @e=list($d->{entries});return unless @e;
        $c->heading($d->{title});
        for my $e (@e) {
            $c->keep(30);
            $c->text(entry_heading($e),font=>'B',size=>9.5,after=>1);
            $c->text(entry_meta($e),size=>8,grey=>1,after=>2) if length entry_meta($e);
            $c->markdown($e->{details},size=>8.8) if length($e->{details}//'');
            $c->gap(5);
        }
        $c->gap(4);
        return;
    }
    if ($t eq 'resume_skills') {
        my @g=grep {skills_of($_)} list($d->{groups});return unless @g;
        $c->heading($d->{title});
        for my $g (@g) {
            $c->text($g->{name},font=>'B',size=>8.5,after=>1) if length($g->{name}//'');
            $c->text(join(', ',skills_of($g)),size=>8.5,after=>4);
        }
        $c->gap(4);
    }
}

# A small PDF writer: Letter pages, the standard Helvetica fonts in the
# Windows-1252 encoding (letters outside it lose their accents, or become “?”),
# text that wraps, links, and two columns that run on to new pages each.
package BlowfishCMS::Addon::Resume::PDF;
use v5.36;
use utf8;
use Encode qw(encode);
use Unicode::Normalize qw(NFD);
# Glyph widths (1/1000 em) for codes 32–255 (Adobe's Helvetica metrics).
my %width;
{
    my @r=qw(278 278 355 556 556 889 667 191 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584 556 1015 667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469 556 333 556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500 334 260 334 584 761 556 0 222 556 333 1000 556 556 333 1000 667 333 1000 0 611 0 0 222 222 333 333 350 556 1000 333 1000 500 333 944 0 500 667 278 333 556 556 556 556 260 556 333 737 370 556 584 333 737 333 400 584 333 333 333 556 537 278 333 333 365 556 834 834 834 611 667 667 667 667 667 667 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 500 556 556 556 556 278 278 278 278 556 556 556 556 556 556 556 584 611 556 556 556 556 500 556 500);
    my @b=qw(278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278 556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611 975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778 667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556 333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611 611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 761 556 0 278 556 500 1000 556 556 333 1000 667 333 1000 0 611 0 0 278 278 500 500 350 556 1000 333 1000 556 333 944 0 500 667 278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 333 400 584 333 333 333 611 556 278 333 333 365 556 834 834 834 611 722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278 722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611 556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278 611 611 611 611 611 611 611 584 611 611 611 611 611 556 611 556);
    $width{R}=[(0)x32,@r];$width{I}=$width{R};$width{B}=[(0)x32,@b];
}
# Letters with no accent to take off, and what stands in for them.
my %plain=('Ł'=>'L','ł'=>'l','Đ'=>'D','đ'=>'d','Ħ'=>'H','ħ'=>'h','ı'=>'i','Ŀ'=>'L','ŀ'=>'l','‐'=>'-','‑'=>'-','−'=>'-','′'=>"'",'″'=>'"','…'=>'...');
my %font=(R=>'Helvetica',B=>'Helvetica-Bold',I=>'Helvetica-Oblique');
use constant {PAGE_W=>612,PAGE_H=>792,MARGIN=>42,GUTTER=>20};
sub new ($class,%o) { my $s=bless {pages=>[],annots=>[],%o},$class;$s->{col}=BlowfishCMS::Addon::Resume::PDF::Column->new($s,MARGIN,PAGE_W-2*MARGIN,0,PAGE_H-MARGIN);return $s }
sub column ($s) { return $s->{col} }
sub stream ($s,$page) { $s->{pages}[$page] //= '';return \$s->{pages}[$page] }
# Two columns side by side (1.75 : 1, as the page prints), from where the
# page is; the page carries on below whichever ends lower.
sub columns ($s,$left,$right) {
    my $c=$s->{col};my $lw=(PAGE_W-2*MARGIN-GUTTER)*1.75/2.75;
    my $l=BlowfishCMS::Addon::Resume::PDF::Column->new($s,MARGIN,$lw,$c->{page},$c->{y});
    my $r=BlowfishCMS::Addon::Resume::PDF::Column->new($s,MARGIN+$lw+GUTTER,PAGE_W-2*MARGIN-GUTTER-$lw,$c->{page},$c->{y});
    $_->($l) for @$left;$_->($r) for @$right;
    my ($end)=sort {$b->{page} <=> $a->{page} || $a->{y} <=> $b->{y}} $l,$r;
    @$c{qw(page y)}=@$end{qw(page y)};
}
# Text as Windows-1252 bytes: a letter it lacks loses its accent, else is “?”.
sub cp1252 ($text) {
    my $out='';
    for my $ch (split //,$text//'') {
        my $b=encode('cp1252',$ch,sub {''});
        $b=encode('cp1252',($plain{$ch} // NFD($ch) =~ s/\p{Mn}//gr),sub {'?'}) unless length $b;
        $out.=$b;
    }
    return $out;
}
sub width ($bytes,$f,$size) { my $w=0;$w+=$width{$f}[ord $_]//556 for split //,$bytes;return $w*$size/1000 }
sub hex_string ($bytes) { return '<'.unpack('H*',$bytes).'>' }
sub num ($n) { return sprintf('%.2f',$n) =~ s/\.?0+\z//r }
# A text string for the document's information (title, author): UTF-16 with a mark.
sub info_string ($text) { return '<FEFF'.uc(unpack('H*',encode('UTF-16BE',$text))).'>' }
sub bytes ($s) {
    my @pages=@{$s->{pages}};@pages=('') unless @pages;
    my @obj;my $add=sub ($body) {push @obj,$body;return scalar @obj};
    my $catalog=$add->('');my $tree=$add->('');
    my %f=map {($_=>$add->("<< /Type /Font /Subtype /Type1 /BaseFont /$font{$_} /Encoding /WinAnsiEncoding >>"))} qw(R B I);
    my $res='<< /Font << '.join(' ',map {"/F$_ $f{$_} 0 R"} qw(R B I)).' >> >>';
    my @kids;
    for my $i (0..$#pages) {
        my $content=$pages[$i]//'';
        my $stream=$add->('<< /Length '.length($content)." >>\nstream\n$content\nendstream");
        my @a=map {$add->('<< /Type /Annot /Subtype /Link /Rect ['.join(' ',map {num($_)} @{$_->[0]}).'] /Border [0 0 0] /A << /S /URI /URI '.hex_string(encode('UTF-8',$_->[1])).' >> >>')} @{$s->{annots}[$i]//[]};
        push @kids,$add->('<< /Type /Page /Parent '.$tree.' 0 R /MediaBox [0 0 '.PAGE_W.' '.PAGE_H.'] /Resources '.$res.' /Contents '.$stream.' 0 R'.(@a ? ' /Annots ['.join(' ',map {"$_ 0 R"} @a).']' : '').' >>');
    }
    $obj[$tree-1]='<< /Type /Pages /Kids ['.join(' ',map {"$_ 0 R"} @kids).'] /Count '.scalar(@kids).' >>';
    $obj[$catalog-1]="<< /Type /Catalog /Pages $tree 0 R >>";
    my $info=$add->('<< /Title '.info_string($s->{title}//'').(length($s->{author}//'') ? ' /Author '.info_string($s->{author}) : '').' /Producer (BlowfishCMS) >>');
    my $out="%PDF-1.4\n";my @at;
    for my $i (0..$#obj) {push @at,length $out;$out.=($i+1)." 0 obj\n$obj[$i]\nendobj\n"}
    my $xref=length $out;
    $out.="xref\n0 ".(@obj+1)."\n0000000000 65535 f \n".join('',map {sprintf("%010d 00000 n \n",$_)} @at);
    $out.="trailer\n<< /Size ".(@obj+1)." /Root $catalog 0 R /Info $info 0 R >>\nstartxref\n$xref\n%%EOF\n";
    return $out;
}

# Where text goes next: a column x, width w, on page `page` at height y
# (from the bottom, as PDF counts), starting a new page when it's full.
package BlowfishCMS::Addon::Resume::PDF::Column;
use v5.36;
use utf8;
sub new ($class,$pdf,$x,$w,$page,$y) { return bless {pdf=>$pdf,x=>$x,w=>$w,page=>$page,y=>$y},$class }
use constant {MARGIN=>BlowfishCMS::Addon::Resume::PDF::MARGIN,PAGE_H=>BlowfishCMS::Addon::Resume::PDF::PAGE_H};
sub cp1252 { BlowfishCMS::Addon::Resume::PDF::cp1252(@_) }
sub width { BlowfishCMS::Addon::Resume::PDF::width(@_) }
sub num { BlowfishCMS::Addon::Resume::PDF::num(@_) }
sub hex_string { BlowfishCMS::Addon::Resume::PDF::hex_string(@_) }
# Room for $h more points, or a new page.
sub keep ($c,$h) { if ($c->{y}-$h<MARGIN) {$c->{page}++;$c->{y}=PAGE_H-MARGIN} }
sub gap ($c,$h) { $c->{y}-=$h }
sub out ($c,$text) { ${$c->{pdf}->stream($c->{page})}.=$text }
# Words (bytes) into lines no wider than $w.
sub wrap ($c,$bytes,$f,$size,$w) {
    my @lines;my $line='';
    for my $word (split / /,$bytes) {
        my $try=length $line ? "$line $word" : $word;
        if (length $line && width($try,$f,$size)>$w) {push @lines,$line;$line=$word} else {$line=$try}
        # A word wider than the line is cut where it must be.
        while (width($line,$f,$size)>$w && length($line)>1) {
            my $n=length $line;$n-- while $n>1 && width(substr($line,0,$n),$f,$size)>$w;
            push @lines,substr($line,0,$n);$line=substr($line,$n);
        }
    }
    push @lines,$line if length $line;
    return @lines;
}
sub line ($c,$bytes,%o) {
    my ($f,$size)=($o{font}//'R',$o{size}//9);my $lead=$size*1.25;
    $c->keep($lead);$c->{y}-=$size;
    $c->out(($o{grey} ? '0.38 g ' : '0 g ').'BT /F'.$f.' '.num($size).' Tf '.num($c->{x}+($o{indent}//0)).' '.num($c->{y}).' Td '.hex_string($bytes)." Tj ET\n");
    $c->{y}-=$lead-$size;
}
sub text ($c,$text,%o) {
    my $bytes=cp1252($text =~ s/\s+/ /gr =~ s/\A | \z//gr);
    my $w=$c->{w}-($o{indent}//0);
    $c->line($_,%o) for $c->wrap($bytes,$o{font}//'R',$o{size}//9,$w);
    $c->{y}-=$o{after}//0;
}
# Items joined by “ · ”, wrapping between them; [text, link] are linked.
sub links ($c,$items,%o) {
    my $size=$o{size}//9;my $sep=cp1252(' · ');my ($x,@pending)=(0);
    return unless @$items;
    my $flush=sub {
        return unless @pending;
        $c->keep($size*1.25);my $y=$c->{y}-$size;my $line='';my $at=$c->{x};
        for my $p (@pending) {
            my ($bytes,$url,$lead)=@$p;
            $line.=$lead;$at+=width($lead,'R',$size);
            push @{$c->{pdf}{annots}[$c->{page}]},[[$at,$y-2,$at+width($bytes,'R',$size),$y+$size],$url] if length $url;
            $line.=$bytes;$at+=width($bytes,'R',$size);
        }
        $c->line($line,%o);@pending=();$x=0;
    };
    for my $item (@$items) {
        my $bytes=cp1252($item->[0]);my $lead=@pending ? $sep : '';
        $flush->() if @pending && $x+width($lead.$bytes,'R',$size)>$c->{w};
        $lead=@pending ? $sep : '';
        push @pending,[$bytes,$item->[1],$lead];$x+=width($lead.$bytes,'R',$size);
    }
    $flush->();
    $c->{y}-=$o{after}//0;
}
sub heading ($c,$title) {
    return unless length($title//'');
    $c->keep(44);
    $c->text($title,font=>'B',size=>10.5,after=>0);
    $c->out('0.6 G 0.6 w '.num($c->{x}).' '.num($c->{y}+1).' m '.num($c->{x}+$c->{w}).' '.num($c->{y}+1)." l S\n");
    $c->{y}-=5;
}
# Markdown, as plain text: paragraphs, and “- ” or “* ” points as bullets.
sub plain ($text) { return $text =~ s/\[([^\]]*)\]\([^)]*\)/$1/gr =~ s/(\*\*|__|\*|_|`)(\S(?:.*?\S)?)\1/$2/gr =~ s/\\([\\`*_{}\[\]()#+\-.!])/$1/gr =~ s/\A#+\s*//r }
sub markdown ($c,$text,%o) {
    my $size=$o{size}//9;
    my @paras;
    for my $line (split /\n/,$text//'') {
        if ($line =~ /\A\s*[-*+]\s+(.*)/) {push @paras,['•',$1]}
        elsif ($line =~ /\S/) {
            if (@paras && !defined $paras[-1][0] && !$paras[-1][2]) {$paras[-1][1].=" $line"} else {push @paras,[undef,$line]}
        }
        elsif (@paras) {$paras[-1][2]=1}
    }
    for my $p (@paras) {
        if (defined $p->[0]) {
            my $indent=9;my @lines=$c->wrap(cp1252(plain($p->[1]) =~ s/\s+/ /gr =~ s/\A | \z//gr),'R',$size,$c->{w}-$indent);
            my $first=1;
            for (@lines) {$c->line($_,size=>$size,indent=>$indent);if ($first) {my $y=$c->{y}+$size*0.25;$c->out('0 g BT /FR '.num($size).' Tf '.num($c->{x}+1).' '.num($y).' Td '.hex_string(cp1252('•'))." Tj ET\n");$first=0}}
            $c->{y}-=1;
        }
        else {$c->text(plain($p->[1]),size=>$size,after=>3)}
    }
}

1;