Textify 0.2.0-beta
This is a prerelease version of Textify.
dotnet add package Textify --version 0.2.0-beta
NuGet\Install-Package Textify -Version 0.2.0-beta
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="Textify" Version="0.2.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Textify --version 0.2.0-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Textify, 0.2.0-beta"
#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 Textify as a Cake Addin #addin nuget:?package=Textify&version=0.2.0-beta&prerelease // Install Textify as a Cake Tool #tool nuget:?package=Textify&version=0.2.0-beta&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Textify
An HTML to plaintext conversion library for .NET Standard 2.0 written in C#.
Features
- Supports HTML headings, paragraphs, containers, lists and tables (basic support)
- Takes an HTML string as an input or an
INode
from AngleSharp - Outputs a readable text representation of the web page
- Targets .NET Standard 2.0
- Full test coverage
Installation
Install from NuGet:
Install-Package Textify
or
dotnet add package Textify
Usage
HtmlToTextConverter converter = new HtmlToTextConverter();
string output = converter.Convert(html);
By default, the whole page will be converted.
If you're interested in converting only a part of it, parse the page by yourself with AngleSharp and pass the INode
you're interested in. You don't need to install AngleSharp because Textify already depends on it.
HtmlParser parser = new HtmlParser();
IHtmlDocument doc = parser.ParseDocument(html);
IElement element = doc.QuerySelector("#main");
HtmlToTextConverter converter = new HtmlToTextConverter();
string output = converter.Convert(element);
Example
Input:
<div id="page">
<header>
<a href="http://example.com" class="site-logo">
<img src="logo.png" alt="Logo" />
</a>
<h1>
Site title
</h1>
</header>
<main>
<article>
<h2>Article title</h2>
<p>
<strong>Lorem ipsum</strong> dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.</p>
Here is a list of things anyway:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
But maybe a table is nicer:<br><br>
<table>
<thead>
<th>Key</th>
<th>Value</th>
</thead>
<tr>
<td>One</td>
<td>Value</td>
</tr>
</table>
</article>
</main>
</div>
Output:
[IMG: Logo] [1]
++++++++++
Site title
++++++++++
-------------
Article title
-------------
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Here is a list of things anyway:
* One
* Two
* Three
But maybe a table is nicer:
| Key | Value |
| One | Value |
[1] http://example.com```
## License
MIT license.
Thanks to Jay Taylor for the inspiration with his [html2text](https://github.com/jaytaylor/html2text) Go module.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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
- AngleSharp (>= 0.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.0-beta | 55,180 | 3/16/2021 |
0.1.0-beta | 7,651 | 11/29/2019 |