From 173645cdd2bc6f170866437c37d5685a83563c85 Mon Sep 17 00:00:00 2001 From: Patrik Svensson Date: Mon, 31 Aug 2020 14:05:28 +0200 Subject: [PATCH] Added documentation for markup text --- .github/workflows/publish.yaml | 2 + docs/Preview.ps1 | 1 + docs/input/assets/images/helloworld.png | Bin 0 -> 1332 bytes docs/input/docs/colors.md | 2 +- docs/input/docs/markup.md | 95 ++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 docs/Preview.ps1 create mode 100644 docs/input/assets/images/helloworld.png create mode 100644 docs/input/docs/markup.md diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8a5cea8..f80e82f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -6,6 +6,8 @@ on: - '*' branches: - main + paths: + - 'src/**' env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true diff --git a/docs/Preview.ps1 b/docs/Preview.ps1 new file mode 100644 index 0000000..6f4f896 --- /dev/null +++ b/docs/Preview.ps1 @@ -0,0 +1 @@ +dotnet run -- preview --virtual-dir "spectre.console" \ No newline at end of file diff --git a/docs/input/assets/images/helloworld.png b/docs/input/assets/images/helloworld.png new file mode 100644 index 0000000000000000000000000000000000000000..24a440c71b9749fc2935fd6a92f6c7f24de560e4 GIT binary patch literal 1332 zcmaKsYgEz)7>9|lNm|Vt*hZ@`tkl3ubCMjqr+7he{?Y7$n7HD7q{K?^$LwE%E|0XXOpKXpVi`m+iyz{?6~5_rrVM56|rYqUWxi-|Pf| zK)VQD?t$8D)`HUAp`Fu+@J4NHqXl}pf*OYr^V$NTy7;+(KrJl2jh}S19UA9#iUtC~ zQ2(%v5P0abc1J>RcL_>5w^-7}*asN*ZJxGjK>6uDLDC^8)2v-qb?!zXI_WO%um&(0 zwzIIs5E5e*c>92^tAzpQ%J1an@pP#~E=g3$W(PUgg%nIm&ry8G>y(cI+Pk+STtTdi zS6hy4iz+2WW^gM03#=Wu>AIu0AYmr!L6`V)7`jQKk}KJFSQv_*1~bR$SvVYiVd=T; zQERYQw$<*Obj|Df$d1h392^w9rBQ1JAR?|~9~o9b@Ll&Jk$+_e^N1Q|mS6)WHx zW94Jj%7UsddF-Us0PpgZ`5I3c>hzIWX3VsJifKfR!nS`=N?*3;6|d{ScdSo8z4PD2|eF^^aSWEL-F{r2Mwwmqh=|5&O%^FDrW0q&E}TweSecJjl*C5%V@{y@$i8rj!8=1d39*$1i<2w#$5Ud}= z%Be4l`1Q&cILkWM$P8>DF7(B#ukxApV%Uq=sa%s86R26i8EC^|zgGX)<7!s4rQz%L?y|OdLXWux@`UzIA?w)9>lOFm zcT7`1nEql1JyW?Q%#u3v{y>t9PpSr|O)@N_&xVb%v!CO$mubPXyxB#KCwJg3-{JL#6aGp$0(cMW|;lOokBm%c18 z%_j+RJ9(|a%LTEqYs=EEttB3pSyML}Tnwm?Xl3xFMnH=UsI`1FxSr_xChw*a+JJUjN#FWE)U z2!1P^mCSSw;IkPW^FS-Bh{WsV_E6m8T5ROexgjywm;2meZ2Btrc6i^;>8s{Cmr4yT i{*N{OWs?kSn;O1fS;r#j++}J_2O@Y7-5XuQGXDlW`;RsN literal 0 HcmV?d00001 diff --git a/docs/input/docs/colors.md b/docs/input/docs/colors.md index 21fd419..6d52ab1 100644 --- a/docs/input/docs/colors.md +++ b/docs/input/docs/colors.md @@ -1,5 +1,5 @@ Title: Colors -Order: 2 +Order: 4 --- The following is a list of the standard 8-bit colors supported in terminals. diff --git a/docs/input/docs/markup.md b/docs/input/docs/markup.md new file mode 100644 index 0000000..93ceae8 --- /dev/null +++ b/docs/input/docs/markup.md @@ -0,0 +1,95 @@ +Title: Markup +Order: 3 +Hidden: False +--- + +In `Spectre.Console` there's a class called `Markup` that +allows you to output rich text to the console. + +```csharp +AnsiConsole.Render(new Markup("[bold yellow]Hello[/] [red]World![/]")); +``` + +Which should output something similar to the image below. Note that the +actual appearance might vary depending on your terminal. + +![](/spectre.console/assets/images/helloworld.png) + + +The `Markup` class implements `IRenderable` which means that you +can use this in tables, grids, and panels. Most classes that support +rendering of `IRenderable` also have overloads for rendering rich text. + +```csharp +var table = new Table(); +table.AddColumn(new TableColumn(new Markup("[yellow]Foo[/]"))); +table.AddColumn(new TableColumn("[blue]Bar[/]")); +``` + +# Convenience methods + +There is also convenience methods on `AnsiConsole` that can be used +to write markup text to the console without instantiating a new `Markup` +instance. + +```csharp +AnsiConsole.Markup("[underline green]Hello[/] "); +AnsiConsole.MarkupLine("[bold]World[/]"); +``` + +# Setting background color + +You can set the background color in markup by prefixing the color with +`on`. + +``` +[bold yellow on blue]Hello[/] +[default on blue]World[/] +``` + +# Colors + +For a list of colors, see the [Colors](xref:colors) section. + +# Styles + +Note that what styles that can be used is defined by the system or your terminal software, and may not appear as they should. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
boldBold text
dimDim or faint text
italicItalic text
underlineUnderlined text
invertSwaps the foreground and background colors
concealHides the text
slowblinkMakes text blink slowly
rapidblinkMakes text blink
strikethroughShows text with a horizontal line through the center
\ No newline at end of file