Process book records correctly
This commit is contained in:
parent
5e0c737423
commit
356dc796c8
34
Records.cs
34
Records.cs
@ -71,7 +71,7 @@ namespace Txt2Bib.Records
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"@{Type}{{{Author[0][..5]}_{Year},\n" +
|
||||
return $"@{Type}{{{Author[0][..5].Replace(". ", "_")}_{Year},\n" +
|
||||
$"\tauthor = \"{string.Join(" and ", Author)}\",\n" +
|
||||
$"\ttitle = {{{Title}}},\n" +
|
||||
$"\tjournal = \"{Journal}\",\n" +
|
||||
@ -88,7 +88,8 @@ namespace Txt2Bib.Records
|
||||
public record class BookBib : IBib
|
||||
{
|
||||
public string Type { get; init; } = "book";
|
||||
public string[] Author { get; set; } = { "Gianni e Pinotto" };
|
||||
public string[] Author { get; set; } = Array.Empty<string>();
|
||||
public string[] Editor { get; set; } = Array.Empty<string>();
|
||||
public string Title { get; set; } = "";
|
||||
public ushort Year { get; set; } = 1950;
|
||||
public string Publisher { get; set; } = "";
|
||||
@ -104,7 +105,15 @@ namespace Txt2Bib.Records
|
||||
var s = a.Split(' ');
|
||||
return $"{s[1]} {s[0]}";
|
||||
};
|
||||
Author = entryLines[1].Split(',').Select(a => rearrange(a)).ToArray();
|
||||
var auths = entryLines[1];
|
||||
if (auths.Contains("eds"))
|
||||
{
|
||||
Editor = auths.Replace("(eds.)", "").Split(',').Select(a => rearrange(a)).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
Author = auths.Split(',').Select(a => rearrange(a)).ToArray();
|
||||
}
|
||||
Year = ushort.Parse(entryLines[2]);
|
||||
Title = entryLines[3];
|
||||
Place = entryLines[4];
|
||||
@ -126,13 +135,28 @@ namespace Txt2Bib.Records
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"@{Type}{{{Author[0][..5]}_{Year},\n" +
|
||||
$"\tauthor = \"{string.Join(" and ", Author)}\",\n" +
|
||||
var label = "";
|
||||
var authString = "";
|
||||
|
||||
if (Author.Length != 0)
|
||||
{
|
||||
label = Author[0][..5].Replace(". ", "");
|
||||
authString = $"\tauthor = \"{string.Join(" and ", Author)}\",\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
label = Editor[0][..5].Replace(". ", "");
|
||||
authString = $"\teditor = \"{string.Join(" and ", Editor)}\",\n";
|
||||
}
|
||||
|
||||
return $"@{Type}{{{label}_{Year},\n" +
|
||||
authString +
|
||||
$"\ttitle = {{{Title}}},\n" +
|
||||
$"\tpublisher = \"{Publisher}\",\n" +
|
||||
$"\taddress = \"{Place}\",\n" +
|
||||
$"\tyear = \"{Year}\",\n" +
|
||||
$"\turl = \"{Url}\",\n" +
|
||||
$"\tdoi = \"{Doi}\",\n" +
|
||||
"}\n";
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,7 @@ namespace Txt2Bib
|
||||
|
||||
if (!IsValidEntry(type)) throw new Exception($"Invalid entry type '{type}'");
|
||||
|
||||
string citation = "";
|
||||
|
||||
string citation;
|
||||
try
|
||||
{
|
||||
citation = type switch
|
||||
|
Loading…
Reference in New Issue
Block a user