Skip to content

Commit

Permalink
Be careful of unexpected Comment nodes when scanning element children…
Browse files Browse the repository at this point in the history
… for specific patterns
  • Loading branch information
brucemiller committed Sep 22, 2024
1 parent d3d3fcc commit d207190
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/LaTeXML/Engine/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,11 @@ sub applyAligningContext {
if (my $container = LookupValue('ALIGNING_NODE')) {
my ($node, $previous) = @$container;
my @children = $node->childNodes;
while (my $skip = shift(@children)) {
last if !$previous || $previous->isSameNode($skip); }
while (@children) {
my $skip = $children[0];
last if !$previous;
shift(@children);
last if $previous->isSameNode($skip); }
while (my $child = shift(@children)) {
setAlignOrClass($document, $child, $align, $class) if $child->nodeType == XML_ELEMENT_NODE; } }
return; }
Expand Down
4 changes: 2 additions & 2 deletions lib/LaTeXML/Engine/TeX_Box.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ sub insertBlock {
my $inline = $is_svg || $document->canContain($context_tag, '#PCDATA');
my $container = $document->openElement('ltx:_CaptureBlock_', '_vertical_mode_' => 1, %blockattr);
$document->absorb($contents);
my @nodes = $container->childNodes;
my @node_tags = map { $document->getNodeQName($_); } @nodes;
my @nodes = grep { $_->nodeType != XML_COMMENT_NODE; } $container->childNodes;
my @node_tags = map { $document->getNodeQName($_); } @nodes;
my $nnodes = scalar(@nodes);
$document->closeToNode($container, 1);
$document->closeNode($container);
Expand Down

0 comments on commit d207190

Please sign in to comment.