PerlPoint-Package

 view release on metacpan or  search on metacpan

Changelog  view on Meta::CPAN

	
	
=0.43

\ILLT

==Features

\ILLT

===Import filter API for the INCLUDE and EMBED tags

PerlPoint supports import filters for other formats since package version
0.38, via tag option \C<ifilter>:

  \\INCLUDE{type=pp ifilter='pod2pp' file="file.pod"}

Nevertheless, this could be simplified. With the new option C<import>
this can be written as

  \\INCLUDE{type=pp import=pod file="file.pod"}

Changelog  view on Meta::CPAN


This feature applies to all existing converters automatically.

	
===Misc

* new option \BC<-version> for \C<perlpoint> and \C<PerlPoint::Generator>,
  thanks to Achim Grolms for the suggestion;
	
* the default file type for C<\\INCLUDE> and the default language for
  \C<\\EMBED> are \C<pp> now;
	
* all generator based converters now accept the new option \C<-acceptedFormat>,
  which specifies languages to be accepted in included files or embedded
  snippets (with \C<\\INCLUDE> or \C<\\EMBED>);

* parser: slight code optimizations;

	
=0.42

The main intention of this update is to allow the production of better
structured results (like correct XHTML). On the way to there, fixes and
improvements were made.

Changelog  view on Meta::CPAN


* Tag authors can declare their tags as standalone now. If the parser
  finds a text paragraph is occupied by such a tag entirely, the
  paragraph "wrapper" is removed from the stream. This allows to
  produce better output for tags that are transformed into something
  that does not fit into a paragraph. (We had this before for images
  and a few other special tags, but now this is a general mechanism.)
  Standalone tags not used standalone have no special effect.

