Data-Edit-Xml
view release on metacpan or search on metacpan
lib/Data/Edit/Xml.pm view on Meta::CPAN
{$o->putPrevAsText(q( [));
$o->putNextAsText(q(] ));
}
else
{$o->putPrevAsText(q( {));
$o->putNextAsText(q(} ));
}
my ($c, @c) = @$o;
$_->putPrevAsText(q( | )) for @c;
}
elsif ($i eq q(optional)) # Non group choice just has square brackets
{$o->putPrevAsText(q( [));
$o->putNextAsText(q(] ));
}
if ($o->at_syntaxdiagram) # Map tags
{$o->change_p;
$o->outputclass = q(syntaxdiagram);
}
elsif ($o->at_kwd and $o->outputclassX eq q(command))
{$o->change_cmdname;
}
elsif ($o->at_kwd)
{$o->change_codeph;
}
elsif ($o->at_var)
{$o->change_userinput;
}
elsif ($o->at_sep)
{$o->change_codeph;
}
elsif ($o->at_groupseq or $o->at_groupchoice)
{$o->unwrap;
}
$o->deleteAttrs_outputclass_importance;
});
} # ditaSyntaxDiagramToBasicRepresentation
sub ditaUnderPNotConbody #P Return a hash of items that L<Dita> permits under B<p> but not directly under B<conbody>
{{
"abbreviated-form" => 1,
"apiname" => 1,
"b" => 1,
"boolean" => 1,
"CDATA" => 1,
"cite" => 1,
"cmdname" => 1,
"codeph" => 1,
"equation-inline" => 1,
"filepath" => 1,
"fn" => 1,
"i" => 1,
"indexterm" => 1,
"indextermref" => 1,
"keyword" => 1,
"line-through" => 1,
"markupname" => 1,
"menucascade" => 1,
"msgnum" => 1,
"msgph" => 1,
"numcharref" => 1,
"option" => 1,
"overline" => 1,
"parameterentity" => 1,
"parmname" => 1,
"ph" => 1,
"q" => 1,
"state" => 1,
"sub" => 1,
"sup" => 1,
"synph" => 1,
"systemoutput" => 1,
"term" => 1,
"text" => 1,
"textentity" => 1,
"tm" => 1,
"tt" => 1,
"u" => 1,
"uicontrol" => 1,
"userinput" => 1,
"varname" => 1,
"wintitle" => 1,
"xmlatt" => 1,
"xmlelement" => 1,
"xmlnsname" => 1,
"xmlpi" => 1,
"xref" => 1,
}} # ditaUnderPNotConbody
sub ditaWrapWithPUnderConbody($) #U Wrap items immediately under L<DITA> B<conbody> with B<p> or merge with any previous B<p> if the item in question does not fit under B<conbody> but does fit under B<p>...
{my ($conbody) = @_; # Section
$conbody->at_conbody or confess "Not a conbody, its a ". -t $conbody; # Check we are on a conbody
my $fit = ditaUnderPNotConbody; # Tags that need to be wrapped with B<p> if they occur directly under B<conbody>.
my $p; # Last p encountered
my @c = @$conbody; # Each direct child of conbody
for my $c(@c) # Each direct child of conbody
{if ($$fit{-t $c}) # Better as a p
{if ($p) # Prior tag is p
{$p->putLastCut($c); # Merge
}
else # Start new p
{$p = $c->wrapWith_p; # Wrap with p and make new p
}
}
elsif ($c->at_p) # Tag is p - so make it the last p
{$p = $c; # P tag becomes last p
}
else # Not on a p and not better wrapped in p
{$p = undef; # New p required
}
}
}
#D1 PCD # Please Change Dita Language Features
our %savedNodes; #E Hash of saved nodes
sub putNodeAs($$@) #CU Return the specified B<$node> after saving it under the specified B<$name> if we are in the optional B<@context>.
( run in 1.387 second using v1.01-cache-2.11-cpan-df04353d9ac )