void SetOperatorStyle(XElement opElement) { string name = opElement.Attribute("operator").Value; OperatorStyle os = new OperatorStyle(name); opElement.Attributes().Where(x=>x.Name != "operator").ToList().ForEach(x=> os.AddStyle(x.Name.LocalName, x.Value)); OperatorStyles.Add(os); }
private void SetOperatorStyle(XElement opElement) { string name = opElement.Attribute("operator").Value; OperatorStyle os = new OperatorStyle(name); opElement.Attributes().Where(x => x.Name != "operator").ToList().ForEach(x => os.AddStyle(x.Name.LocalName, x.Value)); OperatorStyles.Add(os); }
public static void CMo(MathNode node) { // Apply special formatting to operators OperatorStyle extraStyle = node.Config.OperatorStyles.FirstOrDefault(x => x.OpName == node.Text);//.Styling; if (extraStyle != null) { node.Attributes.AddRange(extraStyle.Styling); //ToDo: verify } // Consult the operator dictionary, and set the appropriate defaults string form = "infix"; if (node.Parent == null) { // pass } else if (new List <string>() { "mrow", "mstyle", "msqrt", "merror", "mpadded", "mphantom", "menclose", "mtd", "math" }.Any(x => x == node.Parent.ElementName)) { //ToDo: verify List <MathNode> prevSiblings = node.Parent.Children.TakeWhile((value, i) => i != node.NodeIndex).Where(IsNonSpaceNode).ToList(); List <MathNode> nextSiblings = node.Parent.Children.Skip(node.NodeIndex + 1).Where(IsNonSpaceNode).ToList(); if (prevSiblings.Count == 0 && nextSiblings.Count > 0) { form = "prefix"; } if (nextSiblings.Count == 0 && prevSiblings.Count > 0) { form = "postfix"; } } if (node.Attributes.ContainsKey("form")) { form = node.Attributes["form"]; } node.OpDefaults = node.Config.MathOperators.LookUp(node.Text, form); DefaultContext(node); string stretchyattr = node.GetProperty("stretchy", node.OpDefaults.Dict()["stretchy"]); node.Stretchy = (stretchyattr == "true"); string symmetricattr = node.GetProperty("symmetric", node.OpDefaults.Dict()["symmetric"]); node.Symmetric = (symmetricattr == "true"); node.Scaling = node.OpDefaults.Dict()["scaling"]; if (!node.TightSpaces) { string lspaceattr = node.GetProperty("lspace", node.OpDefaults.Dict()["lspace"]); node.LeftSpace = node.ParseSpace(lspaceattr); string rspaceattr = node.GetProperty("rspace", node.OpDefaults.Dict()["rspace"]); node.RightSpace = node.ParseSpace(rspaceattr); } if (node.DisplayStyle) { string value = node.OpDefaults.Dict()["largeop"]; if (node.GetProperty("largeop", value) == "true") { node.FontSize *= 1.41; } } else { string value = node.OpDefaults.Dict()["movablelimits"]; node.MoveLimits = (node.GetProperty("movablelimits", value) == "true"); } }