HelperVSCodePossibleExtension and
Person Title
This commit is contained in:
@ -10,6 +10,73 @@ internal static partial class HelperCreateNoteFiles
|
||||
[GeneratedRegex("[^a-z0-9-]")]
|
||||
private static partial Regex AlphaNumOnly();
|
||||
|
||||
private static string? GetTags(string tagsText)
|
||||
{
|
||||
string? result;
|
||||
StringBuilder stringBuilder = new();
|
||||
if (string.IsNullOrEmpty(tagsText))
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string[] segments;
|
||||
_ = stringBuilder.AppendLine("tags:");
|
||||
string[] tags = tagsText.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string tag in tags)
|
||||
{
|
||||
segments = tag.Split(':');
|
||||
_ = stringBuilder.AppendLine($"- '{segments.First()}'");
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetLinks(string type, string linksText)
|
||||
{
|
||||
string? result;
|
||||
StringBuilder stringBuilder = new();
|
||||
if (!string.IsNullOrEmpty(linksText))
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string linkLower;
|
||||
string[] segments;
|
||||
string[] links = linksText.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string link in links)
|
||||
{
|
||||
segments = link.Split(':');
|
||||
linkLower = AlphaNumOnly().Replace(segments.First().Trim().ToLower(), "-").Replace("--", "-");
|
||||
if (segments.Length == 1)
|
||||
_ = stringBuilder.AppendLine($"- [[{type}/{linkLower}]]");
|
||||
else if (segments.Length == 2)
|
||||
_ = stringBuilder.AppendLine($"- [{type}/{linkLower}]({segments.Last()})");
|
||||
else
|
||||
continue;
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetAttributes(string[] columns, string[]? headerColumns, int expectedCount)
|
||||
{
|
||||
string? result;
|
||||
if (headerColumns is null || columns.Length <= expectedCount)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int j = expectedCount; j < columns.Length; j++)
|
||||
{
|
||||
if (headerColumns.Length <= j)
|
||||
continue;
|
||||
_ = stringBuilder.AppendLine($"{headerColumns[j].Trim()}: '{columns[j].Trim()}'");
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void CleanExistingFiles(string directory, long ticks)
|
||||
{
|
||||
string check;
|
||||
@ -100,73 +167,6 @@ internal static partial class HelperCreateNoteFiles
|
||||
}
|
||||
}
|
||||
|
||||
private static string? GetTags(string tagsText)
|
||||
{
|
||||
string? result;
|
||||
StringBuilder stringBuilder = new();
|
||||
if (string.IsNullOrEmpty(tagsText))
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string[] segments;
|
||||
_ = stringBuilder.AppendLine("tags:");
|
||||
string[] tags = tagsText.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string tag in tags)
|
||||
{
|
||||
segments = tag.Split(':');
|
||||
_ = stringBuilder.AppendLine($"- '{segments.First()}'");
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetLinks(string type, string linksText)
|
||||
{
|
||||
string? result;
|
||||
StringBuilder stringBuilder = new();
|
||||
if (!string.IsNullOrEmpty(linksText))
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
string linkLower;
|
||||
string[] segments;
|
||||
string[] links = linksText.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string link in links)
|
||||
{
|
||||
segments = link.Split(':');
|
||||
linkLower = AlphaNumOnly().Replace(segments.First().Trim().ToLower(), "-").Replace("--", "-");
|
||||
if (segments.Length == 1)
|
||||
_ = stringBuilder.AppendLine($"- [[{type}/{linkLower}]]");
|
||||
else if (segments.Length == 2)
|
||||
_ = stringBuilder.AppendLine($"- [{type}/{linkLower}]({segments.Last()})");
|
||||
else
|
||||
continue;
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? GetAttributes(string[] columns, string[]? headerColumns, int expectedCount)
|
||||
{
|
||||
string? result;
|
||||
if (headerColumns is null || columns.Length <= expectedCount)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int j = expectedCount; j < columns.Length; j++)
|
||||
{
|
||||
if (headerColumns.Length <= j)
|
||||
continue;
|
||||
_ = stringBuilder.AppendLine($"{headerColumns[j].Trim()}: '{columns[j].Trim()}'");
|
||||
}
|
||||
result = stringBuilder.ToString().Trim();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void CreateImportFiles(long ticks, List<string> importFiles)
|
||||
{
|
||||
bool csv;
|
||||
|
Reference in New Issue
Block a user