Pages: 1
Author Topic: CSS set specific style to second child element  (Read 302 times)

Posts: 2

« on: December 21, 2017, 09:38:27 AM »


is it possible to set a specific style to the second child element?
In this sample i want the second child element of msub should be shown with vertical-align sub in xMax.


This don't work:

msub > *[2] {
  display: inline;
  vertical-align: sub;
  font-size: 0.8em;

Derek Read
Program Manager (XMetaL)

Posts: 2524

« Reply #1 on: December 21, 2017, 02:35:55 PM »

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 <mi> elements that have a <mi> before them.

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

//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<nodes.length; 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):
« Last Edit: December 21, 2017, 02:38:19 PM by Derek Read » Logged
Pages: 1
Jump to: