public static BibTexDatabase LoadBibTexDatabase(string filename)
		{
			LastTemplateParseException = null;

			try
			{
				var text = LoadFile(filename);

                BibTexParser parser = new BibTexParser(new BibTexLexer(text));

				var result = parser.Parse();

				var fileInfo = new FileInfo(filename);

				result.Filename = fileInfo.FullName;
				result.Timestamp = fileInfo.LastWriteTime;

				return result;
			}
			catch(Exception ex)
			{
				LastTemplateParseException = ex as TemplateParseException;

				Helper.LogUnexpectedException("Failed loading Bibtex database from '" + filename + "'", ex);

				return null;
			}
		}
Exemple #2
0
		public void LoadSpecialCharactersDatabase()
		{
			var data = File.ReadAllText(@"Sample Files\b4w.bib", Encoding.GetEncoding(1252));
			var parser = new BibTexParser(new BibTexLexer(data));

			specialCharactersDatabase = parser.Parse();
		}
Exemple #3
0
		public void Mendeley1Parser()
		{
			var data = File.ReadAllText(@"Sample Files\Mendeley 1.bib");

			var parser = new BibTexParser(new BibTexLexer(data));

			var db = parser.Parse();
			Console.WriteLine("{0} abbreviations; {1} entries", db.AbbreviationCount, db.EntryCount);

			Assert.AreEqual(0, db.AbbreviationCount);
			Assert.AreEqual(1227, db.EntryCount);
			Assert.AreEqual(14633, parser.Current.Line);
			Assert.AreEqual(1, parser.Current.Column);
			Assert.AreEqual(740249, parser.Current.Position);
		}
Exemple #4
0
		public void DocearParser()
		{
			var data = File.ReadAllText(@"Sample Files\Docear.bib");

			var parser = new BibTexParser(new BibTexLexer(data));

			var db = parser.Parse();
			Console.WriteLine("{0} abbreviations; {1} entries", db.AbbreviationCount, db.EntryCount);

			Assert.AreEqual(8, db.AbbreviationCount);
			Assert.AreEqual(1064, db.EntryCount);
			Assert.AreEqual(17638, parser.Current.Line);
			Assert.AreEqual(1, parser.Current.Column);
			Assert.AreEqual(682497, parser.Current.Position);
		}
Exemple #5
0
		public void BigFileParser()
		{
			var data = File.ReadAllText(@"Sample Files\BigFile.bib");

			var parser = new BibTexParser(new BibTexLexer(data));

			var db = parser.Parse();
			Console.WriteLine("{0} abbreviations; {1} entries", db.AbbreviationCount, db.EntryCount);

			Assert.AreEqual(232, db.AbbreviationCount);
			Assert.AreEqual(1457, db.EntryCount);
			Assert.AreEqual(11264, parser.Current.Line);
			Assert.AreEqual(1, parser.Current.Column);
			Assert.AreEqual(359616, parser.Current.Position);
		}
Exemple #6
0
		public void SimpleParser()
		{
			const string Data = @"

@article{mrx05, 
auTHor = ""Mr. X"", 
Title = {Something Great}, 
publisher = ""nob"" # ""ody"", 
YEAR = 2005, 
} ";

			var lexer = new BibTexLexer(Data);
			var parser = new BibTexParser(lexer);

			var db = parser.Parse();
			Console.WriteLine("{0} abbreviations; {1} entries", db.AbbreviationCount, db.EntryCount);
		}
		public static BibTexDatabase CreateBibTexDatabase(string text)
		{
			var parser = new BibTexParser(new BibTexLexer(text));

			return parser.Parse();
		}
Exemple #8
0
		[Test]  // From http://theoval.cmp.uea.ac.uk/~nlct/latex/novices/symbols.html
		public void SymbolTests()
		{
			var text = @"@MISC{LatexSymbols,title = {\textbackslash \_ - -- \textendash --- \textemdash \P \textasciicircum \$ \S \textasciitilde \{ \ldots \pounds \} ?` \textquestiondown \textregistered \# !` \textexclamdown \texttrademark \% ' \textquoteright '' \textquotedblright \copyright \& ` \textquoteleft `` \textquotedblleft \yen \i \j \textbar \textperiodcentered \textless \textgreater \slash}";
			var title = new BibTexParser(new BibTexLexer(text)).Parse()["LatexSymbols"]["title"];

			Assert.AreEqual("\\ _ - – – — — ¶ ^ $ § ~ { … £ } ¿ ¿ ® # ¡ ¡ \x2122 % ’ ’ ” ” © & ‘ ‘ “ “ ¥ \uD835\uDEA4 \uD835\uDEA5 | · < > /", title.Display);
		}
Exemple #9
0
		public void TempParser()
		{
			var data = File.ReadAllText(@"Sample Files\Temp.bib");

			var parser = new BibTexParser(new BibTexLexer(data));

			var db = parser.Parse();
			Console.WriteLine("{0} abbreviations; {1} entries", db.AbbreviationCount, db.EntryCount);
		}