예제 #1
0
        private static void ArrangeBiblio(string[] filenames, Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = new UTF8Encoding();
            }
            var sources = filenames.Select(f => File.ReadAllText(f, encoding)).ToArray();

            var(bibInd, mod) = CommonProcessor.ArrangeCites(sources);
            File.Copy(filenames[bibInd], GetBakFilename(filenames[bibInd]));
            File.WriteAllText(filenames[bibInd], mod, encoding);
        }
예제 #2
0
        private static void ConvertRbibToBib(string filename, Encoding encoding = null)
        {
            // add prefixes to formulas
            if (encoding == null)
            {
                encoding = new UTF8Encoding();
            }

            var converted = CommonProcessor.ConvertRBibitemsToBibitems(File.ReadAllText(filename, encoding));

            File.Copy(filename, GetBakFilename(filename));
            File.WriteAllText(filename, converted, encoding);
        }
예제 #3
0
        private static void MergeBib(string[] filenames, Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = new UTF8Encoding();
            }

            List <string> sources = filenames.Select(f => File.ReadAllText(f, encoding)).ToList();

            sources = CommonProcessor.MergeBibitemsAndReplaceCites(sources);
            for (int i = 0; i < sources.Count; i++)
            {
                File.Copy(filenames[i], GetBakFilename(filenames[i]));
                File.WriteAllText(filenames[i], sources[i], encoding);
            }
        }
예제 #4
0
        /// <summary>
        /// Replaces $$-blocks that have \eqno{num} by
        /// \begin{equation}\label{num} ... \end{equation}
        /// </summary>
        /// <param name="sourceFilename">File to be processed</param>
        /// <param name="destinationFilename">Result will be saved in this file</param>
        static void ProcessFile(string sourceFilename, Encoding encoding = null)
        {
            string destinationFilename = Path.Combine(
                Path.GetDirectoryName(sourceFilename),
                Path.GetFileNameWithoutExtension(sourceFilename) + "_processed" +
                Path.GetExtension(sourceFilename));

            if (encoding == null)
            {
                encoding = new UTF8Encoding();
            }
            var source = File.ReadAllText(sourceFilename, encoding);
            var text   = CommonProcessor.MakeEquationWithLabelsFromDollars(source, "eq");

            //var text = CommonProcessor.MakeDollarsFromEquationWithLabels(source);
            //var text = CommonProcessor.ArrangeCites(source);
            //var text = CommonProcessor.WrapInEnvironment(source, @"\\textbf{Замечание (\d*).*}", "%e", "замечани", "remark", n => "kad-ito:"+n);
            //var text = CommonProcessor.WrapInEnvironment(source, @"\\textbf{Определение ((\d|\.)*).*?}", "%e", "определени", "definition", n => "sirazh2:" + n);
            File.WriteAllText(destinationFilename, text, encoding);
        }