diff --git a/lib/LaTeXML/Core/Document.pm b/lib/LaTeXML/Core/Document.pm index aa04f1db4..637945909 100644 --- a/lib/LaTeXML/Core/Document.pm +++ b/lib/LaTeXML/Core/Document.pm @@ -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, @@ -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!