Dita-PCD

 view release on metacpan or  search on metacpan

lib/Dita/PCD.pm  view on Meta::CPAN


    next unless $l =~ m(\S);                                                    # Ignore empty rows

    if ($l =~ m(\A\s*#\s*(.*?)\s*\Z))                                           # Comment
     {push @p, newDitaPcdComment(comment=>trim($1));
     }
    elsif ($l =~ m(\A\S))                                                       # Description
     {push @p, newDitaPcdDescription(description=>$l);
     }
    else                                                                        # Method
     {if (my ($method, @context) = split m/\s+/, trim($l))                      # Parse command string invoking method
       {push @p, newDitaPcdMethod(method=>$method, context=>[@context]);
       }
     }
   }

  newDitaPcdParseTree(rows => \@p)                                              # Parse tree
 } # parsePcdString

sub parsePcdFile($)                                                             #P Parse the specified L<pcd> directives B<$file> specifying changes to be made to L<dita> files.
 {my ($if) = @_;                                                                # Input file

lib/Dita/PCD.pm  view on Meta::CPAN

     }
   }

  join "\n", @t, '';
 } # representPcdParseTreeAsText

sub compilePcdString($;$)                                                       #P Compile the specified L<pcd> directives in the supplied B<$string> optionally associated with B<$file>.
 {my ($string, $file) = @_;                                                     # Input string, optional name of file associated with string
  my $if = $file // q();                                                        # Nominal file

  my @l = split m/\n/, $string;

  my @blocks;
  for my $i(keys @l)                                                            # Each line==row a pcd file
   {my $l = $l[$i];
    my $j = $i + 1;

    next if $l =~ m(\A\s*#|\A\s*\Z);                                            # Comment

    if ($l =~ m(\A\S)s)                                                         # Change description
     {push @blocks, [[trim($l), $i+1, $if], []];
     }
    else                                                                        # Change command block
     {if (my ($cmd, @Keys) = split m/\s+/, trim($l))                            # Parse command
       {my @keys;

        for my $key(@Keys)                                                      # Transforms keys into Perl strings
         {if    ($key =~ m(undef))       {push @keys, "undef"}                  # Undef for anything
          elsif ($key =~ m/\Aqr(.*)\Z/s) {push @keys, $key}                     # Words wrapped with qr(.*) are regular expressions
          elsif ($key =~ m(\|)s)         {push @keys, "qr(\\A($key)\\Z)"}       # Words separated by | are a regular expression indicating choice of tags
          else                           {push @keys,      "q($key)"}
         }

        if (isSubInPackage(q(Data::Edit::Xml), $cmd))                           # Validate command



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