Psw.TextWriters
1.0.3
dotnet add package Psw.TextWriters --version 1.0.3
NuGet\Install-Package Psw.TextWriters -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Psw.TextWriters" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Psw.TextWriters --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Psw.TextWriters, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Psw.TextWriters as a Cake Addin
#addin nuget:?package=Psw.TextWriters&version=1.0.3
// Install Psw.TextWriters as a Cake Tool
#tool nuget:?package=Psw.TextWriters&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Indent Text Writer
A Text Writer, with a fluent API, for structured text generation incorporating:
- Automatic Indentation management (configurable).
- Extensions for HTML writing with tag management.
- Extensions for essential Markdown writing.
- Text is output to an internal or external StringBuffer.
- May be further extended to generate any kind of structured output.
Example text writing:
using Psw.TextWriters;
void BasicSample() {
var w = new IndentTextWriter();
w.WriteLine("class ClassName")
.WriteLine("{").Indent()
.WriteLine("public int SomeValue { get; set; }")
.WriteLine()
.WriteLine("public int SomeMethod(int value) {").Indent()
.WriteLine("return value * 2;")
.Outdent().WriteLine("}")
.Outdent().WriteLine("}");
Console.WriteLine(w.AsString());
}
// Same as BasicSample using the Block methods
void BlockSample() {
var w = new IndentTextWriter();
w.WriteLine("class ClassName")
.BlockCurly(b => b
.WriteLine("public int SomeValue { get; set; }")
.WriteLine()
.Write("public int SomeMethod(int value) ")
.BlockCurly(b => b.WriteLine("return value * 2;"))
);
Console.WriteLine(w.AsString());
}
Output of the above:
class ClassName
{
public int SomeValue { get; set; }
public int SomeMethod(int value) {
return value * 2;
}
}
Sample Html writing:
void HtmlSample() {
var w = new IndentTextWriter().SetIndentSize(2);
w.HtmlTag("div", "class='some-class'", c => c
.HtmlLineTag("p", "Some paragraph text")
.HtmlTag("div", c => c.WriteLine("Inner text"))
);
Console.WriteLine(w.AsString());
}
Output of above:
<div class='some-class'>
<p>Some paragraph text</p>
<div>
Inner text
</div>
</div>
Sample Markdown writing:
void MarkdownSample() {
var w = new IndentTextWriter();
w.WriteLine("# Markdown output:")
.Write("This is ").MdBold("bold").MdLB()
.Write("This is ").MdItalic("italic").MdLB()
.Write("This is ").MdBoldItalic("bold and italic").MdLB()
.Write("This is ").MdCode("code").NewLine(2)
.Write("Link: ").MdLink("link title", "https://www.example.com").MdLB()
.Write("Image: ").MdImage("alt text", "/assets/images/san-juan-mountains.jpg").MdLB()
.Write("Image with title: ").MdImage("alt text", "/assets/images/san-juan-mountains.jpg", "San Juan Mountains").MdLB()
.Write("LinkImage: ").MdLinkImage("alt text", "mountains.jpg", "https://www.pics.com/mountains", "Mountains").MdLB();
w.NewLine().WriteLine("## Markdown Table")
.MdTableHeader("LCR", "Left", "Center", "Right")
.MdTableRow("Col 1 Row 1", "Col 2 Row 1", "Col 3 Row 1")
.MdTableRow("Col 1 Row 2", "Col 2 Row 2", "Col 3 Row 2")
.MdTableRow(
c => c.Write("This is ").MdBold("bold").MdBr()
.Write("Bold Link: ").MdBold(m => m.MdLink("bold link title", "https://www.example.com")),
c => c.Write("This is ").MdItalic("italic"),
c => c.Write("Link: ").MdLink("link title", "https://www.example.com")
);
w.NewLine(2).WriteLine("## Badges")
.MdBadgeNugetV("Psw.TextWriters").NewLine().MdBadgeNugetDt("Psw.TextWriters").NewLine()
.MdBadgeCSharp().NewLine().MdBadgeLicenseMIT().NewLine()
.MdBadge("subject", "status", "pink");
Console.WriteLine(w.AsString());
}
Output of above:
# Markdown output:
This is **bold**
This is *italic*
This is ***bold and italic***
This is `code`
Link: [link title](https://www.example.com)
Image: ![alt text](/assets/images/san-juan-mountains.jpg)
Image with title: ![alt text](/assets/images/san-juan-mountains.jpg "San Juan Mountains")
LinkImage: [![alt text](mountains.jpg "Mountains")](https://www.pics.com/mountains)
## Markdown Table
| Left | Center | Right |
| :--- | :---: | ---: |
| Col 1 Row 1 | Col 2 Row 1 | Col 3 Row 1 |
| Col 1 Row 2 | Col 2 Row 2 | Col 3 Row 2 |
| This is **bold**<br/>Bold Link: **[bold link title](https://www.example.com)** | This is *italic* | Link: [link title](https://www.example.com) |
## Badges
[![Nuget](https://img.shields.io/nuget/v/Psw.TextWriters?style=flat)](https://www.nuget.org/packages/Psw.TextWriters/)
[![Nuget](https://img.shields.io/nuget/dt/Psw.TextWriters?style=flat)](https://www.nuget.org/packages/Psw.TextWriters/)
![C#](https://img.shields.io/badge/c%23-%23239120.svg?style=flat&logo=c-sharp&logoColor=white)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://lbesson.mit-license.org/)
[![Generic bandge](https://img.shields.io/badge/subject-status-pink.svg?style=flat)](https://shields.io/)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Net 8 support added.