Add table heading and footnote support

Closes #116
This commit is contained in:
Patrik Svensson
2020-10-19 00:41:40 +02:00
committed by Patrik Svensson
parent 5c119ee0c3
commit cb2924a609
15 changed files with 299 additions and 259 deletions

View File

@ -8,14 +8,9 @@ namespace Spectre.Console.Internal
public static string GetAbbreviatedDayName(this DayOfWeek day, CultureInfo culture)
{
culture ??= CultureInfo.InvariantCulture;
var name = culture.DateTimeFormat.GetAbbreviatedDayName(day);
if (name.Length > 0 && char.IsLower(name[0]))
{
name = string.Format(culture, "{0}{1}", char.ToUpper(name[0], culture), name.Substring(1));
}
return name;
return culture.DateTimeFormat
.GetAbbreviatedDayName(day)
.Capitalize(culture);
}
public static DayOfWeek GetNextWeekDay(this DayOfWeek day)

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Spectre.Console.Rendering;
@ -18,6 +19,23 @@ namespace Spectre.Console.Internal
return Cell.GetCellLength(context, text);
}
public static string Capitalize(this string text, CultureInfo? culture = null)
{
if (text == null)
{
return string.Empty;
}
culture ??= CultureInfo.InvariantCulture;
if (text.Length > 0 && char.IsLower(text[0]))
{
text = string.Format(culture, "{0}{1}", char.ToUpper(text[0], culture), text.Substring(1));
}
return text;
}
public static string NormalizeLineEndings(this string text, bool native = false)
{
text ??= string.Empty;