#!/usr/bin/env perl

use strict;
use warnings;

use open qw(:std :utf8);
use feature 'unicode_strings';
use utf8;

my $text;
if (@ARGV) {
    my $file = shift @ARGV;
    open(my $fh, '<', $file) or die $!;
    local $/;
    $text = <$fh>;
    close $fh;
}
else {
    local $/;
    $text = <>;
}

# typography enhanced for pdf made via xelatex
$text =~ s/(—~?[\.,:;])/\\mbox{$1}/g;
$text =~ s/«\~/« /g;
$text =~ s/\~»/ »/g;

print $text;

