Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

accept and emit "screen" sections

  • Loading branch information...
commit 439bec6636dee3f570f69989b65dacfbf22caf51 1 parent 7a7c642
@moritz authored
Showing with 37 additions and 4 deletions.
  1. +27 −3 lib/Pod/PseudoPod/LaTeX.pm
  2. +4 −1 t/sections.t
  3. +6 −0 t/test_file.pod
View
30 lib/Pod/PseudoPod/LaTeX.pm
@@ -1,6 +1,8 @@
package Pod::PseudoPod::LaTeX;
use Pod::PseudoPod 0.16;
+;
+our $VERSION = 1.101070;
use base 'Pod::PseudoPod';
use 5.008006;
@@ -14,11 +16,12 @@ sub new
my $self = $class->SUPER::new(%args);
$self->accept_targets_as_text(
- qw( sidebar blockquote programlisting figure table PASM PIR PIR_FRAGMENT PASM_FRAGMENT PIR_FRAGMENT_INVALID)
+ qw( sidebar blockquote programlisting screen figure table PASM PIR PIR_FRAGMENT PASM_FRAGMENT PIR_FRAGMENT_INVALID)
);
$self->{scratch} ||= '';
$self->{stack} = [];
+ $self->{labels} = { screen => 'Program output'};
return $self;
}
@@ -54,6 +57,8 @@ sub encode_text
$text =~ s/\\/\\backslash/g; # backslashes are special
$text =~ s/([#\$&%_{}])/\\$1/g;
$text =~ s/(\^)/\\char94{}/g; # carets are special
+ $text =~ s/</\\textless{}/g;
+ $text =~ s/>/\\textgreater{}/g;
$text =~ s/(\\backslash)/\$$1\$/g; # add unescaped dollars
@@ -286,10 +291,17 @@ sub start_Verbatim
{
my $self = shift;
- # $self->{scratch} .= "\\addtolength{\\parskip}{-5pt}\n";
+ my $verb_options = "commandchars=\\\\\\{\\}";
+ eval {
+ if ($self->{curr_open}[-1][-1]{target} eq 'screen') {
+ $verb_options .= ',frame=single,label='
+ . $self->{labels}{screen};
+ }
+ };
+
$self->{scratch} .= "\\vspace{-6pt}\n"
. "\\scriptsize\n"
- . "\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n";
+ . "\\begin{Verbatim}[$verb_options]\n";
$self->{flags}{in_verbatim}++;
}
@@ -305,6 +317,18 @@ sub end_Verbatim
$self->emit();
}
+
+sub end_screen
+{
+ my $self = shift;
+ $self->{scratch} .= "\n\\end{Verbatim}\n"
+ . "\\vspace{-6pt}\n";
+
+ # $self->{scratch} .= "\\addtolength{\\parskip}{5pt}\n";
+ $self->{scratch} .= "\\normalsize\n";
+ $self->{flags}{in_verbatim}--;
+ $self->emit();
+}
sub start_figure
{
my ( $self, $flags ) = @_;
View
5 t/sections.t
@@ -6,7 +6,7 @@ use warnings;
use IO::String;
use File::Spec::Functions;
-use Test::More tests => 15;
+use Test::More tests => 16;
use_ok( 'Pod::PseudoPod::LaTeX' ) or exit;
@@ -33,6 +33,9 @@ like( $text, qr/\\subsubsection\*{c heading}/,
like( $text, qr/\\begin{Verbatim}.+"This text.+--.+\$text."\n\\end{Verbatim}/s,
'programlistings should become unescaped, verbatim text' );
+like( $text, qr/\\begin{Verbatim}.*label=.+This should also be \$unm0d\+ified\n\\end{Verbatim}/s,
+ 'screens should become unescaped, verbatim text' );
+
like( $text, qr/Blockquoted text.+``escaped''\./,
'blockquoted text gets escaped' );
View
6 t/test_file.pod
@@ -13,6 +13,12 @@ Here is some ignorable text.
This indented text should come through unmodified too -- it is also "normal"
$text.
+=begin screen
+
+ This should also be $unm0d+ified
+
+=end screen
+
=begin blockquote
Blockquoted text may or may not need "escaped". I haven't decided.
Please sign in to comment.
Something went wrong with that request. Please try again.