* Likewise, if all that is found in a paragraph is an embedded area
  (\C<\\EMBED{...} ... \\END_EMBED>, the wrapping paragraph directives
  are removed from the stream.

* \C<IMAGE> tags now get an \C<alt> option by default unless they define
  their own (the default is "Image").
	
* \C<perlpoint> now reads option files from the start directory, allowing to
  have a \C<.perlpoint> file in a project tree.

	
	

Changelog  view on Meta::CPAN


==Changes

* Tags are streamed with an additional information. Both opening and closing
  directives now provide a body hint telling a backend programmer if the tag
  has a body or not.

* The lexer makes use of precompiled patterns now, but it seems not to affect
  the performance of parsing.

* \C<\\INCLUDE>, \C<\\EMBED> and \C<\\TABLE> now support the \C<_cnd_> option,
  like tags defined externally.

* Embedded parts and included files can be preprocessed by the new "input
  filters" - snippets of PerlPoint author defined Perl code transforming
  the included or embedded parts before they are processed as usual. This
  is a generic implementation of sourcefile import.

  For example, it is possible to process POD sources
  directly now. Here is a simple filter that does the job:

  \\EMBED{lang=perl}

  use Pod::PerlPoint 0.03;

  sub pod2pp
   {
    my ($pod2pp, $result)=(new Pod::PerlPoint());
    $pod2pp->output_string(\\$result);
    $pod2pp->parse_string_document(@main::_ifilterText);
    $result;
   }

  \\END_EMBED


* Or try the new demo source file, \C<demo/perlpods.pp>, with your favourite
  PerlPoint converter. (Make sure the cache is deactivated and you are using
  \C<-active -safe ALL>. Depending on your system, this is a CPU, memory and
  time consuming job producing over 12.000 pages when processed with perl 5.8.0.)

* Demo converters \C<pp2pod>, \C<pp2pp> and \C<pp2tree> got the usual interface
  (supporting traces etc.).

Changelog  view on Meta::CPAN

The filters results must be valid PerlPoint which will then be
reparsed.

So finally those filters are there. Here is a complete example to
demonstrate how this feature can be used. The example document
contains a verbatim block of Perl code, which is made a block by
a user filter. The simple filter marks all Perl comments bold
(using a straight forward comment detection).

  // define the paragraph filter
  \\EMBED{lang=perl}

  sub formatComments
   {
    # $main::_pfilterText is used to
    # pass the paragraph content
    $main::_pfilterText=~s/(#.+)$/\\\\B<$1>/mg;
    $main::_pfilterText;
   }

  \\END_EMBED

  Now, an example in a verbatim block paragraph:

  \B<||formatComments||><<EOM

    # 1st comment
    This is my example. # 2nd comment

    Continued.

TODO  view on Meta::CPAN

implementation if possible. If you like it so much that you want to
implement it yourself, this might be possible - please contact us.


=General

* Bodyless macro call before a new chapter inserts an additional headline (delayed "=")
  when the macro opens an included file and produces additional paragraphs.

* add tests for the \C<_cnd>_ option (both for generic tags declared by modules and the builtin
  ones like \C<\\INCLUDE>, \C<\\EMBED> and \C<\\TABLE>)

* publish a collection of example filters

* publish a collection of example code

* improve the SourceForge project homepage, include areas for user provides macros, filters,
  code, examples etc.

* The Emacs 19.x lisp file does not work under Emacs 21.x. I made a workaround, but it
  still produces an error message. Check if it still works with older Emacs versions, and

demo/perlpods.pp  view on Meta::CPAN

//


//
// Recommended converter options: "-active -safe ALL".
//
//              Do *not* use the cache!
// 


\EMBED{lang=perl}

# load libraries
use Pod::PerlPoint;
use File::Basename;
use Config qw(%Config);

# declare the filter function
sub pod2pp
 {
  my ($pod2pp, $result)=(new Pod::PerlPoint());

demo/perlpods.pp  view on Meta::CPAN

  $result;
 }

# build output from all POD files in the distribution of the running perl
my $pp="\n\n";
$pp=join('', $pp, "\n=", basename($_, '.pod'), qq(\n\n\\INCLUDE{file="$_" ifilter=pod2pp type=pp headlinebase=CURRENT_LEVEL}), "\n\n") for (sort <$Config{privlib}/pod/*.pod>);

# provide result
$pp;

\END_EMBED

demo/pp2ppresenter  view on Meta::CPAN

All supported tags are declared by B<PerlPoint::Tags::SDF> (currently, this shall become
C<PerlPoint::Tags::XML>). Please see there for a complete list.

B<pp2ppresenter> supports several foreign tags initially introduced by C<pp2html>.
Support means that they are handled, but possibly different to the original handling.

At the moment, the only tag of this type is C<\L>, which is translated into an HTML
like hyperlink. Note: PPresenter support of hyperlinks is only assumed yet.


=head1 EMBEDDING TARGET CODE

There may be things you want to see in the target document but find no way to express
them in PerlPoint. Well, PerlPoint lets you embed target code very easily directly into
the PerlPoint script. Nevertheless, it is recommended to use native PerlPoint wherever
possible ;-).

Please note that embedded target code intended for certain translators like B<pp2ppresenter>
may be B<I<ignored>> if the PerlPoint document is processed by I<other> translators.
pp2html, for example, accepts embedded HTML but ignores embedded XML.

=head2 Embedding XML

Just use the B<\EMBED> and B<\END_EMBED> tags to place native XML if really
necessary:

  This is \I<PerlPoint> with embedded
  \EMBED{lang=xml}<B>XML<B/>\END_EMBED.

  \EMBED{lang=xml}

  <UL>

    <LI>This ...<LI/>

    <LI>... and that.<LI/>

  <UL/>

  \END_EMBED

You may as well I<include> complete XML files by B<\INCLUDE>.

  \INLUDE{type=xml file="snippet.xml"}


=head2 Embedding other languages

B<pp2ppresenter> will ignore any other embedded or included target language than XML.

demo/pp2sdf  view on Meta::CPAN

Marks the body to be underlined

 Example:

  \U<text> becomes "{{U:text}}".


=back


=head1 EMBEDDING TARGET CODE

There may be things you want to see in the target document but find no way to express
them in PerlPoint. Well, PerlPoint lets you embed target code very easily directly into
the PerlPoint script. Nevertheless, it is recommended to use native PerlPoint wherever
possible ;-).

Please note that embedded target code intended for certain translators like B<pp2sdf>
may be B<I<ignored>> if the PerlPoint document is processed by I<other> translators.
pp2html, for example, accepts embedded HTML but ignores embedded SDF.

=head2 Embedding SDF

Just use the B<\EMBED> and B<\END_EMBED> tags to place native SDF if really
necessary:

  This is \I<PerlPoint> with embedded
  \EMBED{lang=sdf}{{B:SDF}}\END_EMBED.

  \EMBED{lang=sdf}

  H2: An SDF chapter

  Note: An SDF note.

  \END_EMBED

You may as well I<include> complete SDF files by B<\INCLUDE>.

  \INLUDE{type=sdf file="snippet.sdf"}


=head2 Embedding HTML

is as easy as embedding SDF directly. It is, of course, only useful if you plan
to transform your presentation to an HTML page via SDF. You can embed complete
HTML sections:

  \EMBED{lang=html}

  <h1>An HTML chapter</h1>

  <p>
  This was written in <i>HTML</i>.

  \END_EMBED

This way B<pp2sdf> will produce SDF inline blocks like this:

  !block inline

  <h1>An HTML chapter</h1>

  <p>
  This was written in <i>HTML</i>.

  !endblock

Further proceeding is up to sdf, so please refer to the SDF manuals for details.

Alternatively, you may choose to embed HTML directly into a PerlPoint paragraph:

  This is \I<PerlPoint> with embedded
  \EMBED{lang=html}<b>HTML</b>\END_EMBED.

This will be translated into an SDF inline I<phrase>:

  This is {{I:PerlPoint}} with embedded {{INLINE:<b>HTML</b>}}.

Please note that for unknown reasons SDF processes POD tags in inlined I<phrases> (even
if it was not intended to use POD). In the example above, this causes a wrong result
because an C<L> tag is assumed. This is currently a feature of sdf, not pp2sdf.

HTML code can be embedded by complete I<files> as well, of course:

demo/pp2sdf  view on Meta::CPAN

    }
  elsif ($tag eq 'TABLE_HL')
    {
     # act mode dependend
     push(@{$table->{rows}[-1]}, '{{B:') if $mode==DIRECTIVE_START;
     $table->{rows}[-1][-1].='}}'        if $mode==DIRECTIVE_COMPLETE;

     # ok, well done
     return(1);
    }
  elsif ($tag eq 'EMBED' and $settings->{lang}=~/^sdf$/i)
    {
     # act mode dependend
     if ($mode==DIRECTIVE_START)
       {
        # flag that we are within embedded SDF
        $flags{sdf}=1;
       }
     else
       {
        # flag that embedded SDF is completed
        $flags{sdf}=0;
       }

     # ok, well done
     return(1);
    }
  elsif ($tag eq 'EMBED' and $settings->{lang}=~/^html$/i)
    {
     # act mode dependend
     if ($mode==DIRECTIVE_START)
       {
        # flag that we are within embedded HTML
        $flags{html}=1;

        # reset text start flag (otherwise, the inlined HTML would be prefixed
        # by a backslash if placed at the beginning of a paragraph)
        $flags{textstart}=0;

doc/doc-functions.pp  view on Meta::CPAN


// process a directory, insert all files found
\EMBED{lang=perl}

use strict;

sub includeDirectoryFiles
 {
  # get and check parameters
  my ($dir)=@_;
  die qq([Error] Missing directory option.\n) unless $dir;
  die qq([Error] Directory "$dir" does not exist.\n) unless -d $dir;

doc/doc-functions.pp  view on Meta::CPAN

       {
        # pass the file(s) to PerlPoint
        $perlPoint.=qq(\n\n\\INCLUDE{file="$dir/$_" type=pp headlinebase=CURRENT_LEVEL}\n\n) foreach @{$headlines{$headline}};
       }
    }

  # supply generated PerlPoint
  $perlPoint;
 }

\END_EMBED

doc/parser-active-contents.pp  view on Meta::CPAN

=Active Contents

Document parts can be generated \I<dynamically>. This is done by evaluating a \I<condition>,
\I<embedded> or \I<included> \B<Perl> code \I<at translation time>. Paragraph and input filters
are more types of Active Content.

@|
active part       | description | example
condition         | A paragraph type to control inclusion of all subsequent source parts before the next condition. | \C<\B<?> \$PerlPoint-\>{targetLanguage} eq "HTML">
\I<tag> condition | A special tag option available for all tags which accept options which flags whether the tag should take effect or not.  If Active Contents is \REF{name=Security type=linked}<disabled>, the condition defaults to "false". | \C<\\IM...
embedded Perl     | Perl code embedded into \C<\\EMBED> and \C<\\END_EMBED> tags, marked as Perl by tag option \C<lang> set to \C<"perl">. The code is expected to return a string which will be interpreted as \B<PerlPoint>. | \C<This document was gene...
included Perl     | Perl code read from a file via an \C<\\INCLUDE> tag, marked as Perl by tag option \C<type> set to \C<"perl">. File contents is evaluated like embedded Perl. | \C<\B<\\INCLUDE{type=perl file="included.pl"}>>
input filters     | A special option to \C<\\EMBED> and \C<\\INCLUDE> tags which allows to preprocess embedded code or included files before they are furtherly processed. The filter code may be passed directly or refer to functions defined in \I<embe...
paragraph filters | Calls to functions declared in \I<embedded Perl> (see above) used to modify a complete paragraph and return it for reparsing. Filters are applied by preceeding the target paragraph with the filter call enclosed in \C<\|\|> pairs. ...

  As an introduction example of the active contents feature,
  here is a report about this document: it was generated
  at \EMBED{lang=perl}my @t=(localtime)[3, 4, 5]; sprintf("%d.%d.%d", $t[0], $t[1]+1, $t[2]+1900); \END_EMBED.


==What it is for

Well, honestly spoken, I'm looking forward to the usage people will make of this feature.
But I can already imagine things like

* document parts included depending on the target language (an article could
  possibly provide more informations than presentation sheets), the time of
  presentation generation (informations may be confidental until a certain

doc/parser-active-contents.pp  view on Meta::CPAN

* and more ...

As for conditions, they can be used to generate various different documents from
one and the same source, depending on decisions based on evaluated Perl code.


==An example

The following files were found in the source directory of this documentation part when this presentation was built:

\EMBED{lang=perl}

# read /tmp
opendir(D, '.');
my @snapshot=map {my $size=(stat($_))[7]; [$_, defined $size ? $size : 0]} sort readdir(D);
closedir(D);

# supply the listing as a table
join(
     # row separator
     "\n",

doc/parser-active-contents.pp  view on Meta::CPAN

     # headline
     "filename | file size",

     # data, sorted
     map {join(' | ', @$_)} @snapshot,

     # closing empty line
     '',
    );

\END_EMBED


==Security

Security is kept by running active contents in a safe environment via a \B<Safe>
object if requested. This way every translator can implement its own grade of security,
allowing only such operations which seem to be uncritical to the author.

Nevertheless, the necessary security grade may vary. Imagine a downloaded presentation source
and a self written document. But even with own presentations it seems to be good

doc/parser-active-contents.pp  view on Meta::CPAN


All active contents shares the same \B<Safe> object which means that it is executed \I<in
the same Perl namespace> (which usually happens to appear as \C<main::>, please see the
translators documentation for details). As a consequece, several parts can interact with
each other by variables and functions.

Note that the active parts are evaluated in the order they appear in the PerlPoint source.

<<EOE

   \EMBED{lang=perl}

   sub fileCount
     {
      # get number of files
      opendir(D, '.');
      my @fileNr=readdir(D);
      my $fileNr=@fileNr;
      closedir(D);

      # supply result
      $fileNr;
     }

   # scan directory
   $filesFound=fileCount;

   '';

   \END_EMBED

EOE

The following condition evaluates the number of files found by the previously
executed code, using a variable set there:

  // conditional hints
  ? \B<$filesFound>>10000000000

... and includes more informations if appropriate:

doc/parser-active-contents.pp  view on Meta::CPAN


  The number of files in your directory let us add additional suggestions:

  ...

  // back to main document
  ? 1

Now we can use the previously declared function again:

  There are \\EMBED{lang=perl}\B<fileCount>\\END_EMBED files
  in the current directory.


==Using document variables

PerlPoint variables are \I<no> active contents. Even when active contents is
disabled completely, variables will still work. Nevertheless, their \I<values>
are \I<copied> into the namespace of active contents.

That means you can read every PerlPoint variable in active parts.

<<EOE

  $var=10

  The variables value on PerlPoint side is $var. On Perl side,
  it is \EMBED{lang=perl}$main::var\END_EMBED as well.

EOE

Note that the variables are only \I<copied>. They may be modified on Perl side
but without effect to PerlPoint.

<<EOE

  $var=10

  The variables value on PerlPoint side is $var. On Perl side,
  it is \EMBED{lang=perl}$main::var*=100\END_EMBED now. But this does not
  affect PerlPoint which still sees a value of $var.

EOE

Further more, whenever a variable is set on PerlPoint side, the Perl side
value is updated which overwrites all modifications eventually made.

You may have noticed that the variables were accessed by their fully qualified names
in the examples above. This was done because PerlPoint variables are evaluated \I<first>
- before the code is passed to perl. By using the fully qualified name which is unknown

doc/parser-active-contents.pp  view on Meta::CPAN


  // include the following depending on command
  ? flagSet('special')

Active contents can modify the provided data but changes will \I<expire> when a code
snippet is executed completely.

<<EOE

  // active contents modifying base data
  \EMBED{lang=perl}
     $PerlPoint->{targetLanguage}='modified';
  \END_EMBED

  // base data is automatically restored now,
  // so the condition checks the original value
  ? $PerlPoint->{targetLanguage} eq 'HTML'

EOE


==Known problems

doc/parser-faq.pp  view on Meta::CPAN


// declare helpful macros
+BU:\B<\U<__body__>>

// general headline
=FAQ

// process all articles dynamically
\EMBED{lang=perl}

{
 # declare variables
 my $perlPoint='';

 # get all subdirectories
 opendir(D, 'faq') or die qq([Fatal] Cannot open directory "faq"\n);
 my @categories=grep((-d "faq/$_" and !/^\./), readdir(D));
 closedir(D);

doc/parser-faq.pp  view on Meta::CPAN

          # pass the file(s) to PerlPoint
          $perlPoint.=qq(\n\n\\INCLUDE{file="faq/$category/$_" type=pp headlinebase=CURRENT_LEVEL}\n\n) foreach @{$questions{$question}};
         }
      }
   }

 # supply generated PerlPoint
 $perlPoint;
}

\END_EMBED

doc/parser-paragraphs.pp  view on Meta::CPAN

  $var=var

  This variable is set to $var.

All variables are made available to \I<embedded> and \I<included> Perl code as well as to
\I<conditions> and can be accessed there as package variables of "main::". Because a
variable is already replaced by the parser if possible, you have to use the fully
qualified name or to guard the variables "$" prefix character to do so:

<<EOE
  \EMBED{lang=perl}join(' ', $main::var, \$var)\END_EMBED
EOE

Variable modifications by embedded or included Perl \I<do not> affect the variables
visible to the parser. (This includes condition paragraphs.) This means that

<<EOE
  $var=10
  \EMBED{lang=perl}$main::var*=2;\END_EMBED
EOE

causes \C<\$var> to be different on parser and code side - the parser will still use a
value of 10, while embedded code works on with a value of 20.

Translator software \I<can> make additional use of variables, especially predeclare
certain settings (such variables are usually capitalized). Please see your converters
documentation for details.


doc/parser-paragraphs.pp  view on Meta::CPAN

  +F:\FONT{color=__c__}<__body__>

  +IB:\B<\I<__body__>>

  This \IB<text> is \RED<colored>.

  +TEXT:Macros can be used to abbreviate longer
  texts as well as other tags
  or tag combinations.

  +HTML:\EMBED{lang=html}

  Tags can be \RED<\I<nested>> into macros. And \I<\F{c=blue}<vice versa>>.
  \IB<\RED<This>> is formatted by nested macros.
  \HTML This is <i>embedded HTML</i>\END_EMBED.

  Please note: \TEXT

EOE


===Option defaults

If an option is declared but unused, it defaults to an empty string unless
the definition declared a default value itself by using an assignment list

doc/parser-tags.pp  view on Meta::CPAN

=Special purpose tags

* provide additional source control and

* allow target format specific source parts and

* implement structured formatting;

* can be used whereever tags in general are valid;

* currently are \C<\\INCLUDE>, \C<\\EMBED> and \C<\\END_EMBED>, \C<\\TABLE> and \C<\\END_TABLE>;

==File inclusion

It is possible to include another file by \B<\\INCLUDE{file=\<filename\> type=\<type\>}>.

The mandatory base options are

@|
option | description
file   | names the source to be included (should exist)

doc/parser-tags.pp  view on Meta::CPAN

the special option \C<\X<ifilter>>.

  Let's say you want to process a POD source.
  This is simple:

  \\INCLUDE{file="perlpod.pod" \B<ifilter="pod2pp"> type=pp}

Oh, well, we need a \C<pod2pp()> function to make this work. It could be defined
in embedded or included Perl code above the example snippet, like this:

  \\EMBED{lang=perl}

  # load lib
  use Pod::PerlPoint;

  # process what we got and supply the result
  sub pod2pp
   {
    my ($pod2pp, $perlpoint)=(new Pod::PerlPoint());
    $pod2pp->output_string(\$perlpoint);
    $pod2pp->parse_string_document(\I<@main::_ifilterText>);
    $perlpoint;
   }

  \\END_EMBED

As you can see, the source to be translated is provided in an array \C<\X<@main::_ifilterText>>.
(A second variable \C<\X<$main::_ifilterType>> provides the target language, if required.) The
result should be supplied as a list.

Filters can be used for any file type, not only \C<pp>. Just make sure that your code supplies
whatever is appropriate for your \C<type> option.


==Embedded code

Target format code does not necessarily need to be imported by file - it can be
directly \I<embedded> as well. This means that one can write target language
code within the input stream using \C<\\EMBED>, maybe because you miss a certain
feature in the current translator version:

<<EOE

  \EMBED{lang=HTML}
  This is <i><b>embedded</b> HTML</i>. The parser detects <i>no</i>
  Perl Point tag here, except of <b>END_EMBED</b>.
  \END_EMBED

EOE

The mandatory \I<lang> option specifies which language the embedded code is of.
Usually a translator only supports its own target format to be embedded.
(You will not be surprised that language values of \C<"perl"> and \C<"pp"> are special
cases - see the related subsections.)

Please note that the \C<\\EMBED> tag does not accept a tag body to avoid
ambiguities. Use \C<\\END_EMBED> to flag where the embedded code is completed.
\I<It is the only recognized tag therein.>

Because embedding is not implemented by a paragraph but by a \I<tag>, \\EMBED
can be placed \I<directly> in a text like this:

<<EOE
  These \EMBED{lang=HTML}<i>italics</i>\END_EMBED are formatted
  by HTML code.
EOE

===Embedding PerlPoint into PerlPoint

This is just for fun. Set the \C<"lang"> option to \C<"pp"> to try it:

<<EOE
  Perl Point \EMBED{lang=pp}can \EMBED{lang=pp}be
  \EMBED{lang=pp}nested\END_EMBED\END_EMBED\END_EMBED.
EOE

===Embedding Perl

This feature offers dynamic PerlPoint generation at \I<translation time>.

  \\EMBED{lang=perl}hello\\END_EMBED

\B<Embedded Perl is \I<active contents> - see the special chapter about it.>

\I<If> active contents is enabled, embedded Perl code is evaluated. The code is
expected to produce a PerlPoint string which then replaces the inclusion tag and
is read like static PerlPoint.

If the included code fails, an error message is displayed and the result is
ignored.

Here's another example:

<<EOE

  \EMBED{lang=PERL}

  # build a message
  my $msg="Perl may be embedded as well.";

  # and supply it
  $msg;

  \END_EMBED

EOE

The feature is of course more powerful. You may generate images at translation
time and include them, scan the disk and include a formatted listing, download
data from a webserver and make it part of your presentation, autoformat complex
data, include formatted source code, keep your presentation up to date in any
way and so on.


===Using input filters

Embedded code can be preprocessed by a user defined \I<input filter>.  A filter
is set up by using the special option \C<\X<ifilter>>.

  Let's say you want to process a piece of POD.

  \\EMBED{\B<ifilter="pod2pp"> lang=pp}

Again, we need a \C<pod2pp()> function to make this work. Fortunately, as the function
interface is the same, we can use the same filter that we defined to translate POD \I<files>
\REF{name="Special purpose tags | File inclusion | Using input filters" type=linked}<above>.

Filters can be used for any target language, not only \C<pp>. Just make sure that your code
supplies whatever is appropriate for your \C<type> option.



doc/tagdoc-example.pp  view on Meta::CPAN

// load function definition
\INCLUDE{file="doc-functions.pp" type=pp}


// open tag doc chapter
=Supported tags

This chapter documents all tags supported by pp2xy.

// call the function to process the docs in chapter "tags".
\EMBED{lang=perl}includeDirectoryFiles('tags');\END_EMBED

doc/tutorial.pp  view on Meta::CPAN

+BLUE:\F{color=blue}<__body__>

+GREEN:\F{color=green}<__body__>

+ILLT:\LOCALTOC{type=linked depth=2}

+FNR:\SUP<\F{size="-2"}<\REF{type=linked name="__n__"}>>

+FN:\F{size="-2"}<\SEQ{type=footnotes name="__n__"}: __body__>

+HR:\EMBED{lang=html}<HR/>\END_EMBED


=Start

.\I<Note: this tutorial is still incomplete, so several sections might be empty. Nevertheless,
the basic parts are there and should allow you to start working with PerlPoint. Enjoy!>

// TOC
\ILLT

doc/tutorial.pp  view on Meta::CPAN


Condition paragraphs are only seen by PerlPoint itself. As they are just controlling translation,
they do not appear in the results (HTML, XML or whatever).

Conditions of course can be more complex. They can be anything that is valid Perl code, but to
get readable sources it is recommended to hide complexity in function calls, like here

   ? \RED<shouldWeIncludeTheFollowing()>

The function can be declared in any other Active Contents part read before. A well working
technique is to use \CX<\\EMBED{lang=perl}> for this. This tag starts a section of embedded
Perl code which is evaulated only if Active Contents is enabled, and with the same rules.
In our current context, one important rule is that \I<all> Active Contents code lives in the same
namespace (\CX<main::> from the codes point of view), so function definitions, package variables
etc. can be shared.

Here is a definition of our "should-we-include-this" function:

~hints

Note that in the embedded Perl area newlines are allowed.

~main

   \\EMBED{lang=perl}

   \GREEN<# declare a function for conditions>
   sub shouldWeIncludeTheFollowing
    {
     1;
    }

   \GREEN<# supply an empty string as PerlPoint
   code to be processed>
   '';

   \\END_EMBED

I confess this is a rather simple function, but I think you get the point. Define whatever
function you need, of your prefered complexity. An effective way to do this is to have a
special \I<file> with \I<all> definitions etc. that should be used later on in conditions, and
to include this file in all the documents that make use of it.

   \GREEN<// include code>
   \\INCLUDE{type=perl file="code.pp" smart=1}

Some functions of general use are provided without any definition. These are ...

doc/writing-converters-traditional.pp  view on Meta::CPAN



==Finding tag names

New tag names can be freely chosen, with two exceptions: first, certain tag names are already used (and therefore reserved) by the base system:

@|
tag                                                      | description
\BC<\\B>, \BC<\\C>, \BC<\\HIDE>, \BC<\\I>, \BC<\\IMAGE>, \BC<\\READY>, \BC<\\REF>, \BC<\\SEQ> | Base tags defined by \BC<\PP::Tags::Basic>. By convention, \I<all> converters support these tags. (The list might be incomplete, please look at the latest...
\BC<\\TABLE>, \BC<\\END_TABLE>                           | construct tables
\BC<\\EMBED>, \BC<\\END_EMBED>                           | embed other languages into a \PP source, e.g. to directly include parts in the target format, or to call Perl code which produces \PP on the fly
\BC<\\INCLUDE>                                           | loads additional files which are made part of the source (in various ways)

Second, please have a look at existing converters and \I<their> tags. It might confuse users if one and the same tag name has completely different meanings in different converters. So if your prefered name is already used, please invent another one. ...

All tag names are made of uppercased letters. Underscores and digits are allowed as well. The parser does not recognize a tag if its name does not match these rules.


==Tag option conventions

You are free to invent whatever option names you prefer. Well, almost. There are a few

lib/PerlPoint/Generator/SDF.pm  view on Meta::CPAN

# formatters

sub preFormatter
 {
  # get and check parameters
  my ($me, $opcode, $mode, @more)=@_;
  confess "[BUG] Missing object parameter.\n" unless $me;
  confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);

  # embed tag?
  if ($opcode==DIRECTIVE_TAG and $more[0] eq 'EMBED')
    {
     # get more parameters
     my ($tag, $settings)=@more;

     # embedded SDF configuration
     $me->{flags}{sdf}=($mode==DIRECTIVE_START) ? 1 : 0 if $settings->{lang}=~/^sdf$/i;

     # embedded HTML configuration
     $me->{flags}{html}=($mode==DIRECTIVE_START) ? 1 : 0 if $settings->{lang}=~/^html$/i;
    }

lib/PerlPoint/Generator/SDF.pm  view on Meta::CPAN

  if (exists $simpleTags{$item->{cfg}{data}{name}})
    {
     $directive=$simpleTags{$item->{cfg}{data}{name}};
     $result=join('', "{{$directive:", @{$item->{parts}}, '}}');
    }
  elsif ($item->{cfg}{data}{name} eq 'A')
    {
     # anchor: build result string
     $result=join('', qq({{N[id=q($item->{cfg}{data}{options}{name})]), @{$item->{parts}}, '}}');
    }
  elsif ($item->{cfg}{data}{name} eq 'EMBED')
    {
     # embedded part: SDF is prepared for printing
     if ($item->{cfg}{data}{options}{lang}=~/^SDF$/i)
       {
        # just concatenate the parts
        $result=join('', @{$item->{parts}});
       }
     elsif ($item->{cfg}{data}{options}{lang}=~/^HTML$/i)
       {
        # concatenate first ...

lib/PerlPoint/Parser.pm  view on Meta::CPAN

#         |04.07.2002| JSTENZEL | simplified several array field access codes;
#         |          | JSTENZEL | bugfix: empty headlines caused an infinite loop
#         |          |          | when trailing whitespaces should be removed;
#         |          | JSTENZEL | bugfix: empty headlines caused a failure when headline
#         |          |          | anchors should be stored, skipping them now;
#         |20.08.2002| JSTENZEL | improved tag streaming: stream now contains a body hint;
#         |          | JSTENZEL | bugfix: paragraph filters restored tag bodies even if
#         |          |          | there was no body;
#         |          | JSTENZEL | old caches need to be updated - adapted compatibility hint;
#         |27.08.2002| JSTENZEL | started to use precompiled lexer patterns;
#         |31.08.2002| JSTENZEL | \INCLUDE, \EMBED and \TABLE now support the _cnd_ option,
#         |          |          | like tags defined externally;
#         |04.12.2002| JSTENZEL | bugfix in pfilter retranslation: backslash reinsertion was
#         |          |          | not performed multiply;
#         |          | JSTENZEL | pfilter retranslation: backslash reinsertion now suppressed
#         |          |          | in verbatim blocks;
#         |01.01.2003| JSTENZEL | added input filter support to \EMBED, via option "ifilter";
#         |02.01.2003| JSTENZEL | added input filter support to \INCLUDE, same interface;
# 0.37    |up to     | JSTENZEL | flagSet() now takes a list of flag names;
#         |14.04.2002| JSTENZEL | names of included files are resolved to avoid trouble
#         |          |          | with links (and to avoid error messages);
#         |          | JSTENZEL | \INCLUDE searches pathes specified in environment
#         |          |          | variable PERLPOINTLIB (like perl, shells, linkers etc.);
#         |          | JSTENZEL | if tags with finish hooks are used, a paragraph will
#         |          |          | not be cached because it becomes potentially dynamic;
#         |          | JSTENZEL | anchors defined by a cached paragraph are cached now
#         |          |          | as well - and restored after a cache hit (updated cache

lib/PerlPoint/Parser.pm  view on Meta::CPAN

  $var=var

  This variable is called $var.

All variables are made available to embedded and included Perl code as well as to
conditions and can be accessed there as package variables of "main::" (or whatever
package name the Safe object is set up to). Because a
variable is already replaced by the parser if possible, you have to use the fully
qualified name or to guard the variables "$" prefix character to do so:

  \EMBED{lang=perl}join(' ', $main::var, \$var)\END_EMBED

Variable modifications by embedded or included Perl I<do not> affect the variables
visible to the parser. (This is true for conditions as well.) This means that

  $var=10
  \EMBED{lang=perl}$main::var*=2;\END_EMBED

causes I<$var> to be different on parser and code side - the parser will still use a
value of 10, while embedded code works on with a value of 20.

=item Macro or alias definitions

Sometimes certain text parts are used more than once. It would be a relieve
to have a shortcut instead of having to insert them again and again. The same
is true for tag combinations a user may prefer to use. That's what I<aliases>
(or "macros") are designed for. They allow a presentation author to declare

lib/PerlPoint/Parser.pm  view on Meta::CPAN


  This \IB<text> is \RED<colored>.

  Defaults: first, text in \COLORED{c=red}<Red>,
  now text in \COLORED<Blue>.

  +TEXT:Macros can be used to abbreviate longer
     texts as well as other tags
  or tag combinations.

  +HTML:\EMBED{lang=html}

  Tags can be \RED<\I<nested>> into macros.
  And \I<\F{c=blue}<vice versa>>.
  \IB<\RED<This>> is formatted by nested macros.
  \HTML This is <i>embedded HTML</i>\END_EMBED.

  Please note: \TEXT

I<If no parameter is defined in the macro definition, options will not be recognized.>
The same is true for the body part.
I<Unless C<__body__> is used in the macro definition, macro bodies will not be recognized.>
This means that with the definition

  +OPTIONLESS:\B<__body__>

lib/PerlPoint/Parser.pm  view on Meta::CPAN


Including external scripts this way can accelerate PerlPoint authoring significantly,
especially if the included files are still subject to changes.

It is possible to filter the file types you wish to include (with exception
of "pp" and "example"), see below for details. I<In any case>, the mentioned file
has to exist.



=item \EMBED and \END_EMBED

Target format code does not necessarily need to be imported - it can be
directly I<embedded> as well. This means that one can write target language
code within the input stream using I<\EMBED>:

  \EMBED{lang=HTML}
  This is <i><b>embedded</b> HTML</i>.
  The parser detects <i>no</i> PerlPoint
  tag here, except of <b>END_EMBED</b>.
  \END_EMBED

Because this is handled by I<tags>, not by paragraphs, it can be placed
directly in a text like this:

  These \EMBED{lang=HTML}<i>italics</i>\END_EMBED
  are formatted by HTML code.

Please note that the EMBED tag does not accept a tag body (to avoid
ambiguities).

Both tag and embedded text are made part of the intermediate stream.
It is the backends task to deal with it. The only exception of this rule
is the embedding of I<Perl> code, which is evaluated by the parser.
The reply of this code is made part of the input stream and parsed as
usual.

PerlPoint authors can declare an I<input filter> to preprocess the
embedded text. This is done via option I<ifilter>:

  \EMBED{lang=pp ifilter="pod2pp()"}

  =head1 POD formatted part

  This part was written in POD.

  \END_EMBED

An input filter is a snippet of user defined Perl code, taking the
embedded text via C<@main::_ifilterText> and the target language via
C<$main::_ifilterType>. The original filename can be accessed via
C<$main::_ifilterType> (but please note that this is the source with
the \EMBED tag). It should supply its result as an array of
strings which will then be processed as usual.

Input filters are Active Contents. If Active Contents is disabled,
embedded parts using input filters will be ignored I<completely>.

It is possible to filter the languages you wish to embed (with exception
of "PP"), see below for details.


=item \TABLE and \END_TABLE

lib/PerlPoint/Parser.pm  view on Meta::CPAN

   # state constants
   _startupGenerateConstants(
                            'STATE_DEFAULT',         # default;
                            'STATE_DEFAULT_TAGMODE', # default in tag mode;

                            'STATE_BLOCK',           # block;
                            'STATE_COMMENT',         # comment;
                            'STATE_CONTROL',         # control paragraph (of a single character);
                            'STATE_DPOINT',          # definition list point;
                            'STATE_DPOINT_ITEM',     # definition list point item (defined stuff);
                            'STATE_EMBEDDING',       # embedded things (HTML, Perl, ...);
                            'STATE_PFILTER',         # paragraph filter installation;
                            'STATE_PFILTERED',       # "default" state after a pfilter installation;
                            'STATE_CONDITION',       # condition;
                            'STATE_HEADLINE_LEVEL',  # headline level setting;
                            'STATE_HEADLINE',        # headline;
                            'STATE_OPOINT',          # ordered list point;
                            'STATE_TEXT',            # text;
                            'STATE_UPOINT',          # unordered list point;
                            'STATE_VERBATIM',        # verbatim block;
                            'STATE_TABLE',           # table *paragraph*;

lib/PerlPoint/Parser.pm  view on Meta::CPAN

     %lexerFlagsOfPreviousState,   # buffered lexer state flags of previous state;
     %statistics,                  # statistics data;
     %variables,                   # user managed variables;
     %flags,                       # various flags;
     %macros,                      # macros / aliases;
     %openedSourcefiles,           # a hash of all source files already opened (to enable smart inclusion);
     %paragraphTypeStrings,        # paragraph type to string translation table;

     @nestedSourcefiles,           # a list of current source file nesting (to avoid circular inclusions);
     @specialStack,                # special state stack for temporary activations (to restore original states);
     @stateStack,                  # state stack (mostly intended for non paragraph states like STATE_EMBEDDED);
     @tableSeparatorStack,         # the first element is the column separator string within a table, empty otherwise;
     @inputStack,                  # a stack of additional input lines and dynamically inserted parts;
     @inHandles,                   # a stack of input handles (to manage nested sources);
     @olistLevels,                 # a hint storing the last recent ordered list level number of a paragraph (hyrarchically);
     @inLine,                      # current *real* input line (the unexpanded line read from a source file);
     @previousStackLines,          # buffer of the last lines gotten from input stack;
     @libraryPath,                 # a collection of pathes to find files for \INCLUDE in;
     @headlineIds,                 # the hierarchical values of $directiveCounter pointing to the current chapter headline;

     $anchors,                     # anchor collector object;

lib/PerlPoint/Parser.pm  view on Meta::CPAN

 my $patternWUmlauts=qr/[\wäöüÄÖÜß]+/;

 # prepare lexer patterns
 my $patternNlbBackslash=qr/(?<!\\)/;
 my %lexerPatterns=(
                    tag              => qr/$patternNlbBackslash\\([A-Z_0-9]+)/,
                    space            => qr/(\s+)/,
                    pfilterDelimiter => qr/$patternNlbBackslash((\|){1,2})/,
                    table            => qr/$patternNlbBackslash\\(TABLE)/,
                    endTable         => qr/$patternNlbBackslash\\(END_TABLE)/,
                    embed            => qr/$patternNlbBackslash\\(EMBED)/,
                    endEmbed         => qr/$patternNlbBackslash\\(END_EMBED)/,
                    include          => qr/$patternNlbBackslash\\(INCLUDE)/,
                    nonWhitespace    => qr/$patternNlbBackslash(\S)/,
                    colon            => qr/$patternNlbBackslash(:)/,
                    namedVarKernel   => qr/\$($patternWUmlauts)/,
                    symVarKernel     => qr/\$({($patternWUmlauts)})/,
                   );
  @lexerPatterns{qw(
                    namedVar
                    symVar
                   )

lib/PerlPoint/Parser.pm  view on Meta::CPAN

 my %embeddedParagraphs;
 @embeddedParagraphs{
                     DIRECTIVE_UPOINT,
                     DIRECTIVE_OPOINT,
                    }=();

 # declare token descriptions (to be used in error messages)
 my %tokenDescriptions=(
                        EOL                      => 'a carriage return',
                        Embed                    => 'embedded code',
                        Embedded                 => 'an \END_EMBED tag',
                        Empty_line               => 'an empty line',
                        Heredoc_close            => 'a string closing the "here document"',
                        Heredoc_open             => 'a "here document" opener',
                        Ils                      => 'a indentation',
                        Include                  => 'an included part',
                        Named_variable           => 'a named variable',
                        Space                    => 'a whitespace',
                        StreamedPart             => undef,
                        Symbolic_variable        => 'a symbolic variable',
                        Table                    => 'a table',

lib/PerlPoint/Parser.pm  view on Meta::CPAN

                              and (
                                      $_[1][0][1][STREAM_DIR_DATA]=~/^(TABLE)$/
                                   or (
                                           $_[1][0][1][STREAM_DIR_DATA]=~/^(\w+)$/
                                       and (
                                               (
                                                    exists $tagsRef->{$1}
                                                and exists $tagsRef->{$1}{standalone}
                                                and $tagsRef->{$1}{standalone}
                                               )
                                            or $1 eq 'EMBED'
                                           )
                                      )
                                  )

                              # ending with the same tag?
                              and ref($_[1][0][-2]) eq 'ARRAY'
                              and $_[1][0][-2][STREAM_DIR_TYPE]==DIRECTIVE_TAG
                              and $_[1][0][-2][STREAM_DIR_DATA] eq $1

                              # both building the same tag?

lib/PerlPoint/Parser.pm  view on Meta::CPAN

                   }
	],
	[#Rule 147
		 '@28-1', 0,
sub
#line 3626 "ppParser.yp"
{
             # switch to embedding mode saving the former state (including *all* special settings)
             push(@stateStack, $parserState);
             push(@specialStack, [%specials]);
             _stateManager(STATE_EMBEDDING);

             # trace, if necessary
             warn "[Trace] $sourceFile, line $_[1][1]: Embedding starts.\n" if $flags{trace} & TRACE_PARAGRAPHS;

             # Disable storage of a checksum. (Dynamic parts may change or have changed.
             # Static parts are static of course, but the filter settings may vary.)
             $flags{checksummed}=0;

             # temporarily activate specials "{" and "}"
             push(@specialStack, @specials{('{', '}')});

lib/PerlPoint/Parser.pm  view on Meta::CPAN

                # we have to supply something, but it should be nothing
                [[()], $_[6][1]];
               }
             else
               {
                # reply data in a "tag envelope" (for backends)
                my %hints=(nr=>++$directiveCounter);
                [
                 [
                  # opener directive
                  [\%hints, DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED', \%pars],
                  # the list of enclosed literals, if any
                  @{$_[5][0]} ? @{$_[5][0]} : (),
                  # final directive
                  [\%hints, DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED', \%pars]
                 ],
                 $_[6][1]
                ];
               }
            }
	],
	[#Rule 150
		 '@30-1', 0,
sub
#line 3830 "ppParser.yp"

lib/PerlPoint/Parser.pm  view on Meta::CPAN

                          ],
                          $_[3][1]
                         ];
                        }
                      else
                        {
                         my %hints=(nr=>++$directiveCounter);
                         [
                          [
                           # opener directive
                           [\%hints, DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED', {lang=>$tagpars{type}}],
                           # the list of enclosed "literals", if any
                           @included,
                           # final directive
                           [\%hints, DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED', {lang=>$tagpars{type}}]
                          ],
                          $_[3][1]
                         ];
                        }
                     }
                  }
                else
                  {
                   # file missing, simply inform user
                   $errors++, _semerr($_[0], "$sourceFile, line $_[3][1]: File $tagpars{file} does not exist or cannot be read (current directory: ", cwd(), ").");

lib/PerlPoint/Parser.pm  view on Meta::CPAN

     # reply next token: scan for SPECIAL tagnames: \TABLE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Table starts in line $lineNrs{$inHandle}.\n")),
     return('Table', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{table}/;

     # reply next token: scan for SPECIAL tagnames: \END_TABLE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Table completed in line $lineNrs{$inHandle}.\n")),
     return('Tabled', [$found, $lineNrs{$inHandle}])  if $specials{tag} and /^$lexerPatterns{endTable}/;

     # reply next token: scan for SPECIAL tagnames: \EMBED
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Embedding starts in line $lineNrs{$inHandle}.\n")),
     return('Embed', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{embed}/;

     # reply next token: scan for SPECIAL tagnames: \END_EMBED
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Embedding completed in line $lineNrs{$inHandle}.\n")),
     return('Embedded', [$found, $lineNrs{$inHandle}]) if $specials{embedded} and /^$lexerPatterns{endEmbed}/;

     # reply next token: scan for SPECIAL tagnames: \INCLUDE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Including starts in line $lineNrs{$inHandle}.\n")),
     return('Include', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{include}/;

     # reply next token: scan for tagnames

lib/PerlPoint/Parser.pm  view on Meta::CPAN

     # likewise, flag that this paragraph *might* use variables someday, if there is still something being no variable,
     # but looking like a variable (somebody could *later* declare it a real var, so the cache
     # needs to check variable definitions)
     $flags{checksummed}[4]=1
       if     /($lexerPatterns{namedVarKernel})|($lexerPatterns{symVarKernel})/
          and not (exists $flags{checksummed} and not $flags{checksummed});

     # remove guarding \\, if necessary
     s/^\\// unless    $specials{heredoc}
                    or (defined $lexerFlags{backsl} and $lexerFlags{backsl}==LEXER_TOKEN)
                    or $parserState==STATE_EMBEDDING
                    or $parserState==STATE_PFILTER
                    or $parserState==STATE_CONDITION
                    or $parserState==STATE_DEFINITION;

     # reply next token: scan for numbers, if necessary
     $found=$1, s/^$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Number $found in line $lineNrs{$inHandle}.\n")),
     return('Number', [$found, $lineNrs{$inHandle}]) if $specials{number} and /^(\d+)/;

     unless ($flags{noboost})

lib/PerlPoint/Parser.pm  view on Meta::CPAN

  # check parameter
  confess "[BUG] Invalid new state $newState passed.\n" unless    $newState==STATE_DEFAULT
                                                               or $newState==STATE_DEFAULT_TAGMODE
                                                               or $newState==STATE_TEXT
                                                               or $newState==STATE_UPOINT
                                                               or $newState==STATE_OPOINT
                                                               or $newState==STATE_DPOINT
                                                               or $newState==STATE_DPOINT_ITEM
                                                               or $newState==STATE_BLOCK
                                                               or $newState==STATE_VERBATIM
                                                               or $newState==STATE_EMBEDDING
                                                               or $newState==STATE_PFILTER
                                                               or $newState==STATE_PFILTERED
                                                               or $newState==STATE_CONDITION
                                                               or $newState==STATE_HEADLINE_LEVEL
                                                               or $newState==STATE_HEADLINE
                                                               or $newState==STATE_TABLE
                                                               or $newState==STATE_DEFINITION
                                                               or $newState==STATE_CONTROL
                                                               or $newState==STATE_COMMENT;

lib/PerlPoint/Parser.pm  view on Meta::CPAN

     @specials{('.', '/', '*', '#', '=', '<', '>', '{', '}' , '-', '?', '@', '+', '~', 'heredoc', 'colon', 'tag', 'embedded', 'number', 'pfilter')}=(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0);

     # trace, if necessary
     warn "[Trace] Entered verbatim state.\n" if $flags{trace} & TRACE_SEMANTIC;

     # well done
     return;
    };

  # enter new state: embedding
  $newState==STATE_EMBEDDING and do
    {
     # prepare lexer
     @lexerFlags{qw(ils eol el cbell)}=(LEXER_SPACE, LEXER_TOKEN, LEXER_TOKEN, LEXER_IGNORE);

     # activate special characters as necessary
     @specials{('.', '/', '*', '#', '=', '<', '>', '{', '}' , '-', '?', '@', '+', '~', 'heredoc', 'colon', 'tag', 'embedded', 'number', 'pfilter')}=(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);

     # trace, if necessary
     warn "[Trace] Entered embedding state.\n" if $flags{trace} & TRACE_SEMANTIC;

ppParser.yp  view on Meta::CPAN

#         |04.07.2002| JSTENZEL | simplified several array field access codes;
#         |          | JSTENZEL | bugfix: empty headlines caused an infinite loop
#         |          |          | when trailing whitespaces should be removed;
#         |          | JSTENZEL | bugfix: empty headlines caused a failure when headline
#         |          |          | anchors should be stored, skipping them now;
#         |20.08.2002| JSTENZEL | improved tag streaming: stream now contains a body hint;
#         |          | JSTENZEL | bugfix: paragraph filters restored tag bodies even if
#         |          |          | there was no body;
#         |          | JSTENZEL | old caches need to be updated - adapted compatibility hint;
#         |27.08.2002| JSTENZEL | started to use precompiled lexer patterns;
#         |31.08.2002| JSTENZEL | \INCLUDE, \EMBED and \TABLE now support the _cnd_ option,
#         |          |          | like tags defined externally;
#         |04.12.2002| JSTENZEL | bugfix in pfilter retranslation: backslash reinsertion was
#         |          |          | not performed multiply;
#         |          | JSTENZEL | pfilter retranslation: backslash reinsertion now suppressed
#         |          |          | in verbatim blocks;
#         |01.01.2003| JSTENZEL | added input filter support to \EMBED, via option "ifilter";
#         |02.01.2003| JSTENZEL | added input filter support to \INCLUDE, same interface;
# 0.37    |up to     | JSTENZEL | flagSet() now takes a list of flag names;
#         |14.04.2002| JSTENZEL | names of included files are resolved to avoid trouble
#         |          |          | with links (and to avoid error messages);
#         |          | JSTENZEL | \INCLUDE searches pathes specified in environment
#         |          |          | variable PERLPOINTLIB (like perl, shells, linkers etc.);
#         |          | JSTENZEL | if tags with finish hooks are used, a paragraph will
#         |          |          | not be cached because it becomes potentially dynamic;
#         |          | JSTENZEL | anchors defined by a cached paragraph are cached now
#         |          |          | as well - and restored after a cache hit (updated cache

ppParser.yp  view on Meta::CPAN

  $var=var

  This variable is called $var.

All variables are made available to embedded and included Perl code as well as to
conditions and can be accessed there as package variables of "main::" (or whatever
package name the Safe object is set up to). Because a
variable is already replaced by the parser if possible, you have to use the fully
qualified name or to guard the variables "$" prefix character to do so:

  \EMBED{lang=perl}join(' ', $main::var, \$var)\END_EMBED

Variable modifications by embedded or included Perl I<do not> affect the variables
visible to the parser. (This is true for conditions as well.) This means that

  $var=10
  \EMBED{lang=perl}$main::var*=2;\END_EMBED

causes I<$var> to be different on parser and code side - the parser will still use a
value of 10, while embedded code works on with a value of 20.

=item Macro or alias definitions

Sometimes certain text parts are used more than once. It would be a relieve
to have a shortcut instead of having to insert them again and again. The same
is true for tag combinations a user may prefer to use. That's what I<aliases>
(or "macros") are designed for. They allow a presentation author to declare

ppParser.yp  view on Meta::CPAN


  This \IB<text> is \RED<colored>.

  Defaults: first, text in \COLORED{c=red}<Red>,
  now text in \COLORED<Blue>.

  +TEXT:Macros can be used to abbreviate longer
     texts as well as other tags
  or tag combinations.

  +HTML:\EMBED{lang=html}

  Tags can be \RED<\I<nested>> into macros.
  And \I<\F{c=blue}<vice versa>>.
  \IB<\RED<This>> is formatted by nested macros.
  \HTML This is <i>embedded HTML</i>\END_EMBED.

  Please note: \TEXT

I<If no parameter is defined in the macro definition, options will not be recognized.>
The same is true for the body part.
I<Unless C<__body__> is used in the macro definition, macro bodies will not be recognized.>
This means that with the definition

  +OPTIONLESS:\B<__body__>

ppParser.yp  view on Meta::CPAN


Including external scripts this way can accelerate PerlPoint authoring significantly,
especially if the included files are still subject to changes.

It is possible to filter the file types you wish to include (with exception
of "pp" and "example"), see below for details. I<In any case>, the mentioned file
has to exist.



=item \EMBED and \END_EMBED

Target format code does not necessarily need to be imported - it can be
directly I<embedded> as well. This means that one can write target language
code within the input stream using I<\EMBED>:

  \EMBED{lang=HTML}
  This is <i><b>embedded</b> HTML</i>.
  The parser detects <i>no</i> PerlPoint
  tag here, except of <b>END_EMBED</b>.
  \END_EMBED

Because this is handled by I<tags>, not by paragraphs, it can be placed
directly in a text like this:

  These \EMBED{lang=HTML}<i>italics</i>\END_EMBED
  are formatted by HTML code.

Please note that the EMBED tag does not accept a tag body (to avoid
ambiguities).

Both tag and embedded text are made part of the intermediate stream.
It is the backends task to deal with it. The only exception of this rule
is the embedding of I<Perl> code, which is evaluated by the parser.
The reply of this code is made part of the input stream and parsed as
usual.

PerlPoint authors can declare an I<input filter> to preprocess the
embedded text. This is done via option I<ifilter>:

  \EMBED{lang=pp ifilter="pod2pp()"}

  =head1 POD formatted part

  This part was written in POD.

  \END_EMBED

An input filter is a snippet of user defined Perl code, taking the
embedded text via C<@main::_ifilterText> and the target language via
C<$main::_ifilterType>. The original filename can be accessed via
C<$main::_ifilterType> (but please note that this is the source with
the \EMBED tag). It should supply its result as an array of
strings which will then be processed as usual.

Input filters are Active Contents. If Active Contents is disabled,
embedded parts using input filters will be ignored I<completely>.

It is possible to filter the languages you wish to embed (with exception
of "PP"), see below for details.


=item \TABLE and \END_TABLE

ppParser.yp  view on Meta::CPAN

   # state constants
   _startupGenerateConstants(
                            'STATE_DEFAULT',         # default;
                            'STATE_DEFAULT_TAGMODE', # default in tag mode;

                            'STATE_BLOCK',           # block;
                            'STATE_COMMENT',         # comment;
                            'STATE_CONTROL',         # control paragraph (of a single character);
                            'STATE_DPOINT',          # definition list point;
                            'STATE_DPOINT_ITEM',     # definition list point item (defined stuff);
                            'STATE_EMBEDDING',       # embedded things (HTML, Perl, ...);
                            'STATE_PFILTER',         # paragraph filter installation;
                            'STATE_PFILTERED',       # "default" state after a pfilter installation;
                            'STATE_CONDITION',       # condition;
                            'STATE_HEADLINE_LEVEL',  # headline level setting;
                            'STATE_HEADLINE',        # headline;
                            'STATE_OPOINT',          # ordered list point;
                            'STATE_TEXT',            # text;
                            'STATE_UPOINT',          # unordered list point;
                            'STATE_VERBATIM',        # verbatim block;
                            'STATE_TABLE',           # table *paragraph*;

ppParser.yp  view on Meta::CPAN

     %lexerFlagsOfPreviousState,   # buffered lexer state flags of previous state;
     %statistics,                  # statistics data;
     %variables,                   # user managed variables;
     %flags,                       # various flags;
     %macros,                      # macros / aliases;
     %openedSourcefiles,           # a hash of all source files already opened (to enable smart inclusion);
     %paragraphTypeStrings,        # paragraph type to string translation table;

     @nestedSourcefiles,           # a list of current source file nesting (to avoid circular inclusions);
     @specialStack,                # special state stack for temporary activations (to restore original states);
     @stateStack,                  # state stack (mostly intended for non paragraph states like STATE_EMBEDDED);
     @tableSeparatorStack,         # the first element is the column separator string within a table, empty otherwise;
     @inputStack,                  # a stack of additional input lines and dynamically inserted parts;
     @inHandles,                   # a stack of input handles (to manage nested sources);
     @olistLevels,                 # a hint storing the last recent ordered list level number of a paragraph (hyrarchically);
     @inLine,                      # current *real* input line (the unexpanded line read from a source file);
     @previousStackLines,          # buffer of the last lines gotten from input stack;
     @libraryPath,                 # a collection of pathes to find files for \INCLUDE in;
     @headlineIds,                 # the hierarchical values of $directiveCounter pointing to the current chapter headline;

     $anchors,                     # anchor collector object;

ppParser.yp  view on Meta::CPAN

 my $patternWUmlauts=qr/[\wäöüÄÖÜß]+/;

 # prepare lexer patterns
 my $patternNlbBackslash=qr/(?<!\\)/;
 my %lexerPatterns=(
                    tag              => qr/$patternNlbBackslash\\([A-Z_0-9]+)/,
                    space            => qr/(\s+)/,
                    pfilterDelimiter => qr/$patternNlbBackslash((\|){1,2})/,
                    table            => qr/$patternNlbBackslash\\(TABLE)/,
                    endTable         => qr/$patternNlbBackslash\\(END_TABLE)/,
                    embed            => qr/$patternNlbBackslash\\(EMBED)/,
                    endEmbed         => qr/$patternNlbBackslash\\(END_EMBED)/,
                    include          => qr/$patternNlbBackslash\\(INCLUDE)/,
                    nonWhitespace    => qr/$patternNlbBackslash(\S)/,
                    colon            => qr/$patternNlbBackslash(:)/,
                    namedVarKernel   => qr/\$($patternWUmlauts)/,
                    symVarKernel     => qr/\$({($patternWUmlauts)})/,
                   );
  @lexerPatterns{qw(
                    namedVar
                    symVar
                   )

ppParser.yp  view on Meta::CPAN

 my %embeddedParagraphs;
 @embeddedParagraphs{
                     DIRECTIVE_UPOINT,
                     DIRECTIVE_OPOINT,
                    }=();

 # declare token descriptions (to be used in error messages)
 my %tokenDescriptions=(
                        EOL                      => 'a carriage return',
                        Embed                    => 'embedded code',
                        Embedded                 => 'an \END_EMBED tag',
                        Empty_line               => 'an empty line',
                        Heredoc_close            => 'a string closing the "here document"',
                        Heredoc_open             => 'a "here document" opener',
                        Ils                      => 'a indentation',
                        Include                  => 'an included part',
                        Named_variable           => 'a named variable',
                        Space                    => 'a whitespace',
                        StreamedPart             => undef,
                        Symbolic_variable        => 'a symbolic variable',
                        Table                    => 'a table',

ppParser.yp  view on Meta::CPAN

                              and (
                                      $_[1][0][1][STREAM_DIR_DATA]=~/^(TABLE)$/
                                   or (
                                           $_[1][0][1][STREAM_DIR_DATA]=~/^(\w+)$/
                                       and (
                                               (
                                                    exists $tagsRef->{$1}
                                                and exists $tagsRef->{$1}{standalone}
                                                and $tagsRef->{$1}{standalone}
                                               )
                                            or $1 eq 'EMBED'
                                           )
                                      )
                                  )

                              # ending with the same tag?
                              and ref($_[1][0][-2]) eq 'ARRAY'
                              and $_[1][0][-2][STREAM_DIR_TYPE]==DIRECTIVE_TAG
                              and $_[1][0][-2][STREAM_DIR_DATA] eq $1

                              # both building the same tag?

ppParser.yp  view on Meta::CPAN

                      }
                   }
                ;


embedded : Embed
            {
             # switch to embedding mode saving the former state (including *all* special settings)
             push(@stateStack, $parserState);
             push(@specialStack, [%specials]);
             _stateManager(STATE_EMBEDDING);

             # trace, if necessary
             warn "[Trace] $sourceFile, line $_[1][1]: Embedding starts.\n" if $flags{trace} & TRACE_PARAGRAPHS;

             # Disable storage of a checksum. (Dynamic parts may change or have changed.
             # Static parts are static of course, but the filter settings may vary.)
             $flags{checksummed}=0;

             # temporarily activate specials "{" and "}"
             push(@specialStack, @specials{('{', '}')});

ppParser.yp  view on Meta::CPAN

                # we have to supply something, but it should be nothing
                [[()], $_[6][1]];
               }
             else
               {
                # reply data in a "tag envelope" (for backends)
                my %hints=(nr=>++$directiveCounter);
                [
                 [
                  # opener directive
                  [\%hints, DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED', \%pars],
                  # the list of enclosed literals, if any
                  @{$_[5][0]} ? @{$_[5][0]} : (),
                  # final directive
                  [\%hints, DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED', \%pars]
                 ],
                 $_[6][1]
                ];
               }
            }
          ;


included : Include
            {

ppParser.yp  view on Meta::CPAN

                          ],
                          $_[3][1]
                         ];
                        }
                      else
                        {
                         my %hints=(nr=>++$directiveCounter);
                         [
                          [
                           # opener directive
                           [\%hints, DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED', {lang=>$tagpars{type}}],
                           # the list of enclosed "literals", if any
                           @included,
                           # final directive
                           [\%hints, DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED', {lang=>$tagpars{type}}]
                          ],
                          $_[3][1]
                         ];
                        }
                     }
                  }
                else
                  {
                   # file missing, simply inform user
                   $errors++, _semerr($_[0], "$sourceFile, line $_[3][1]: File $tagpars{file} does not exist or cannot be read (current directory: ", cwd(), ").");

ppParser.yp  view on Meta::CPAN

     # reply next token: scan for SPECIAL tagnames: \TABLE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Table starts in line $lineNrs{$inHandle}.\n")),
     return('Table', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{table}/;

     # reply next token: scan for SPECIAL tagnames: \END_TABLE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Table completed in line $lineNrs{$inHandle}.\n")),
     return('Tabled', [$found, $lineNrs{$inHandle}])  if $specials{tag} and /^$lexerPatterns{endTable}/;

     # reply next token: scan for SPECIAL tagnames: \EMBED
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Embedding starts in line $lineNrs{$inHandle}.\n")),
     return('Embed', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{embed}/;

     # reply next token: scan for SPECIAL tagnames: \END_EMBED
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Embedding completed in line $lineNrs{$inHandle}.\n")),
     return('Embedded', [$found, $lineNrs{$inHandle}]) if $specials{embedded} and /^$lexerPatterns{endEmbed}/;

     # reply next token: scan for SPECIAL tagnames: \INCLUDE
     $found=$1, s/^\\$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Including starts in line $lineNrs{$inHandle}.\n")),
     return('Include', [$found, $lineNrs{$inHandle}]) if $specials{tag} and /^$lexerPatterns{include}/;

     # reply next token: scan for tagnames

ppParser.yp  view on Meta::CPAN

     # likewise, flag that this paragraph *might* use variables someday, if there is still something being no variable,
     # but looking like a variable (somebody could *later* declare it a real var, so the cache
     # needs to check variable definitions)
     $flags{checksummed}[4]=1
       if     /($lexerPatterns{namedVarKernel})|($lexerPatterns{symVarKernel})/
          and not (exists $flags{checksummed} and not $flags{checksummed});

     # remove guarding \\, if necessary
     s/^\\// unless    $specials{heredoc}
                    or (defined $lexerFlags{backsl} and $lexerFlags{backsl}==LEXER_TOKEN)
                    or $parserState==STATE_EMBEDDING
                    or $parserState==STATE_PFILTER
                    or $parserState==STATE_CONDITION
                    or $parserState==STATE_DEFINITION;

     # reply next token: scan for numbers, if necessary
     $found=$1, s/^$1//,
     (($flags{trace} & TRACE_LEXER) and warn("[Trace] Lexer: Number $found in line $lineNrs{$inHandle}.\n")),
     return('Number', [$found, $lineNrs{$inHandle}]) if $specials{number} and /^(\d+)/;

     unless ($flags{noboost})

ppParser.yp  view on Meta::CPAN

  # check parameter
  confess "[BUG] Invalid new state $newState passed.\n" unless    $newState==STATE_DEFAULT
                                                               or $newState==STATE_DEFAULT_TAGMODE
                                                               or $newState==STATE_TEXT
                                                               or $newState==STATE_UPOINT
                                                               or $newState==STATE_OPOINT
                                                               or $newState==STATE_DPOINT
                                                               or $newState==STATE_DPOINT_ITEM
                                                               or $newState==STATE_BLOCK
                                                               or $newState==STATE_VERBATIM
                                                               or $newState==STATE_EMBEDDING
                                                               or $newState==STATE_PFILTER
                                                               or $newState==STATE_PFILTERED
                                                               or $newState==STATE_CONDITION
                                                               or $newState==STATE_HEADLINE_LEVEL
                                                               or $newState==STATE_HEADLINE
                                                               or $newState==STATE_TABLE
                                                               or $newState==STATE_DEFINITION
                                                               or $newState==STATE_CONTROL
                                                               or $newState==STATE_COMMENT;

ppParser.yp  view on Meta::CPAN

     @specials{('.', '/', '*', '#', '=', '<', '>', '{', '}' , '-', '?', '@', '+', '~', 'heredoc', 'colon', 'tag', 'embedded', 'number', 'pfilter')}=(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0);

     # trace, if necessary
     warn "[Trace] Entered verbatim state.\n" if $flags{trace} & TRACE_SEMANTIC;

     # well done
     return;
    };

  # enter new state: embedding
  $newState==STATE_EMBEDDING and do
    {
     # prepare lexer
     @lexerFlags{qw(ils eol el cbell)}=(LEXER_SPACE, LEXER_TOKEN, LEXER_TOKEN, LEXER_IGNORE);

     # activate special characters as necessary
     @specials{('.', '/', '*', '#', '=', '<', '>', '{', '}' , '-', '?', '@', '+', '~', 'heredoc', 'colon', 'tag', 'embedded', 'number', 'pfilter')}=(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0);

     # trace, if necessary
     warn "[Trace] Entered embedding state.\n" if $flags{trace} & TRACE_SEMANTIC;

t/cache.pp  view on Meta::CPAN

value is $value.




$nested1=$word $value

$nested2=$number $nested1 $number


\EMBED{lang=perl}$main::nested2;\END_EMBED




\INCLUDE{file="pfilter-code.pp" type=pp}


||numberLines||=A filtered headline


t/embedded.pp  view on Meta::CPAN


=Embedded

Literal text with an \EMBED{lang=html}<i>embedded</i>\END_EMBED part.

Here we go for more.

\EMBED{lang=HTML}

<i>This is embedded <b>HTML</b>.</i>

\END_EMBED

Here the literal \EMBED{lang=perl}"text"\END_EMBED continues.

\EMBED{lang=PERL}

# build a message
my $msg="Perl may be embedded as well.";

# and supply it
$msg;

\END_EMBED

\EMBED{lang=filtered}This part should be filtered out.\END_EMBED

Perl Point \EMBED{lang=pp}can \EMBED{lang=pp}be \EMBED{lang=pp}nested\END_EMBED\END_EMBED\END_EMBED.

Well.

t/ifilters.pp  view on Meta::CPAN


// declare the filter function
\EMBED{lang=perl}

sub lang2pp
 {
  # flag variable
  my $paragraphStart=1;

  # we know that we get the lines in an array, so ...
  foreach (@_ifilterText)
   {
    # recognize empty lines which start new paragraphs

t/ifilters.pp  view on Meta::CPAN

    $paragraphStart and s/^(\*+)\s*/'=' x length($1)/e and (($paragraphStart=0), next);

    # translate bullet points
    $paragraphStart and s/^-(\s+)/*$1/ and (($paragraphStart=0), next);
   }

  # supply the translated text
  @_ifilterText;
 }

\END_EMBED


=A starting headline

Now the included file:

\INCLUDE{file="ifilters.lang" ifilter=lang2pp type=pp headlinebase=CURRENT_LEVEL}

And now, we embed something in this language. \EMBED{lang=pp ifilter=lang2pp}Oops!

Another lang(usage) source!

- lang is simple

- PerlPoint is simple and powerfull

OK!

\END_EMBED

Well.



t/l0_embedded.t  view on Meta::CPAN

 is(join(' ', @$docstreams), '');
}

checkHeadline(\@results, 1, ['Embedded'], ['Embedded'], [1], [1], $varhash);

is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Embedded');
is(shift(@results), $_) foreach (DIRECTIVE_HEADLINE, DIRECTIVE_COMPLETE, 1);

is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Literal text with an ');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '<i>embedded</i>');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'part.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Here we go for more');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);

is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'HTML');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '<i>This is embedded <b>HTML</b>.</i>');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'HTML');
}

is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Here the literal ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'text continues.');

t/l0_embedded.t  view on Meta::CPAN

 is(join(' ', @$docstreams), '');
}

checkHeadline(\@results, 1, ['Embedded'], ['Embedded'], [1], [1], $varhash);

is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Embedded');
is(shift(@results), $_) foreach (DIRECTIVE_HEADLINE, DIRECTIVE_COMPLETE, 1);

is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Literal text with an ');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '<i>embedded</i>');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'part.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Here we go for more');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);

is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'HTML');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '<i>This is embedded <b>HTML</b>.</i>');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'HTML');
}

is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Here the literal ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'text continues.');

t/l0_include1.t  view on Meta::CPAN

is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'something.');
is(shift(@results), $_) foreach (DIRECTIVE_BLOCK, DIRECTIVE_COMPLETE);
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Continued frame source');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);

is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_START);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'Now we include another file type ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '- by declaration: ');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'anything');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "This text was included.\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\\INCLUDE{type=pp file=\"include2.pp\" headlinebase=10}\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "This was the source:\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, qq(\\INCLUDE{type=example file="include2.pp" indent=2}\n));
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'anything');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'This can be done multiply, look: ');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'anything');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "This text was included.\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\\INCLUDE{type=pp file=\"include2.pp\" headlinebase=10}\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "This was the source:\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, qq(\\INCLUDE{type=example file="include2.pp" indent=2}\n));
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, "\n");
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join(' ', sort keys %$pars), 'lang');
 is(join(' ', sort values %$pars), 'anything');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);

t/l0_macros.t  view on Meta::CPAN

is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'I');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join('', sort keys %$pars), '');
}
is(shift(@results), 5);
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'is formatted by nested macros.');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_START, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join('', sort keys %$pars), 'lang');
 is(join('', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, ' ');
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, 'This is <i>embedded HTML</i>');
is(shift(@results), $_) foreach (DIRECTIVE_TAG, DIRECTIVE_COMPLETE, 'EMBED');
{
 my $pars=shift(@results);
 is(ref($pars), 'HASH');
 is(join('', sort keys %$pars), 'lang');
 is(join('', sort values %$pars), 'html');
}
is(shift(@results), $_) foreach (DIRECTIVE_SIMPLE, DIRECTIVE_START, '.');
is(shift(@results), $_) foreach (DIRECTIVE_TEXT, DIRECTIVE_COMPLETE);

# 4th section

t/macros.pp  view on Meta::CPAN

+RED:\FONT{color=red}<__body__>

+F:\FONT{color=__c__}<__body__>

+IB:\I<\B<__body__>>

+DEFAULTS{value1=default value2="values as set up"}:__value1__ __value2__

This \IB<text> is \RED<colored>.

+HTML:\EMBED{lang=html}

+TEXT:Macros can be used to abbreviate longer
texts as well as other tags
or tag combinations.

Macro options can be preset to contain \DEFAULTS. If you want,
you can assign \DEFAULTS{value1="up to date" value2=values}.

Tags can be \RED<\I<nested>> into macros. And \I<\RED<vice versa>>.
\IB<\F{c=blue}<This>> is formatted by nested macros.
\HTML This is <i>embedded HTML</i>\END_EMBED.

\TEXT

t/pfilter-code.pp  view on Meta::CPAN


\EMBED{lang=perl}

 # a very general test filter
 sub numberLines
  {
   # get parameters: start value
   my ($counter)=@_;
   $counter=1 unless defined $counter;

   # declare variables
   my ($buffer, @results, @lines, @buffer)=(0, '');

t/pfilter-code.pp  view on Meta::CPAN

     push(@results, join('', sprintf("%.2d: ", $counter++), $line));
    }

   # complete result
   unshift(@results, $buffer[0]), push(@results, $buffer[1]) if $main::_pfilterType eq 'verbatim block';

   # provide result
   join('', map {"$_\n"} @results);
  }

\END_EMBED

t/variables.pp  view on Meta::CPAN

value is $value.




$nested1=$word $value

$nested2=$number $nested1 $number


\EMBED{lang=perl}$main::nested2;\END_EMBED


Predeclared were $VAR1 $VAR2.

utilities/PerlPoint.clp  view on Meta::CPAN

H="figure"
\IMAGE{file="^&"}


H=";Active contents"

H="condition"
? ^&

H="embedded PerlPoint"
\EMBED{type=pp}^&\END_EMBED

H="embedded Perl"
\EMBED{type=perl}^&\END_EMBED

H="embedded ..."
\EMBED{type="..."}^&\END_EMBED

H="included PerlPoint"
\INCLUDE{lang=pp file="^&"}

H="included Perl"
\INCLUDE{lang=perl file="^&"}

H="included ..."
\INCLUDE{lang="" file="^&"}



( run in 1.327 second using v1.01-cache-2.11-cpan-71847e10f99 )