Bundle-PBib
view release on metacpan or search on metacpan
lib/PBib/Document/RTF.pm view on Meta::CPAN
$text =~ s/\\lang[a-z]*\d* ?//g;
$text =~ s/\\noproof ?//g;
# convert HEX characters
$text =~ s/\\'(..)/ chr(hex($1)) /eg;
$text =~ s/\\emdash ?/---/g;
$text =~ s/\\endash ?/--/g;
$text =~ s/\r?\n//g;
return $text;
}
sub quoteFieldId { my ($self, $id) = @_;
#
# return a valid field ID
#
# strip all non-bookmark chars, and add a prefix "r"
#
$id =~ s/[^A-Z0-9]//gi;
return $id;
}
#
#
# text formating methods
#
#
sub formatRange {
my ($self, $text) = @_;
$text =~ s/\s*-(-?)\s*/\\endash /g if defined $text;
return $text;
}
sub paragraph { my ($self, $text) = @_;
# return "\{\\pard $text\\par\}\n";
# \\pard without pard the par inherits formating from previous paragraph.
# That's what we are likely to want in bibliographies ...
return "\{$text\\par\}\n";
}
sub linebreak { my ($self) = @_;
# return code that stands for a line-break
return "\\line\n";
}
sub singleQuotes { my ($self, $text) = @_;
# return $text enclosed in single quotes
return "\\lquote $text\\rquote ";
}
sub doubleQuotes { my ($self, $text) = @_;
# return $text enclosed in double quotes
return "\\ldblquote $text\\rdblquote ";
}
# text styles
sub italic {
my ($self, $text) = @_;
return "{\\i $text}";
}
sub bold {
# return $text as bold
my ($self, $text) = @_;
return "{\\b $text}";
}
sub underlined {
# return $text as underlined
my ($self, $text) = @_;
return "{\\u $text}";
}
# fonts
sub tt { my ($self, $text) = @_;
# return text in tyoewriter font
### well, maybe not that easy ...
return $text;
}
# fields
sub field {
my ($self, $text, $code) = @_;
return "{\\field{\\*\\fldinst {$code}}{\\fldrslt {$text}}}";
}
sub bookmark {
my ($self, $text, $bookmark) = @_;
return "\{$text\}" unless defined($bookmark);
return "\{\{\\*\\bkmkstart $bookmark\}$text\{\\*\\bkmkend $bookmark\}\}";
}
sub bookmarkLink {
# return $text marked as a hyperlink to bookmark $id
my ($self, $text, $id) = @_;
return $self->field($text, " HYPERLINK \\\\l $id");
}
sub hyperlink {
# return $text marked as bookmark (with $refID as bookmark)
my ($self, $text, $url) = @_;
$url = $text unless( $url );
return $self->field($text, " HYPERLINK $url");
}
sub bibitems_start { my ($self) = @_; return "{"; }
sub bibitems_separator { my ($self) = @_; return "\\par\n"; }
sub bibitems_end { my ($self) = @_; return "}\n"; }
sub block_start { my ($self) = @_; return "{"; }
sub block_separator { my ($self) = @_; return " "; }
sub block_end { my ($self) = @_; return "}\n"; }
sub tieConnect { my $self = shift;
# use non-breaking-space
return join("\\~", @_);
}
sub comment { my ($self, $text) = @_;
return "{\\v $text}\n";
( run in 2.160 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )