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

Framed fix #2161

Merged
merged 6 commits into from
Jul 24, 2023
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
4 changes: 2 additions & 2 deletions lib/LaTeXML/Core/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ sub openText {
return if $font->getFamily eq 'nullfont';
Debug("openText \"$text\" /" . Stringify($font) . " at " . Stringify($node))
if $LaTeXML::DEBUG{document};

# Get the desired font attributes, particularly the desired element
# (usually ltx:text, but let Font override, eg for \emph)
my $declared_font = getNodeFont($self, $node);
Expand Down Expand Up @@ -1272,7 +1271,8 @@ our %non_mergeable_attributes = map { $_ => 1; }
qw(about aboutlabelref aboutidref
resource resourcelabelref resourceidref
property rel rev tyupeof datatype content
data datamimetype dataencoding);
data datamimetype dataencoding
framed);

# Avoid redundant nesting of font switching elements:
# If we're closing a node that can take font switches and it contains
Expand Down
7 changes: 5 additions & 2 deletions lib/LaTeXML/Package/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -4695,7 +4695,7 @@ DefMacro('\framebox', '\@ifnextchar(\pic@framebox\@framebox', robust => 1);
DefConstructor('\@framebox[Dimension][]{}',
"?#mathframe(<ltx:XMArg enclose='box'>#inner</ltx:XMArg>)"
. "(<ltx:text ?#width(width='#width') ?#align(align='#align')"
. " framed='rectangle' framecolor='#framecolor'"
. " framed='rectangle' framecolor='#framecolor' cssstyle='#cssstyle'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am spiritually obliged to mention css_style looks better on every PR that uses the non-underscore variant :>

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

css_style??? so boring...

. " _noautoclose='1'>#3</ltx:text>)",
alias => '\framebox', sizer => '#3',
beforeDigest => sub {
Expand All @@ -4704,8 +4704,10 @@ DefConstructor('\@framebox[Dimension][]{}',
$stomach->beginMode('text');
AssignValue(FRAME_IN_MATH => $wasmath); },
properties => sub {
my $sep= LookupRegister('\fboxsep')->toAttribute;
(($_[2] ? (align => $makebox_alignment{ ToString($_[2]) }) : ()),
framecolor => LookupValue('font')->getColor,
($sep ne '3.0pt' ? (cssstyle => 'padding:' . $sep):()),
($_[1] ? (width => $_[1]) : ())); },
afterDigest => sub {
my ($stomach, $whatsit) = @_;
Expand All @@ -4724,7 +4726,8 @@ DefConstructor('\@framebox[Dimension][]{}',
my $model = $document->getModel;
# and that child can have the framed attribute
if ((scalar(@c) == 1)
&& $document->canHaveAttribute($model->getNodeQName($c[0]), 'framed')) {
&& $document->canHaveAttribute($model->getNodeQName($c[0]), 'framed')
&& !$c[0]->hasAttribute('framed')) {
# unwrap, copying the attributes
$document->unwrapNodes($node);
foreach my $k (qw(width align framed)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/LaTeXML/Package/ntheorem.sty.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Let('\renewtheorem', '\newtheorem');
DefConstructorI('\lx@addframing', undef, sub {
my ($doc, %props) = @_;
my $node = $doc->getElement;
$doc->addClass($node, 'ltx_framed');
$doc->setAttribute($node, framed => 'rectangle');
my $css = $node->getAttribute('cssstyle');
my $pad = 'padding:' . $props{margin} . 'pt;';
$doc->setAttribute($node, cssstyle => ($css ? $css . ';' . $pad : $pad)); },
Expand Down
2 changes: 1 addition & 1 deletion lib/LaTeXML/Package/titlesec.sty.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DefMacro('\lx@titleformat@star {}{}', sub {
Tokens($format, T_SPACE, T_PARAM, T_OTHER('1'))); });
our %titlesec_shape_class_map = (
runin => 'ltx_runin',
frame => 'ltx_framed',
frame => 'ltx_framed ltx_framed_rectangle',
rightmargin => 'ltx_align_right',
leftmargin => 'ltx_align_left'
);
Expand Down
3 changes: 2 additions & 1 deletion lib/LaTeXML/resources/CSS/LaTeXML.css
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ span.ltx_rowspan { position:absolute; top:0; bottom:0; }
.ltx_td,
.ltx_th { display:table-cell; }

.ltx_framed { border:1px solid black;}
.ltx_tabular .ltx_td,
.ltx_tabular .ltx_th { padding:0.1em 0.5em; }
/* regular lines */
Expand All @@ -366,6 +365,8 @@ span.ltx_rowspan { position:absolute; top:0; bottom:0; }
.ltx_border_B { border-bottom:1px solid gray; }
.ltx_border_L { border-left:1px solid gray; }
/* Framing */
.ltx_framed { padding:3pt; }
span.ltx_framed { display:inline-block; text-indent:0; } /* avoid padding/margin collapse */
.ltx_framed_rectangle { border-style:solid; border-width:1px; }
.ltx_framed_top { border-top-style:solid; border-top-width:1px; }
.ltx_framed_left { border-left-style:solid; border-left-width:1px; }
Expand Down
16 changes: 8 additions & 8 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-common.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ Backgroundable.attributes =
## In postprocessing, these values are carried to the \attr{class} attribute,
## and can thus be effected by CSS; the background will presumably
## correspond to a bounding rectangle, but is determined by the CSS rendering engine.
attribute backgroundcolor { text }?
attribute backgroundcolor { text }?,

## the kind of frame or outline for the box.
attribute framed { "rectangle" | "underline" | text }?,

## the color of the frame or outlie for the box.
attribute framecolor { text }?

## Attributes shared by low-level, generic inline and block elements
## that can be sized or shifted.
Expand Down Expand Up @@ -212,13 +218,7 @@ Positionable.attributes =
attribute vattach { "top" | "middle" | "bottom" | "baseline" }?,

## the horizontal floating placement parameter that determines where the object is displayed.
attribute float { ( "right" | "left" | text) }?,

## the kind of frame or outline for the box.
attribute framed { "rectangle" | "underline" | text }?,

## the color of the frame or outlie for the box.
attribute framecolor { text }?
attribute float { ( "right" | "left" | text) }?

## Attributes shared by (hopefully few) elements that can be transformed.
## Such elements should also have Positionable.attributes.
Expand Down
30 changes: 15 additions & 15 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-common.rng
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ and can thus be effected by CSS; the background will presumably
correspond to a bounding rectangle, but is determined by the CSS rendering engine.</a:documentation>
</attribute>
</optional>
<optional>
<attribute name="framed">
<a:documentation>the kind of frame or outline for the box.</a:documentation>
<choice>
<value>rectangle</value>
<value>underline</value>
<text/>
</choice>
</attribute>
</optional>
<optional>
<attribute name="framecolor">
<a:documentation>the color of the frame or outlie for the box.</a:documentation>
</attribute>
</optional>
</define>
<define name="Positionable.attributes">
<a:documentation>Attributes shared by low-level, generic inline and block elements
Expand Down Expand Up @@ -308,21 +323,6 @@ The default is baseline. </a:documentation>
</choice>
</attribute>
</optional>
<optional>
<attribute name="framed">
<a:documentation>the kind of frame or outline for the box.</a:documentation>
<choice>
<value>rectangle</value>
<value>underline</value>
<text/>
</choice>
</attribute>
</optional>
<optional>
<attribute name="framecolor">
<a:documentation>the color of the frame or outlie for the box.</a:documentation>
</attribute>
</optional>
</define>
<define name="Transformable.attributes">
<a:documentation>Attributes shared by (hopefully few) elements that can be transformed.
Expand Down
3 changes: 2 additions & 1 deletion lib/LaTeXML/resources/RelaxNG/LaTeXML-inline.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ element rule { rule_attributes, rule_model }
rule_attributes =
Common.attributes,
Positionable.attributes,
Colorable.attributes
Colorable.attributes,
Backgroundable.attributes

## Content model for \elementref{rule}.
rule_model = empty
Expand Down
1 change: 1 addition & 0 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-inline.rng
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ mixed with arbitrary characters.</a:documentation>
<ref name="Common.attributes"/>
<ref name="Positionable.attributes"/>
<ref name="Colorable.attributes"/>
<ref name="Backgroundable.attributes"/>
</define>
<define name="rule_model">
<a:documentation>Content model for \elementref{rule}.</a:documentation>
Expand Down
Loading
Loading