Skip to content

Commit

Permalink
add test for .xml(:roles) option
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed Jul 23, 2023
1 parent cccc27b commit c607b38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ my $figure = $doc.Figure: $gfx, $img, :position[50, 70], :Alt("A light-bulb");
```

An [PDF::XObject::Form](https://pdf-raku.github.io/PDF-Class-raku/PDF/XObject/Form) may be associated with a marked content
sub-tree. This may be achieved by marking the form against a document fragment, then calling `do` to repeatably
sub-tree. This is achieved by marking the form against a document fragment, then calling `do` to repeatably
render the form, while inserting the fragment, as demonstrated below:

```raku
Expand Down Expand Up @@ -239,7 +239,7 @@ a copy of the fragment into the structure tree.
### Links

Links are usually contained in a block element, such as a `Paragraph`. If
the link is internal, it should further be enclosed in a `Reference` element.
the link is internal, it should be further enclosed in a `Reference` element.

Furthermore, if the link is in flowing text, such as a paragraph, the
`mark` method may be needed to mark preceding text, the link, and
Expand Down
1 change: 0 additions & 1 deletion lib/PDF/Tags.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class PDF::Tags:ver<0.1.10> {
unless $base eq $_;
}
else {
warn "setting role $role => $base";
$_ = $base;
}
}
Expand Down
7 changes: 5 additions & 2 deletions t/role-maps.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 11;
plan 13;

use PDF::Content::FontObj;
use PDF::Content::Tag :Tags;
Expand Down Expand Up @@ -46,6 +46,9 @@ $page.graphics: -> $gfx {
is $fn1.name, 'Note';
is $fn1.attributes<role>, 'Footnote';

is $fn1.xml.lines.map(*.trim).join, '<Note role="Footnote">¹With a foot-note</Note>';
is $fn1.xml(:roles).lines.map(*.trim).join, '<Footnote>¹With a foot-note</Footnote>';

my $fn2 = $doc.add-kid: :name<Footnote>, $gfx, {
.print: '²And another foot-note', :position[50, 50];
};
Expand All @@ -58,6 +61,6 @@ $pdf.id = $*PROGRAM-NAME.fmt('%-16.16s');

is $tags.find('Document//*')>>.name.join(','), 'H1,P,Note,Note';

lives-ok { $pdf.save-as: "t/role-maps.pdf", :!info };
lives-ok { $pdf.save-as: "t/role-maps.pdf", :!info };

done-testing;

0 comments on commit c607b38

Please sign in to comment.