Exemple #1
0
        public MathTeXCommand Clone()
        {
            MathTeXCommand package = new MathTeXCommand(this);

            if (_name != null)
            {
                package._name = String.Copy(_name);
            }
            if (_command != null)
            {
                package._command = String.Copy(_command);
            }
            if (_arguments != null)
            {
                package._arguments = String.Copy(_arguments);
            }

            return(package);
        }
        public override void Update(XPathNavigator configuration)
        {
            base.Update(configuration);

            IList <MathTeXPackage> listPackages = this.Packages;

            if (listPackages != null && listPackages.Count > 0)
            {
                int itemCount = listPackages.Count;

                for (int i = 0; i < itemCount; i++)
                {
                    MathTeXPackage package = listPackages[i];

                    package.ToString(_displayedBuilder);
                }
            }

            IList <MathTeXCommand> listCommands = this.Commands;

            if (listCommands != null && listCommands.Count > 0)
            {
                int itemCount = listCommands.Count;

                for (int i = 0; i < itemCount; i++)
                {
                    MathTeXCommand command = listCommands[i];

                    command.ToString(_displayedBuilder);
                }
            }

            _inlineBuilder.AppendLine("\\begin{document}");
            _inlineBuilder.AppendLine("\\pagestyle{empty}");

            _displayedBuilder.AppendLine("\\begin{document}");
            _displayedBuilder.AppendLine("\\pagestyle{empty}");
        }
        public virtual void Update(XPathNavigator configuration)
        {
            if (configuration == null)
            {
                return;
            }

            //<packages>
            //  <package use="amstext" />
            //  <package use="amsbsy, amscd" />
            //  <package use="noamsfonts" option="psamsfonts" />
            //</packages>
            XPathNodeIterator iterator = configuration.Select("packages/package");

            if (iterator != null && iterator.Count > 0)
            {
                _listPackages = new List <MathTeXPackage>(iterator.Count);

                foreach (XPathNavigator navigator in iterator)
                {
                    string attribute = navigator.GetAttribute("use",
                                                              String.Empty);
                    if (String.IsNullOrEmpty(attribute) == false)
                    {
                        MathTeXPackage package = new MathTeXPackage(attribute,
                                                                    navigator.GetAttribute("options", String.Empty));

                        if (package.IsValid)
                        {
                            _listPackages.Add(package);
                        }
                    }
                }

                this.WriteMessage(MessageLevel.Info,
                                  String.Format("Loaded {0} LaTeX packages", _listPackages.Count));
            }

            //<commands>
            //    <!-- For testing an example
            //    <command name="" value="" />-->
            //    <command name="\quot" value="" arguments="2" />
            //    <command name="\exn" value="" arguments="1" />
            //</commands>
            iterator = configuration.Select("commands/command");
            if (iterator != null && iterator.Count > 0)
            {
                _listCommands = new List <MathTeXCommand>(iterator.Count);

                foreach (XPathNavigator navigator in iterator)
                {
                    string attribute = navigator.GetAttribute("name",
                                                              String.Empty);
                    if (String.IsNullOrEmpty(attribute) == false)
                    {
                        MathTeXCommand command = new MathTeXCommand(attribute,
                                                                    navigator.GetAttribute("value", String.Empty),
                                                                    navigator.GetAttribute("arguments", String.Empty));

                        if (command.IsValid)
                        {
                            _listCommands.Add(command);
                        }
                    }
                }

                this.WriteMessage(MessageLevel.Info,
                                  String.Format("Loaded {0} LaTeX commands", _listCommands.Count));
            }
        }
Exemple #4
0
 public MathTeXCommand(MathTeXCommand source)
 {
     _name      = source._name;
     _command   = source._command;
     _arguments = source._arguments;
 }