Skip to content

Commit 866a089

Browse files
committed
allow intent and arg attributes in schema and Pres. MathML output
1 parent 62c537b commit 866a089

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

lib/LaTeXML/Post/MathML.pm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ sub outerWrapper {
8989
qw(about resource property rel rev typeof datatype content);
9090
my $wrapped = ['m:math', { display => ($mode eq 'display' ? 'block' : 'inline'),
9191
class => $math->getAttribute('class'),
92+
intent => $math->getAttribute('intent'),
9293
alttext => $math->getAttribute('tex'),
9394
#### Handy for debugging math
9495
### title => $math->getAttribute('text'),
@@ -353,6 +354,10 @@ sub pmml {
353354
# Associate the generated node with the source XMath node.
354355
if (my $role = _getattr($refr, $node, 'role')) {
355356
$$result[1]{_role} = $role; }
357+
if (my $intent = _getattr($refr, $node, 'intent')) {
358+
$$result[1]{intent} = $intent; }
359+
if (my $arg = _getattr($refr, $node, 'arg')) {
360+
$$result[1]{arg} = $arg; }
356361
$LaTeXML::Post::MATHPROCESSOR->associateNode($result, $node);
357362
return $result; }
358363

@@ -536,12 +541,12 @@ sub pmml_maybe_resize {
536541
my $xoff = $node->getAttribute('xoffset') || ($parent && $parent->getAttribute('xoffset'));
537542
my $yoff = $node->getAttribute('yoffset') || ($parent && $parent->getAttribute('yoffset'));
538543
my $role = $node->getAttribute('role') || ($parent && $parent->getAttribute('role'));
539-
my $class = $node->getAttribute('class') || ($parent && $parent->getAttribute('class'));
544+
my $class = $node->getAttribute('class') || ($parent && $parent->getAttribute('class'));
540545

541546
# First, special case hack for stretchy arrows, with specified width
542547
# Stretchiness (currently) only has effect within munder/mover!!!!!
543548
if ($width && (($role || '') eq 'ARROW')
544-
&& (($class||'') =~ /\bltx_horizontally_stretchy\b/)) { # SPECIAL CASE HACK
549+
&& (($class || '') =~ /\bltx_horizontally_stretchy\b/)) { # SPECIAL CASE HACK
545550
$result = ['m:mover', {}, $result, ['m:mspace', { width => $width }]]; }
546551
elsif ($width || $height || $depth || $xoff || $yoff) {
547552
if ($$result[0] eq 'm:mpadded') { }
@@ -1196,11 +1201,11 @@ our $atomtype_form = {
11961201
# (use negative for spacing only in display & text style; use 0 for * which means "shouldn't happen")
11971202
# THUS, we'll need to know which style!!!
11981203
our $atompair_spacing = {
1199-
Ord => { Ord => 0, Op => 1, Bin => -2, Rel => -3, Open => 0, Close => 0, Punct => 0, Inner => -1 },
1200-
Op => { Ord => 1, Op => 1, Bin => 0, Rel => -3, Open => 0, Close => 0, Punct => 0, Inner => -1 },
1204+
Ord => { Ord => 0, Op => 1, Bin => -2, Rel => -3, Open => 0, Close => 0, Punct => 0, Inner => -1 },
1205+
Op => { Ord => 1, Op => 1, Bin => 0, Rel => -3, Open => 0, Close => 0, Punct => 0, Inner => -1 },
12011206
Bin => { Ord => -2, Op => -2, Bin => 0, Rel => 0, Open => -2, Close => 0, Punct => 0, Inner => -2 },
12021207
Rel => { Ord => -3, Op => -3, Bin => 0, Rel => 0, Open => -3, Close => 0, Punct => 0, Inner => -3 },
1203-
Open => { Ord => 0, Op => 0, Bin => 0, Rel => 0, Open => 0, Close => 0, Punct => 0, Inner => 0 },
1208+
Open => { Ord => 0, Op => 0, Bin => 0, Rel => 0, Open => 0, Close => 0, Punct => 0, Inner => 0 },
12041209
Close => { Ord => 0, Op => 1, Bin => -2, Rel => -3, Open => 0, Close => 0, Punct => 0, Inner => -1 },
12051210
Punct => { Ord => -1, Op => -1, Bin => 0, Rel => -1, Open => -1, Close => -1, Punct => -1, Inner => -1 },
12061211
Inner => { Ord => -1, Op => 1, Bin => -2, Rel => -3, Open => -1, Close => 0, Punct => -1, Inner => -1 },

lib/LaTeXML/resources/RelaxNG/LaTeXML-math.rnc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Math_attributes =
5454
## a textified representation of the math.
5555
attribute text { text }?,
5656

57+
## intent attribute from MathML 4
58+
attribute intent { text }?,
59+
5760
## preserved grammar-near lexemes for export to external apps
5861
attribute lexemes { text }?
5962

@@ -88,6 +91,12 @@ XMath.attributes =
8891
## The OpenMath CD for which \attr{meaning} is a symbol.
8992
attribute omcd { text }?,
9093

94+
## intent attribute from MathML 4
95+
attribute intent { text }?,
96+
97+
## arg attribute from MathML 4
98+
attribute arg { text }?,
99+
91100
## An encoding of the position of sub/superscripts
92101
## Before parsing, it takes two forms. On a base token or element,
93102
## it is one of (pre|mid|post), indicating where any script can be placed.

lib/LaTeXML/resources/RelaxNG/LaTeXML-math.rng

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ the content of the \elementref{XMath} element.</a:documentation>
8080
<a:documentation>a textified representation of the math.</a:documentation>
8181
</attribute>
8282
</optional>
83+
<optional>
84+
<attribute name="intent">
85+
<a:documentation>intent attribute from MathML 4</a:documentation>
86+
</attribute>
87+
</optional>
8388
<optional>
8489
<attribute name="lexemes">
8590
<a:documentation>preserved grammar-near lexemes for export to external apps</a:documentation>
@@ -133,6 +138,16 @@ such as the OpenMath name.</a:documentation>
133138
<a:documentation>The OpenMath CD for which \attr{meaning} is a symbol.</a:documentation>
134139
</attribute>
135140
</optional>
141+
<optional>
142+
<attribute name="intent">
143+
<a:documentation>intent attribute from MathML 4</a:documentation>
144+
</attribute>
145+
</optional>
146+
<optional>
147+
<attribute name="arg">
148+
<a:documentation>arg attribute from MathML 4</a:documentation>
149+
</attribute>
150+
</optional>
136151
<optional>
137152
<attribute name="scriptpos">
138153
<a:documentation>An encoding of the position of sub/superscripts

lib/LaTeXML/resources/RelaxNG/LaTeXML.model

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,21 @@ subsubsection.body:=(ltx:TOC,ltx:declare,ltx:figure,ltx:float,ltx:glossarydefini
9090
*{!svg:*,*,*:*}(!svg:*,#PCDATA,*,*:*)
9191
*:*{}(*:*)
9292
ltx:ERROR{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,fragid,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:id,xml:lang}(#PCDATA)
93-
ltx:Math{!xml:*,*:*,about,aboutidref,aboutlabelref,backgroundcolor,class,content,content-tex,cssstyle,datatype,description,fragid,framecolor,framed,imagedepth,imageheight,imagesrc,imagewidth,lexemes,mode,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,tex,text,typeof,vocab,xml:id,xml:lang}(ltx:XMath)
93+
ltx:Math{!xml:*,*:*,about,aboutidref,aboutlabelref,backgroundcolor,class,content,content-tex,cssstyle,datatype,description,fragid,framecolor,framed,imagedepth,imageheight,imagesrc,imagewidth,intent,lexemes,mode,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,tex,text,typeof,vocab,xml:id,xml:lang}(ltx:XMath)
9494
ltx:MathBranch{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,format,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:lang}(ltx:Math,ltx:td,ltx:tr)
9595
ltx:MathFork{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:lang}(ltx:Math,ltx:MathBranch,ltx:text)
9696
ltx:TOC{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,format,lists,name,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,scope,select,show,typeof,vocab,xml:lang}(ltx:title,ltx:toclist)
97-
ltx:XMApp{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,class,color,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,lpadding,meaning,name,omcd,opacity,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
98-
ltx:XMArg{!xml:*,*:*,about,aboutidref,aboutlabelref,align,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,rule,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
99-
ltx:XMArray{!xml:*,*:*,about,aboutidref,aboutlabelref,align,class,colsep,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rowsep,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:XMRow)
97+
ltx:XMApp{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,backgroundcolor,class,color,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,intent,lpadding,meaning,name,omcd,opacity,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
98+
ltx:XMArg{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,rule,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
99+
ltx:XMArray{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,class,colsep,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rowsep,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:XMRow)
100100
ltx:XMCell{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,border,class,colspan,content,cssstyle,datatype,fragid,framecolor,framed,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,rowspan,thead,typeof,vocab,width,xml:id,xml:lang}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
101-
ltx:XMDual{!xml:*,*:*,about,aboutidref,aboutlabelref,align,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
102-
ltx:XMHint{!xml:*,*:*,about,aboutidref,aboutlabelref,align,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}()
103-
ltx:XMRef{!xml:*,*:*,about,aboutidref,aboutlabelref,align,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,idref,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}()
101+
ltx:XMDual{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
102+
ltx:XMHint{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}()
103+
ltx:XMRef{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,height,href,idref,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}()
104104
ltx:XMRow{!xml:*,*:*,about,aboutidref,aboutlabelref,backgroundcolor,class,content,cssstyle,datatype,fragid,framecolor,framed,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:id,xml:lang}(ltx:XMCell)
105-
ltx:XMText{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(#PCDATA,ltx:ERROR,ltx:Math,ltx:anchor,ltx:bibref,ltx:break,ltx:cite,ltx:del,ltx:emph,ltx:glossaryref,ltx:graphics,ltx:inline-block,ltx:inline-description,ltx:inline-enumerate,ltx:inline-itemize,ltx:inline-logical-block,ltx:inline-sectional-block,ltx:picture,ltx:rawhtml,ltx:rawliteral,ltx:ref,ltx:rule,ltx:sub,ltx:sup,ltx:tabular,ltx:text,ltx:verbatim,svg:svg)
106-
ltx:XMTok{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,class,color,content,cssstyle,datatype,decl_id,depth,enclose,float,font,fontsize,fragid,framecolor,framed,height,href,lpadding,mathstyle,meaning,name,omcd,opacity,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,stretchy,thickness,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(#PCDATA)
107-
ltx:XMWrap{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,rule,scriptpos,style,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
105+
ltx:XMText{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,backgroundcolor,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(#PCDATA,ltx:ERROR,ltx:Math,ltx:anchor,ltx:bibref,ltx:break,ltx:cite,ltx:del,ltx:emph,ltx:glossaryref,ltx:graphics,ltx:inline-block,ltx:inline-description,ltx:inline-enumerate,ltx:inline-itemize,ltx:inline-logical-block,ltx:inline-sectional-block,ltx:picture,ltx:rawhtml,ltx:rawliteral,ltx:ref,ltx:rule,ltx:sub,ltx:sup,ltx:tabular,ltx:text,ltx:verbatim,svg:svg)
106+
ltx:XMTok{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,backgroundcolor,class,color,content,cssstyle,datatype,decl_id,depth,enclose,float,font,fontsize,fragid,framecolor,framed,height,href,intent,lpadding,mathstyle,meaning,name,omcd,opacity,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,scriptpos,stretchy,thickness,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(#PCDATA)
107+
ltx:XMWrap{!xml:*,*:*,about,aboutidref,aboutlabelref,align,arg,backgroundcolor,class,content,cssstyle,datatype,decl_id,depth,enclose,float,fragid,framecolor,framed,height,href,intent,lpadding,meaning,name,omcd,possibleFunction,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,role,rpadding,rule,scriptpos,style,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
108108
ltx:XMath{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,fragid,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:id,xml:lang}(ltx:ERROR,ltx:XMApp,ltx:XMArg,ltx:XMArray,ltx:XMDual,ltx:XMHint,ltx:XMRef,ltx:XMText,ltx:XMTok,ltx:XMWrap)
109109
ltx:_CaptureBlock_{!xml:*,*:*,about,aboutidref,aboutlabelref,align,backgroundcolor,class,content,cssstyle,datatype,depth,float,fragid,framecolor,framed,height,inlist,labels,prefix,property,rdf-prefixes,rel,resource,resourceidref,resourcelabelref,rev,typeof,vattach,vocab,width,xml:id,xml:lang,xoffset,yoffset}(ltx:ERROR,ltx:TOC,ltx:block,ltx:break,ltx:caption,ltx:chapter,ltx:declare,ltx:description,ltx:enumerate,ltx:equation,ltx:equationgroup,ltx:figure,ltx:float,ltx:glossarydefinition,ltx:graphics,ltx:indexmark,ltx:inline-block,ltx:inline-description,ltx:inline-enumerate,ltx:inline-itemize,ltx:inline-logical-block,ltx:inline-sectional-block,ltx:itemize,ltx:listing,ltx:logical-block,ltx:navigation,ltx:note,ltx:p,ltx:pagination,ltx:para,ltx:paragraph,ltx:part,ltx:picture,ltx:proof,ltx:quote,ltx:rawhtml,ltx:rawliteral,ltx:rdf,ltx:resource,ltx:rule,ltx:section,ltx:sectional-block,ltx:sidebar,ltx:slide,ltx:slidesequence,ltx:subsection,ltx:subsubsection,ltx:table,ltx:tabular,ltx:theorem,ltx:toccaption,ltx:verbatim,svg:foreignObject,svg:g,svg:svg)
110110
ltx:abstract{!xml:*,*:*,about,aboutidref,aboutlabelref,class,content,cssstyle,datatype,name,prefix,property,rel,resource,resourceidref,resourcelabelref,rev,typeof,vocab,xml:lang}(ltx:ERROR,ltx:block,ltx:break,ltx:declare,ltx:description,ltx:enumerate,ltx:equation,ltx:equationgroup,ltx:glossarydefinition,ltx:graphics,ltx:indexmark,ltx:inline-block,ltx:inline-description,ltx:inline-enumerate,ltx:inline-itemize,ltx:inline-logical-block,ltx:inline-sectional-block,ltx:itemize,ltx:listing,ltx:navigation,ltx:note,ltx:p,ltx:pagination,ltx:picture,ltx:quote,ltx:rawhtml,ltx:rawliteral,ltx:rdf,ltx:resource,ltx:rule,ltx:tabular,ltx:verbatim,svg:svg)

0 commit comments

Comments
 (0)