⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 latex.pm

📁 MSYS在windows下模拟了一个类unix的终端
💻 PM
📖 第 1 页 / 共 3 页
字号:
    } else {      my ($file, $line) = $pod_seq->file_line();      warn "Escape sequence $seq_argument not recognised at line $line of file $file\n";      return;    }  } elsif ($seq_command eq 'Z') {    # Zero width space    return '$\!$'; # '  } elsif ($seq_command eq 'C') {    return "\\texttt{$seq_argument}";  } elsif ($seq_command eq 'F') {    return "\\emph{$seq_argument}";  } elsif ($seq_command eq 'S') {    # non breakable spaces    my $nbsp = '$\:$'; #'    $seq_argument =~ s/\s/$nbsp/g;    return $seq_argument;  } elsif ($seq_command eq 'L') {    my $link = new Pod::Hyperlink($seq_argument);    # undef on failure    unless (defined $link) {      carp $@;      return;    }    # Handle internal links differently    my $type = $link->type;    my $page = $link->page;    if ($type eq 'section' && $page eq '') {      # Use internal latex reference       my $node = $link->node;      # Convert to a label      $node = $self->_create_label($node);      return "\\S\\ref{$node}";    } else {      # Use default markup for external references      # (although Starlink would use \xlabel)      my $markup = $link->markup;      my ($file, $line) = $pod_seq->file_line();      return $self->interpolate($link->markup, $line);    }  } elsif ($seq_command eq 'P') {    # Special markup for Pod::Hyperlink    # Replace :: with /    my $link = $seq_argument;    $link =~ s/::/\//g;    my $ref = "\\emph{$seq_argument}";    return $ref;  } elsif ($seq_command eq 'Q') {    # Special markup for Pod::Hyperlink    return "\\textsf{$seq_argument}\n";  } elsif ($seq_command eq 'X') {    # Index entries    # use \index command    # I will let '!' go through for now    # not sure how sub categories are handled in X<>    my $index = $self->_create_index($seq_argument);    return "\\index{$index}\n";  } else {    carp "Unknown sequence $seq_command<$seq_argument>";  }}=back=head2 List MethodsMethods used to handle lists.=over 4=item B<begin_list>Called when a new list is found (via the C<over> directive).Creates a new C<Pod::List> object and stores it on the list stack.  $parser->begin_list($indent, $line_num);=cutsub begin_list {  my $self = shift;  my $indent = shift;  my $line_num = shift;  # Indicate that a list should be started for the next item  # need to do this to work out the type of list  push ( @{$self->lists}, new Pod::List(-indent => $indent, 					-start => $line_num,					-file => $self->input_file,				       )	        );}=item B<end_list>Called when the end of a list is found (the C<back> directive).Pops the C<Pod::List> object off the stack of lists and writesthe C<latex> code required to close a list.  $parser->end_list($line_num);=cutsub end_list {  my $self = shift;  my $line_num = shift;  unless (defined $self->lists->[-1]) {    my $file = $self->input_file;    warn "No list is active at line $line_num (file=$file). Missing =over?\n";    return;  }  # What to write depends on list type  my $type = $self->lists->[-1]->type;  # Dont write anything if the list type is not set  # iomplying that a list was created but no entries were  # placed in it (eg because of a =begin/=end combination)  $self->_output("\\end{$type}\n")    if (defined $type && length($type) > 0);    # Clear list  pop(@{ $self->lists});}=item B<add_item>Add items to the list. The first time an item is encountered (determined from the state of the current C<Pod::List> object)the type of list is determined (ordered, unnumbered or description)and the relevant latex code issued.  $parser->add_item($paragraph, $line_num);=cutsub add_item {  my $self = shift;  my $paragraph = shift;  my $line_num = shift;  unless (defined $self->lists->[-1]) {    my $file = $self->input_file;    warn "List has already ended by line $line_num of file $file. Missing =over?\n";    # Replace special chars#    $paragraph = $self->_replace_special_chars($paragraph);    $self->_output("$paragraph\n\n");    return;  }  # If paragraphs printing is turned off via =begin/=end or whatver  # simply return immediately  return if ($self->{_suppress_all_para} || $self->{_suppress_next_para});  # Check to see whether we are starting a new lists  if (scalar($self->lists->[-1]->item) == 0) {    # Examine the paragraph to determine what type of list    # we have    $paragraph =~ s/\s+$//;    $paragraph =~ s/^\s+//;    my $type;    if (substr($paragraph, 0,1) eq '*') {      $type = 'itemize';    } elsif ($paragraph =~ /^\d/) {      $type = 'enumerate';    } else {      $type = 'description';    }    $self->lists->[-1]->type($type);    $self->_output("\\begin{$type}\n");  }  my $type = $self->lists->[-1]->type;  if ($type eq 'description') {    # Handle long items - long items do not wrap    if (length($paragraph) < 40) {      # A real description list item      $self->_output("\\item[$paragraph] \\mbox{}");    } else {      # The item is now simply bold text      $self->_output(qq{\\item \\textbf{$paragraph}});    }  } else {    # If the item was '* Something' we still need to write    # out the something    my $extra_info = $paragraph;    $extra_info =~ s/^\*\s*//;    $self->_output("\\item $extra_info");  }  # Store the item name in the object. Required so that   # we can tell if the list is new or not  $self->lists->[-1]->item($paragraph);}=back=head2 Methods for headings=over 4=item B<head>Print a heading of the required level.  $parser->head($level, $paragraph, $parobj);The first argument is the pod heading level. The second argumentis the contents of the heading. The 3rd argument is a Pod::Paragraphobject so that the line number can be extracted.=cutsub head {  my $self = shift;  my $num = shift;  my $paragraph = shift;  my $parobj = shift;  # If we are replace 'head1 NAME' with a section  # we return immediately if we get it  return     if ($self->{_CURRENT_HEAD1} =~ /^NAME/i && $self->ReplaceNAMEwithSection());  # Create a label  my $label = $self->_create_label($paragraph);  # Create an index entry  my $index = $self->_create_index($paragraph);  # Work out position in the above array taking into account  # that =head1 is equivalent to $self->Head1Level  my $level = $self->Head1Level() - 1 + $num;  # Warn if heading to large  if ($num > $#LatexSections) {    my $line = $parobj->file_line;    my $file = $self->input_file;    warn "Heading level too large ($level) for LaTeX at line $line of file $file\n";    $level = $#LatexSections;  }  # Check to see whether section should be unnumbered  my $star = ($level >= $self->LevelNoNum ? '*' : '');  # Section  $self->_output("\\" .$LatexSections[$level] .$star ."{$paragraph\\label{".$label ."}\\index{".$index."}}");}=back=end __PRIVATE__=begin __PRIVATE__=head2 Internal methodsInternal routines are described in this section. They do not form part of thepublic interface. All private methods start with an underscore.=over 4=item B<_output>Output text to the output filehandle. This method must be always be calledto output parsed text.   $parser->_output($text);Does not write anything if a =begin or =for is active that should beignored.=cutsub _output {   my $self = shift;  my $text = shift;  print { $self->output_handle } $text     unless $self->{_suppress_all_para} ||      $self->{_suppress_next_para};  # Reset pargraph stuff for =for  $self->{_suppress_next_para} = 0    if $self->{_suppress_next_para};}=item B<_replace_special_chars>Subroutine to replace characters that are special in C<latex>with the escaped forms  $escaped = $parser->_replace_special_chars($paragraph);Need to call this routine before interior_sequences are munged butnot if verbatim.Special characters and the C<latex> equivalents are:  }     \}  {     \{  _     \_  $     \$  %     \%  &     \&  \     $\backslash$  ^     \^{}  ~     \~{}  |     $|$=cutsub _replace_special_chars {  my $self = shift;  my $paragraph = shift;  # Replace a \ with $\backslash$  # This is made more complicated because the dollars will be escaped  # by the subsequent replacement. Easiest to add \backslash   # now and then add the dollars  $paragraph =~ s/\\/\\backslash/g;  # Must be done after escape of \ since this command adds latex escapes  # Replace characters that can be escaped  $paragraph =~ s/([\$\#&%_{}])/\\$1/g;  # Replace ^ characters with \^{} so that $^F works okay  $paragraph =~ s/(\^)/\\$1\{\}/g;  # Replace tilde (~) with \texttt{\~{}}  $paragraph =~ s/~/\\texttt\{\\~\{\}\}/g;  # Replace | with $|$  $paragraph =~ s'\|'$|$'g;  # Now add the dollars around each \backslash  $paragraph =~ s/(\\backslash)/\$$1\$/g;  return $paragraph;}=item B<_create_label>Return a string that can be used as an internal referencein a C<latex> document (i.e. accepted by the C<\label> command) $label = $parser->_create_label($string)If UniqueLabels is true returns a label prefixed by Label()This can be suppressed with an optional second argument. $label = $parser->_create_label($string, $suppress);If a second argument is supplied (of any value including undef)the Label() is never prefixed. This means that this routine canbe called to create a Label() without prefixing a previous setting.=cutsub _create_label {  my $self = shift;  my $paragraph = shift;  my $suppress = (@_ ? 1 : 0 );  # Remove latex commands  $paragraph = $self->_clean_latex_commands($paragraph);  # Remove non alphanumerics from the label and replace with underscores  # want to protect '-' though so use negated character classes   $paragraph =~ s/[^-:\w]/_/g;  # Multiple underscores will look unsightly so remove repeats  # This will also have the advantage of tidying up the end and  # start of string  $paragraph =~ s/_+/_/g;  # If required need to make sure that the label is unique  # since it is possible to have multiple pods in a single  # document  if (!$suppress && $self->UniqueLabels() && defined $self->Label) {    $paragraph = $self->Label() .'_'. $paragraph;  }  return $paragraph;}=item B<_create_index>Similar to C<_create_label> except an index entry is created.If C<UniqueLabels> is true, the index entry is prefixed by the current C<Label> and an exclamation mark.  $ind = $parser->_create_index($paragraph);An exclamation mark is used by C<makeindex> to generate sub-entries in an index.=cutsub _create_index {  my $self = shift;  my $paragraph = shift;  my $suppress = (@_ ? 1 : 0 );  # Remove latex commands  $paragraph = $self->_clean_latex_commands($paragraph);  # If required need to make sure that the index entry is unique  # since it is possible to have multiple pods in a single  # document  if (!$suppress && $self->UniqueLabels() && defined $self->Label) {    $paragraph = $self->Label() .'!'. $paragraph;  }  # Need to replace _ with space  $paragraph =~ s/_/ /g;  return $paragraph;}=item B<_clean_latex_commands>Removes latex commands from text. The latex command is assumed to be of theform C<\command{ text }>. "C<text>" is retained  $clean = $parser->_clean_latex_commands($text);=cutsub _clean_latex_commands {  my $self = shift;  my $paragraph = shift;  # Remove latex commands of the form \text{ }  # and replace with the contents of the { }  # need to make this non-greedy so that it can handle  #  "\text{a} and \text2{b}"  # without converting it to  #  "a} and \text2{b"  # This match will still get into trouble if \} is present   # This is not vital since the subsequent replacement of non-alphanumeric  # characters will tidy it up anyway  $paragraph =~ s/\\\w+{(.*?)}/$1/g;  return $paragraph}=back=end __PRIVATE__=head1 NOTESCompatible with C<latex2e> only. Can not be used with C<latex> v2.09or earlier.A subclass of C<Pod::Select> so that specific pod sections can beconverted to C<latex> by using the C<select> method.Some HTML escapes are missing and many have not been tested.=head1 SEE ALSOL<Pod::Parser>, L<Pod::Select>, L<pod2latex>=head1 AUTHORSTim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>=head1 COPYRIGHTCopyright (C) 2000 Tim Jenness. All Rights Reserved.This program is free software; you can redistribute it and/or modify itunder the same terms as Perl itself.=begin __PRIVATE__=head1 REVISION$Id: LaTeX.pm,v 1.6 2000/08/21 09:05:03 timj Exp $=end __PRIVATE__=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -