Include "series" field; better editor management
This commit is contained in:
parent
43942125c9
commit
ceceb69b3f
49
Records.cs
49
Records.cs
@ -153,10 +153,12 @@ namespace Txt2Bib.Records
|
||||
{
|
||||
public string Type { get; init; } = "inproceedings";
|
||||
public string[] Author { get; set; } = Array.Empty<string>();
|
||||
public string[] Editor { get; set; } = Array.Empty<string>();
|
||||
public string Title { get; set; } = "";
|
||||
public string BookTitle { get; set; } = "";
|
||||
public ushort Year { get; set; } = 1950;
|
||||
public string Publisher { get; set; } = "";
|
||||
public string Series { get; set; } = "";
|
||||
public string Address { get; set; } = "";
|
||||
public ushort FirstPage { get; set; } = 1;
|
||||
public ushort LastPage { get; set; } = 1;
|
||||
@ -168,23 +170,27 @@ namespace Txt2Bib.Records
|
||||
Author = entryLines[1].Split(',').Select(a => Rearrange(a)).ToArray();
|
||||
Year = ushort.Parse(entryLines[2]);
|
||||
Title = entryLines[3];
|
||||
BookTitle = entryLines[4];
|
||||
Address = entryLines[5] != String.Empty ? entryLines[5] : Address;
|
||||
Publisher = entryLines[6];
|
||||
Editor = entryLines[4] != String.Empty ?
|
||||
Regex.Replace(entryLines[4], @"\(eds?\.\)", "").Split(',').Select(a => Rearrange(a)).ToArray() :
|
||||
Editor;
|
||||
BookTitle = entryLines[5];
|
||||
Series = entryLines[6] != String.Empty ? entryLines[6] : Series;
|
||||
Address = entryLines[7] != String.Empty ? entryLines[7] : Address;
|
||||
Publisher = entryLines[8];
|
||||
try
|
||||
{
|
||||
FirstPage = ushort.Parse(entryLines[7].Split('-')[0]);
|
||||
LastPage = ushort.Parse(entryLines[7].Split('-')[1].TrimEnd('.'));
|
||||
FirstPage = ushort.Parse(entryLines[9].Split('-')[0]);
|
||||
LastPage = ushort.Parse(entryLines[9].Split('-')[1].TrimEnd('.'));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
throw new Exception("Formato numeri di pagina errato...");
|
||||
}
|
||||
|
||||
if (entryLines.Length > 8 )
|
||||
if (entryLines.Length > 10)
|
||||
{
|
||||
if (IsDoi(entryLines[8])) Doi = entryLines[8];
|
||||
else Url = entryLines[8];
|
||||
if (IsDoi(entryLines[10])) Doi = entryLines[10];
|
||||
else Url = entryLines[10];
|
||||
}
|
||||
|
||||
return ToString();
|
||||
@ -194,12 +200,16 @@ namespace Txt2Bib.Records
|
||||
{
|
||||
string label = Author[0][..5].Replace(". ", "");
|
||||
string authString = $"\tauthor = \"{string.Join(" and ", Author)}\",\n";
|
||||
string edsString = Editor.Length != 0 ?
|
||||
$"\teditor = \"{string.Join(" and ", Editor)}\",\n" : "";
|
||||
|
||||
return $"@{Type}{{{label}_{Year},\n" +
|
||||
authString +
|
||||
edsString +
|
||||
$"\ttitle = {{{Title}}},\n" +
|
||||
$"\tbooktitle = {{{BookTitle}}},\n" +
|
||||
$"\tpublisher = \"{Publisher}\",\n" +
|
||||
$"\tseries = {{{Series}}},\n" +
|
||||
$"\taddress = \"{Address}\",\n" +
|
||||
$"\tyear = \"{Year}\",\n" +
|
||||
$"\tpages = \"{FirstPage}--{LastPage}\",\n" +
|
||||
@ -218,6 +228,7 @@ namespace Txt2Bib.Records
|
||||
public string BookTitle { get; set; } = "";
|
||||
public ushort Year { get; set; } = 1950;
|
||||
public string Publisher { get; set; } = "";
|
||||
public string Series { get; set; } = "";
|
||||
public string Address { get; set; } = "";
|
||||
public ushort FirstPage { get; set; } = 1;
|
||||
public ushort LastPage { get; set; } = 1;
|
||||
@ -229,24 +240,25 @@ namespace Txt2Bib.Records
|
||||
Author = entryLines[1].Split(',').Select(a => Rearrange(a)).ToArray();
|
||||
Year = ushort.Parse(entryLines[2]);
|
||||
Title = entryLines[3];
|
||||
Editor = entryLines[4].Replace("(eds.)", "").Split(',').Select(a => Rearrange(a)).ToArray();
|
||||
Editor = Regex.Replace(entryLines[4], @"\(eds?\.\)", "").Split(',').Select(a => Rearrange(a)).ToArray();
|
||||
BookTitle = entryLines[5];
|
||||
Address = entryLines[6] != String.Empty ? entryLines[6] : Address;
|
||||
Publisher = entryLines[7];
|
||||
Series = entryLines[6] != String.Empty ? entryLines[6] : Series;
|
||||
Address = entryLines[7] != String.Empty ? entryLines[7] : Address;
|
||||
Publisher = entryLines[8];
|
||||
try
|
||||
{
|
||||
FirstPage = ushort.Parse(entryLines[8].Split('-')[0]);
|
||||
LastPage = ushort.Parse(entryLines[8].Split('-')[1].TrimEnd('.'));
|
||||
FirstPage = ushort.Parse(entryLines[9].Split('-')[0]);
|
||||
LastPage = ushort.Parse(entryLines[9].Split('-')[1].TrimEnd('.'));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
throw new Exception("Formato numeri di pagina errato...");
|
||||
}
|
||||
|
||||
if (entryLines.Length > 9)
|
||||
if (entryLines.Length > 10)
|
||||
{
|
||||
if (IsDoi(entryLines[9])) Doi = entryLines[9];
|
||||
else Url = entryLines[9];
|
||||
if (IsDoi(entryLines[10])) Doi = entryLines[10];
|
||||
else Url = entryLines[10];
|
||||
}
|
||||
|
||||
return ToString();
|
||||
@ -264,6 +276,7 @@ namespace Txt2Bib.Records
|
||||
$"\ttitle = {{{Title}}},\n" +
|
||||
$"\tbooktitle = {{{BookTitle}}},\n" +
|
||||
$"\tpublisher = \"{Publisher}\",\n" +
|
||||
$"\tseries = {{{Series}}},\n" +
|
||||
$"\taddress = \"{Address}\",\n" +
|
||||
$"\tyear = \"{Year}\",\n" +
|
||||
$"\tpages = \"{FirstPage}--{LastPage}\",\n" +
|
||||
|
@ -5,7 +5,7 @@
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Version>0.1.5</Version>
|
||||
<Version>0.1.6</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user