Skip to content

Commit

Permalink
Issue warning for inappropriate object set for attribute value
Browse files Browse the repository at this point in the history
  • Loading branch information
brucemiller committed Jan 7, 2025
1 parent f05321b commit 6dcbbb0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/LaTeXML/Core/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ sub serialize_aux {
(map { $_ . '="' . $atnodes{$_} . '"' } sort keys %atnodes)
);
my $noindent_children = ($heuristic
# This emulates libxml2's heuristic
# ? $noindent || grep { $_->nodeType != XML_ELEMENT_NODE } @children
# This emulates libxml2's heuristic
# ? $noindent || grep { $_->nodeType != XML_ELEMENT_NODE } @children
? $noindent || grep { $_->nodeType == XML_TEXT_NODE } @children
# This is the "Correct" way to determine whether to add indentation
# This is the "Correct" way to determine whether to add indentation
: $model->canContain(getNodeQName($self, $node), '#PCDATA'));
return join('',
($noindent ? '' : $indent), $start,
Expand Down Expand Up @@ -1376,12 +1376,15 @@ sub makeError {
# [xml:id and namespaced attributes are always allowed]
sub setAttribute {
my ($self, $node, $key, $value) = @_;
return if (ref $value) && ((!blessed($value)) || !$value->can('toAttribute'));
if (ref $value) {
if ($key eq '_box') {
return $self->setNodeBox($node, $value); }
elsif ($key eq '_font') {
return $self->setNodeFont($node, $value); }
elsif ((!blessed($value)) || !$value->can('toAttribute')) {
Warn('unexpected', (ref $value), $self,
"Don't know how to encode $value as an attribute value");
return; }
else {
$value = $value->toAttribute; } }
if ((defined $value) && ($value ne '')) { # Skip if `empty'; but 0 is OK!
Expand Down

0 comments on commit 6dcbbb0

Please sign in to comment.