Home Forums General XMetaL Discussion CSS set specific style to second child element Reply To: CSS set specific style to second child element

Derek Read

Reply to: CSS set specific style to second child element

This type of selector isn't supported. The following would do it but only for this specific case:

msub > mi mi {
 vertical-align: sub

That's going to affect all elements that have a before them.

If you are going to have content where there are more than two elements you would have to write a script to affect just one and not the others. Something similar to the following would do that:

[code]//XMetaL Script Language JScript:
//create a Range we can move around to alter style(s) for specific elements
var rng = ActiveDocument.Range;
//get all nodes that are the second mi sibling inside msub:
var nodes = ActiveDocument.getNodesByXPath(“//msub/mi[2]”);
//loop through the list of nodes, move the Range to each, and set the style(s):
for(i=0; i rng.SelectNodeContents(nodes.item(i));
rng.ContainerStyle = “display:inline; vertical-align:sub; font-size:0.8em”;

Note to anyone that wants to use this approach for DITA: Please don't try. Modifying the DITA customization's scripts is not supported.

Regarding MathML:
If you are trying to style MathML to make it easier to edit in XMetaL Author I think that's going to be a lot of work unless you use a very small specific subset and perhaps only use some specific equation layouts. If you use MathML on a regular basis I would highly recommend Design Science's “MathFlow Editor” for XMetaL Author (it works with XMAX as well): https://www.dessci.com/en/products/mathflow/mf_for_xmetal.htm