From b3fc81396147a4df176cd86cbf0e42e73fdc418f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 10 Aug 2012 14:29:35 -0400 Subject: Rewrite section code. --- (limited to 'scripts/MarkdownBook/HTMLTree.pm') diff --git a/scripts/MarkdownBook/HTMLTree.pm b/scripts/MarkdownBook/HTMLTree.pm index 27db3e1..419eb53 100644 --- a/scripts/MarkdownBook/HTMLTree.pm +++ b/scripts/MarkdownBook/HTMLTree.pm @@ -43,30 +43,30 @@ sub find_elements_by_tag_names sub each_text { - my ($code, $elem, @args) = @_; + my ($elem) = @_; my $child = $elem; my $root = $elem; - _each_text_recursive($code, $child, $root, @args); + return _each_text_recursive($child, $root); } sub _each_text_recursive { - my ($code, $elem, $root, @args) = @_; + my ($elem, $root) = @_; my $child; - my $i = -1; + my @retlist = (); foreach $child ($elem->content_list()) { - ++$i; if (ref($_) eq 'HTML::Element') { - _each_text_recursive($code, $child, $root, @args); + push(@retlist, _each_text_recursive($child, $root)); } else { - $code->(\$root, $child, @args); - $elem->splice_content($i, 1, $child); + push(@retlist, $child); } } + + return @retlist; } 1; -- cgit v0.9.1