-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script na vytažení všech použitých tagů pasáží
- Loading branch information
1 parent
285101b
commit 1732064
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/perl | ||
|
||
my $usage = | ||
"usage: ./gather-tags.pl TWINE_HTML [-l]\n" . | ||
" prints all existing passage tags\n"; | ||
|
||
|
||
if (not defined $ARGV[0]) { | ||
print $usage; | ||
exit 1; | ||
} | ||
|
||
open(HTML, '<', $ARGV[0]) or die "couldn't open the file: $ARGV[0]"; | ||
|
||
my %tags; | ||
while (<HTML>) { | ||
if ($_ =~ /<tw-passagedata [^>]* tags="([^"]*)"/) { | ||
for my $word (split(/\s+/, $1)) { | ||
$tags{$word} = 1; | ||
} | ||
} | ||
} | ||
|
||
for (keys %tags) { | ||
if ($ARGV[1] eq "-l") { | ||
print "$_\n"; | ||
} else { | ||
print "$_, "; | ||
} | ||
} | ||
|
||
|