Пример #1
0
        void MFenced()
        {
            //Add fences and separators, and process as a mrow
            List<MathNode> old_children = new List<MathNode>(m_node.Children);
            m_node.Children.Clear();

            string openingFence = m_node.GetProperty("open");
            openingFence = string.Join(" ", openingFence.Split(null));
            if (openingFence.Length > 0)
            {
                MathNode opening = new MathNode("mo", new Dictionary<string, string>() { { "fence", "true" }, { "form", "prefix" } }, m_node.Config, m_node);
                opening.Text = openingFence;
                opening.Measure();
            }

            string separators = String.Join("", m_node.GetProperty("separators").Split(null));
            int sepindex = 0;
            int lastsep = separators.Length - 1;

            foreach (MathNode ch in old_children)
            {
                if (m_node.Children.Count > 1 && lastsep >= 0)
                {
                    MathNode sep = new MathNode("mo", new Dictionary<string, string>() { { "separator", "true" }, { "form", "infix" } }, m_node.Config, m_node);
                    sep.Text = separators[sepindex].ToString();
                    sep.Measure();
                    sepindex = Math.Min(sepindex + 1, lastsep);
                }
                m_node.Children.Add(ch);
            }

            string closingFence = m_node.GetProperty("close");
            closingFence = String.Join(" ", closingFence.Split(null));
            if (closingFence.Length > 0)
            {
                MathNode closing = new MathNode("mo", new Dictionary<string, string>() { { "fence", "true" }, { "form", "postfix" } }, m_node.Config, m_node);
                closing.Text = closingFence;
                closing.Measure();
            }

            MRow();
        }