Skip to content

Commit

Permalink
This is the official name in PDF 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed Oct 25, 2023
1 parent 0d9b55f commit 125bf6b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{$NEXT}}
- Use 'DocumentFragment' to name document fragments. It's the
official name in PDF 2.0

0.1.12 2023-10-21T09:20:59+13:00
- Add support for Lang attribute in XML and element construction
Expand Down
2 changes: 1 addition & 1 deletion lib/PDF/Tags/Elem.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class PDF::Tags::Elem
die "element contains multiple xobjects" if @xobjects > 1;
my PDF::XObject:D $Stm = @xobjects[0];
my PDF::Tags::Elem $node = $frag.copy-tree(:$Stm, :$parent);
if $node.name eq '#frag' {
if $node.name eq 'DocumentFragment' {
$parent.add-kid(:node($_)) for $node.kids;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion lib/PDF/Tags/Node.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PDF::Tags::Node {
use Method::Also;

my subset TagName of Str is export(:TagName)
where Str:U | /^<ident>$/ | '#frag';
where Str:U | /^<ident>$/;

has PDF::Tags::Node::Root $.root is required handles<role-map>;
has PDF::Page $.Pg; # current page scope
Expand Down
6 changes: 3 additions & 3 deletions lib/PDF/Tags/Node/Parent.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class PDF::Tags::Node::Parent
method !adopt-node($node) {
# checks
die "unable to add fragment"
if $node.name eq '#frag';
if $node.name eq 'DocumentFragment';
die "unable to add a node to itself"
if $node === self || $node.cos === self.cos;

with $node.parent {
die "node already parented"
unless $_ === self || .name eq '#frag';
unless $_ === self || .name eq 'DocumentFragment';
}

# re-parent cos node
Expand Down Expand Up @@ -109,7 +109,7 @@ class PDF::Tags::Node::Parent
my $parent = self.WHAT;
self.build-kid($cos, :$parent, |%o);
}
multi method fragment(Str:D $name = '#frag', *%o) {
multi method fragment(Str:D $name = 'DocumentFragment', *%o) {
self.fragment(:$name, |%o);
}
multi method FALLBACK(Str:D $name where $_ TagSet, |c) {
Expand Down
2 changes: 1 addition & 1 deletion t/write-tags.t
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $page.graphics: -> $gfx {
my $p = $form-frag.Paragraph: $_, {
.say: "Some sample tagged text", :font($body-font), :$font-size;
};
is $p.node-path, '#frag/P[1]';
is $p.node-path, 'DocumentFragment/P[1]';
}

$doc.do($gfx, $form-frag, :position[150, 70]);
Expand Down

0 comments on commit 125bf6b

Please sign in to comment.