Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stray comments #2420

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/LaTeXML/Common/XML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ our @EXPORT = (
decodeFromUTF8 ),
@XML::LibXML::EXPORT,
# Possibly (later) export these utility functions
qw(&element_nodes &text_in_node &new_node &element_next &element_prev
qw(&element_nodes &content_nodes &text_in_node &new_node &element_next &element_prev
&append_nodes &clear_node &maybe_clone
&valid_attributes &copy_attributes &rename_attribute &remove_attr
&get_attr &isTextNode &isElementNode &isChild &isDescendant &isDescendantOrSelf
Expand All @@ -89,10 +89,18 @@ our $XML_NS = 'http://www.w3.org/XML/1998/namespace'; # [CONSTANT]

#======================================================================
# XML Utilities

# Return all child elements of $node
sub element_nodes {
my ($node) = @_;
return ($node ? grep { $_->nodeType == XML_ELEMENT_NODE } $node->childNodes : ()); }

# return all content (element and text) nodes of $node
sub content_nodes {
my ($node) = @_;
return ($node ? grep { my $t = $_->nodeType; $t == XML_ELEMENT_NODE || $t == XML_TEXT_NODE }
$node->childNodes : ()); }

sub text_in_node {
my ($node) = @_;
return ($node ? join("\n", map { $_->data } grep { $_->nodeType == XML_TEXT_NODE } $node->childNodes) : ''); }
Expand Down
5 changes: 3 additions & 2 deletions lib/LaTeXML/Engine/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,9 @@ 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); }
if ($previous) {
while (my $skip = 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
2 changes: 1 addition & 1 deletion lib/LaTeXML/Engine/TeX_Box.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ 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 @nodes = content_nodes($container);
my @node_tags = map { $document->getNodeQName($_); } @nodes;
my $nnodes = scalar(@nodes);
$document->closeToNode($container, 1);
Expand Down
32 changes: 16 additions & 16 deletions t/alignment/colortbls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ p{3cm}}"?>
<tbody>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">P-column</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">P-column</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">and another one</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">and another one</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}12\cdot 34" text="12.34" xml:id="S2.T1.m1">
<XMath>
Expand All @@ -117,10 +117,10 @@ p{3cm}}"?>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">Some long text in the first column</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">Some long text in the first column</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">bbb</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">bbb</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}1\cdot 2" text="1.2" xml:id="S2.T1.m3">
<XMath>
Expand All @@ -130,10 +130,10 @@ p{3cm}}"?>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">aaa</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">aaa</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">and some long text in the second column</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">and some long text in the second column</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}1\cdot 345" text="1.345" xml:id="S2.T1.m4">
<XMath>
Expand All @@ -152,10 +152,10 @@ p{3cm}}"?>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">aaa</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">aaa</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">bbb</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">bbb</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}1\cdot 345" text="1.345" xml:id="S2.T1.m6">
<XMath>
Expand All @@ -165,11 +165,11 @@ p{3cm}}"?>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">Note that the coloured rules in all columns stretch to accomodate
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">Note that the coloured rules in all columns stretch to accomodate
large entries in one column.</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">bbb</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">bbb</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}1\cdot 345" text="1.345" xml:id="S2.T1.m7">
<XMath>
Expand All @@ -179,10 +179,10 @@ large entries in one column.</text></p>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">aaa</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">aaa</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">bbb</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">bbb</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}100" text="100" xml:id="S2.T1.m8">
<XMath>
Expand All @@ -192,10 +192,10 @@ large entries in one column.</text></p>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">aaa</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">aaa</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">Depending on your driver you may get unsightly gaps or lines
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">Depending on your driver you may get unsightly gaps or lines
where the ‘screens’ used to produce different shapes interact
badly. You may want to cause adjacent panels of the same colour by
specifying a larger overhang
Expand All @@ -209,10 +209,10 @@ or by adding some negative space (in a ”“noalign” between rows.</text></p>
</tr>
<tr>
<td align="justify" backgroundcolor="#FF0000" vattach="top"><inline-block vattach="top">
<p width="56.9pt"><text backgroundcolor="#FF0000" color="#FFFFFF">aaa</text></p>
<p width="56.9pt"><text backgroundcolor="#FF0000" class="ltx_align_left" color="#FFFFFF">aaa</text></p>
</inline-block></td>
<td align="justify" backgroundcolor="#0000FF" vattach="top"><inline-block vattach="top">
<p width="85.4pt"><text backgroundcolor="#0000FF" color="#FFFF00">bbb</text></p>
<p width="85.4pt"><text backgroundcolor="#0000FF" class="ltx_align_left" color="#FFFF00">bbb</text></p>
</inline-block></td>
<td align="char:⋅" backgroundcolor="#FFFF00"><Math mode="inline" tex="\pagecolor{yellow}45\cdot 3" text="45.3" xml:id="S2.T1.m10">
<XMath>
Expand Down
8 changes: 4 additions & 4 deletions t/complex/figure_dual_caption.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<tag role="typerefnum">Figure 2</tag>
</tags>
<figure align="center" class="ltx_figure_panel ltx_minipage" vattach="middle" width="216.8pt" xml:id="S0.F2.fig1">
<graphics candidates="../graphics/none.png" graphic="../graphics/none.png" options="width=411.93767pt,keepaspectratio=true" xml:id="S0.F2.g1"/>
<graphics candidates="../graphics/none.png" class="ltx_centering" graphic="../graphics/none.png" options="width=411.93767pt,keepaspectratio=true" xml:id="S0.F2.g1"/>
<toccaption class="ltx_centering"><tag close=" ">1</tag>Left figure.</toccaption>
<caption class="ltx_centering"><tag close=": ">Figure 1</tag>Left figure.</caption>
</figure>
<figure align="center" class="ltx_figure_panel ltx_minipage" vattach="middle" width="216.8pt" xml:id="S0.F2.fig2">
<graphics candidates="../graphics/none.png" graphic="../graphics/none.png" options="width=411.93767pt,keepaspectratio=true" xml:id="S0.F2.g2"/>
<graphics candidates="../graphics/none.png" class="ltx_centering" graphic="../graphics/none.png" options="width=411.93767pt,keepaspectratio=true" xml:id="S0.F2.g2"/>
<toccaption class="ltx_centering"><tag close=" ">2</tag>Right figure.</toccaption>
<caption class="ltx_centering"><tag close=": ">Figure 2</tag>Right figure.</caption>
</figure>
Expand All @@ -29,7 +29,7 @@
<tag role="typerefnum">Table 2</tag>
</tags>
<figure align="center" class="ltx_figure_panel ltx_minipage" vattach="middle" width="216.8pt" xml:id="S0.T2.fig1">
<tabular vattach="middle">
<tabular class="ltx_centering" vattach="middle">
<tbody>
<tr>
<td align="center">a</td>
Expand All @@ -47,7 +47,7 @@
<caption class="ltx_centering"><tag close=": ">Table 1</tag>Left table.</caption>
</figure>
<figure align="center" class="ltx_figure_panel ltx_minipage" vattach="middle" width="216.8pt" xml:id="S0.T2.fig2">
<tabular vattach="middle">
<tabular class="ltx_centering" vattach="middle">
<tbody>
<tr>
<td align="center">1</td>
Expand Down
2 changes: 1 addition & 1 deletion t/complex/figure_mixed_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<pagination role="newpage"/>
</para>
<figure float="right" xml:id="fig1">
<float class="ltx_minipage" framed="top" inlist="loa" placement="H" vattach="middle" width="433.6pt" xml:id="alg1">
<float align="center" class="ltx_minipage" framed="top" inlist="loa" placement="H" vattach="middle" width="433.6pt" xml:id="alg1">
<tags>
<tag><text font="bold">Algorithm 1</text></tag>
<tag role="refnum">1</tag>
Expand Down
Loading
Loading