mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Added documentation for markup text
This commit is contained in:
parent
7fd2efaeb5
commit
173645cdd2
2
.github/workflows/publish.yaml
vendored
2
.github/workflows/publish.yaml
vendored
@ -6,6 +6,8 @@ on:
|
||||
- '*'
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'src/**'
|
||||
|
||||
env:
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
|
1
docs/Preview.ps1
Normal file
1
docs/Preview.ps1
Normal file
@ -0,0 +1 @@
|
||||
dotnet run -- preview --virtual-dir "spectre.console"
|
BIN
docs/input/assets/images/helloworld.png
Normal file
BIN
docs/input/assets/images/helloworld.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -1,5 +1,5 @@
|
||||
Title: Colors
|
||||
Order: 2
|
||||
Order: 4
|
||||
---
|
||||
|
||||
The following is a list of the standard 8-bit colors supported in terminals.
|
||||
|
95
docs/input/docs/markup.md
Normal file
95
docs/input/docs/markup.md
Normal file
@ -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.
|
||||
|
||||

|
||||
|
||||
|
||||
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.
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><code>bold</code></td>
|
||||
<td>Bold text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>dim</code></td>
|
||||
<td>Dim or faint text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>italic</code></td>
|
||||
<td>Italic text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>underline</code></td>
|
||||
<td>Underlined text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>invert</code></td>
|
||||
<td>Swaps the foreground and background colors</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>conceal</code></td>
|
||||
<td>Hides the text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>slowblink</code></td>
|
||||
<td>Makes text blink slowly</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>rapidblink</code></td>
|
||||
<td>Makes text blink</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>strikethrough</code></td>
|
||||
<td>Shows text with a horizontal line through the center</td>
|
||||
</tr>
|
||||
</table>
|
Loading…
x
Reference in New Issue
Block a user