Bundle-PBib

 view release on metacpan or  search on metacpan

lib/PBib/Document.pm  view on Meta::CPAN

Methods used by PBib to create formatted text.

=over

=cut


#
#
# char set converting methods
#
#

sub quote { my ($self, $text) = @_; return $text; }
sub unquote { my ($self, $text) = @_; return $text; }

sub quoteFieldId { my ($self, $text) = @_;
	#
	# return a valid field ID
	#
	return $text;
}

#
#
# text formating methods
#
#

sub formatRange {
	my ($self, $text) = @_;
	$text =~ s/\s*-(-?)\s*/-/g if defined $text;
	return $text;
}

sub paragraph {
	my ($self, $text) = @_;
	$text = '' unless $text;
	return "$text\n";
}
sub linebreak {
	my ($self, $text) = @_;
	$text = '' unless $text;
	return "$text\n";
}
sub singleQuotes { my ($self, $text) = @_;
# return $text enclosed in single quotes
  return "'$text'";
}
sub doubleQuotes { my ($self, $text) = @_;
# return $text enclosed in double quotes
  return "\"$text\"";
}

# text styles

sub italic { my ($self, $text) = @_;
# return $text as italic
  return $text;
}
sub bold { my ($self, $text) = @_;
# return $text as bold
  return $text;
}
sub underline { my ($self, $text) = @_;
# return $text as underlined
  return $text;
}

sub highlight { my ($self, $text) = @_;
# return $text highlighted, whatever this means.
# It could be bold + italic, or colored etc.
  return $self->bold($self->italic($text));
}

# fonts

sub tt { my ($self, $text) = @_;
# return text in typewriter (Courier) font
  return $text;
}

# fields

sub bookmark {
# return $text marked as bookmark (with $id as bookmark)
  my ($self, $text, $id) = @_;
  return $text;
}

sub bookmarkLink {
# return $text marked as a hyperlink to bookmark $id
  my ($self, $text, $id) = @_;
  return $text;
}

sub hyperlink {
# return $text marked as a hyperlink to $url
  my ($self, $text, $url) = @_;
  $url = $text unless( $url );
  return $text eq $url ? $text : "$text ($url)";
}

sub comment { my ($self, $text) = @_;
	return $self->bold($self->italic($text));
}

#
#
# bibliography formating methods
#
#


sub bibitems_start { my ($self) = @_; return ""; }
sub bibitems_separator { my ($self) = @_; return $self->paragraph(); }
sub bibitems_end { my ($self) = @_; return ""; }

sub block_start { my ($self) = @_; return ""; }
sub block_separator { my ($self) = @_; return ' '; }
sub block_end { my ($self) = @_; return ""; }

sub sentence_start { my ($self) = @_; return ""; }
sub sentence_separator { my ($self) = @_; return ". "; }
sub sentence_end { my ($self) = @_; return "."; }

sub phrase_start { my ($self) = @_; return ""; }
sub phrase_separator { my ($self) = @_; return ", "; }
sub phrase_end { my ($self) = @_; return ""; }

sub spaceConnect { my $self = shift;
# connect all args with spaces
  return join($self->quote(" "), @_);
}
sub tieConnect { my ($self, $a, $b) = @_;
  # use non-breaking-space
  return $self->spaceConnect($a, $b);
}
sub tieOrSpaceConnect { my ($self, $a, $b) = @_;
  # use non-breaking-space, if $a or $b is short (i.e. < 3 characters)
  return '' if ! defined $a && ! defined $b;
  return $a if ! defined $b;
  return $b if ! defined $a;
  return length($a) < 5 || length($b) < 3 ?
	$self->tieConnect($a, $b) :
	$self->spaceConnect($a, $b);
}


##############################################

=back

=head1 Interactive Editing Methods

Methods used by PBib for interactive editing of documents, e.g. open in editor.

=over

=cut


sub openInEditor { my ($self) = @_;
  my $filename = $self->filename();
  if( not defined($filename) ) {



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