Skip to content

Commit

Permalink
Move rule (brucemiller#2440)
Browse files Browse the repository at this point in the history
* Update schema to move ltx:rule from only being Inline, but also Block and Para level (avoids spurious ltx:p,ltx:para)

* Update testcases for more permissive ltx:rule schema

* Define \vspace to use \vskip, rather than no-op

* Make \hrule close ltx:p, if it's a full-width rule

* Fix stupid typo

* Update changes file for more extreme changes
  • Loading branch information
brucemiller authored Nov 24, 2024
1 parent 9ec6a41 commit a40cf40
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 141 deletions.
8 changes: 5 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
- This release addresses a large variety of usability, fidelity, robustness,
portability and output-quality issues.
-
Incompatible changes: The API of several low-level internal functions have changed.
In the unlikely event you have used these in your own bindings, they will need to be
updated.
Incompatible changes:
* The API of several low-level internal functions have changed. In the unlikely
event you have used these in your own bindings, they will need to be updated.
* ltx:rule is now allowed in Block and Para contexts, as well as the previous Inline.
Other changes:
- LaTeXML::Core::CharDef->new($cs,$mode,$value)
- decodeMathCode($mathcode,$reversion) returns ($glyph,$font,$reversion,%mathproperties)
0.8.8 2024-02-29
Expand Down
6 changes: 3 additions & 3 deletions lib/LaTeXML/Engine/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -4809,9 +4809,9 @@ DefPrimitive('\hspace OptionalMatch:* {Dimension}', sub {
Box($s, undef, undef, Invocation(T_CS('\hskip'), $length),
width => $length, isSpace => 1); });

DefPrimitive('\vspace OptionalMatch:* {}', undef);
DefPrimitive('\addvspace {}', undef);
DefPrimitive('\addpenalty {}', undef);
DefMacro('\vspace OptionalMatch:* {}', '\vskip #2\relax');
DefPrimitive('\addvspace {}', undef);
DefPrimitive('\addpenalty {}', undef);
DefPrimitiveI('\@endparenv');

# \hfill, \vfill
Expand Down
4 changes: 4 additions & 0 deletions lib/LaTeXML/Engine/TeX_Box.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ DefConstructor('\hrule RuleSpecification',
. "(<ltx:rule height='#rheight' depth='#rdepth' width='#rwidth' color='#color'/>))",
afterConstruct => sub { # NOTE: Only For xy development!
Warn('unexpected', 'hrule', $_[0], "Encountered \\hrule in SVG") if inSVG(); },
beforeConstruct => sub {
my ($document, $whatsit) = @_;
my $w = $whatsit->getProperty('rwidth');
$_[0]->maybeCloseElement('ltx:p') if $w && ($w eq '100%'); },
afterDigest => sub {
my ($stomach, $whatsit) = @_;
my $dims = $whatsit->getArg(1);
Expand Down
18 changes: 1 addition & 17 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-inline.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default namespace = "http://dlmf.nist.gov/LaTeXML"

## The inline module defines basic inline elements used throughout.
Inline.class |=
\text | emph | del | sub | sup | glossaryref | rule
\text | emph | del | sub | sup | glossaryref
| anchor | ref | cite | bibref

#======================================================================
Expand Down Expand Up @@ -133,22 +133,6 @@ glossaryref_model = Inline.model

#======================================================================

rule =
## A Rule.
element rule { rule_attributes, rule_model }

## Attributes for \elementref{rule}.
rule_attributes =
Common.attributes,
Positionable.attributes,
Colorable.attributes,
Backgroundable.attributes

## Content model for \elementref{rule}.
rule_model = empty

#======================================================================

ref =
## A hyperlink reference to some other object.
## When converted to HTML, the content would be the content of the anchor.
Expand Down
20 changes: 0 additions & 20 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-inline.rng
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<ref name="sub"/>
<ref name="sup"/>
<ref name="glossaryref"/>
<ref name="rule"/>
<ref name="anchor"/>
<ref name="ref"/>
<ref name="cite"/>
Expand Down Expand Up @@ -168,25 +167,6 @@ mixed with arbitrary characters.</a:documentation>
<ref name="Inline.model"/>
</define>
<!-- ====================================================================== -->
<define name="rule">
<element name="rule">
<a:documentation>A Rule.</a:documentation>
<ref name="rule_attributes"/>
<ref name="rule_model"/>
</element>
</define>
<define name="rule_attributes">
<a:documentation>Attributes for \elementref{rule}.</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>
<empty/>
</define>
<!-- ====================================================================== -->
<define name="ref">
<element name="ref">
<a:documentation>A hyperlink reference to some other object.
Expand Down
20 changes: 18 additions & 2 deletions lib/LaTeXML/resources/RelaxNG/LaTeXML-para.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@ default namespace = "http://dlmf.nist.gov/LaTeXML"
Para.class |=
para | logical-block
| theorem | proof
| figure | table | float | pagination
| figure | table | float | pagination | rule
# allow pagination here, to avoid unnecessary extra para!

## Additionally, it defines these miscellaneous elements that can appear
## in both inline and block contexts.
Misc.class |= inline-logical-block
Misc.class |= inline-logical-block | rule

#======================================================================

rule =
## A Rule.
element rule { rule_attributes, rule_model }

## Attributes for \elementref{rule}.
rule_attributes =
Common.attributes,
Positionable.attributes,
Colorable.attributes,
Backgroundable.attributes

## Content model for \elementref{rule}.
rule_model = empty

#======================================================================

Expand Down
25 changes: 24 additions & 1 deletion lib/LaTeXML/resources/RelaxNG/LaTeXML-para.rng
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,36 @@
<ref name="table"/>
<ref name="float"/>
<ref name="pagination"/>
<ref name="rule"/>
</choice>
</define>
<!-- allow pagination here, to avoid unnecessary extra para! -->
<define name="Misc.class" combine="choice">
<a:documentation>Additionally, it defines these miscellaneous elements that can appear
in both inline and block contexts.</a:documentation>
<ref name="inline-logical-block"/>
<choice>
<ref name="inline-logical-block"/>
<ref name="rule"/>
</choice>
</define>
<!-- ====================================================================== -->
<define name="rule">
<element name="rule">
<a:documentation>A Rule.</a:documentation>
<ref name="rule_attributes"/>
<ref name="rule_model"/>
</element>
</define>
<define name="rule_attributes">
<a:documentation>Attributes for \elementref{rule}.</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>
<empty/>
</define>
<!-- ====================================================================== -->
<define name="para">
Expand Down
Loading

0 comments on commit a40cf40

Please sign in to comment.