Release v1.0.2

- moved folders around
- provided readme
This commit is contained in:
Alexander Kozachenko 2023-11-07 16:51:25 +03:00
parent 13659e7eaf
commit fc19e6e4e1
31 changed files with 102 additions and 71 deletions

View File

@ -1,19 +1,47 @@
# ProSol.Web.Html.TagsProvider
# ProSol.Html.TagsProvider
A tool for extracting tags from HTML, via push-notifications.
TagsProvider is a tool for extracting HTML tags from a string, in event-driven way.
Helps to extract text, structured data, from a specific site.
- [Usage](#usage)
- [Known Issues](#known-issues)
- [Goals](#goals)
- [Footnote](#footnote)
## How to use?
## Usage
Install the package:
```sh
dotnet add package ProSol.Html.TagsProvider
```
## Known Issues
Make an Observer:
```csharp
internal class ConsoleLogObserver : IObserver<TagsProviderMessage>
{
public void OnCompleted() { }
## Goals
public void OnError(Exception error) { }
## Footnote
public void OnNext(TagsProviderMessage value)
{
Console.WriteLine(value.CurrentTag.TagInfo.Name);
}
}
```
- The versioning is complied to the Semver 2.0.0. Please refer to [semver.org](https://semver.org/) for details.
- Please refer to the [Changelog](./Changelog.md) for the progress.
Run the TagsProvider:
```csharp
var provider = new TagsProvider();
using var unsub = provider.Subscribe(new ConsoleLogObserver());
provider.Process("<div> <span> </span> </div>");
```
Get the output:
```
span
div
```
That's it!
The provider notifies about any tag met and its data:
- name,
- range of entire tag,
- range of inner content.
More demos [here](https://git.disroot.org/alexenko/Demos/src/branch/master/ProSol.TagsProvider).

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSol.Web.Html.Tests", "ProSol.Web.Html.Tests\ProSol.Web.Html.Tests.csproj", "{2EF0FD35-7C6C-4CE7-8BA6-BE00FB7402FA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSol.Html.Tests", "tests\ProSol.Html.Tests.csproj", "{2EF0FD35-7C6C-4CE7-8BA6-BE00FB7402FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSol.Web.Html", "ProSol.Web.Html\ProSol.Web.Html.csproj", "{24E53336-6607-4660-B194-297813769605}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProSol.Html", "src\ProSol.Html.csproj", "{24E53336-6607-4660-B194-297813769605}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Contracts.Data;
namespace ProSol.Html.Contracts.Data;
/// <summary>
/// Represents the completed tag with metadata and offsets from begin to end.

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Contracts.Data;
namespace ProSol.Html.Contracts.Data;
/// <summary>
/// Represents the html info about the tag.

View File

@ -1,6 +1,6 @@
using System.Collections.Immutable;
namespace ProSol.Web.Html.Contracts.Data;
namespace ProSol.Html.Contracts.Data;
/// <summary>
/// Represents a push-notification from <see cref="TagsProvider"/>

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Contracts.Operations;
namespace ProSol.Html.Contracts.Operations;
/// <summary>
/// Provides a conditional subscription.

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Data;
namespace ProSol.Html.Data;
internal enum TagKind
{

View File

@ -1,11 +1,11 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Html.Contracts.Data;
namespace ProSol.Web.Html.Data;
namespace ProSol.Html.Data;
/// <summary>
/// Represents an opened tag, when there is incomplete data about it.
/// </summary>
public record class UnprocessedTag(
internal record class UnprocessedTag(
TagInfo TagInfo,
int TagOffset,
int? InnerOffset);

View File

@ -1,6 +1,6 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Html.Contracts.Data;
namespace ProSol.Web.Html.Messaging;
namespace ProSol.Html.Messaging;
internal class Broadcaster
{

View File

@ -1,5 +1,5 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Html.Contracts.Data;
namespace ProSol.Web.Html.Messaging;
namespace ProSol.Html.Messaging;
internal record class TagObserver(IObserver<TagsProviderMessage> Observer, string? TagName);

View File

@ -1,5 +0,0 @@
global using ProSol.Web.Html.Tools;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("ProSol.Web.Html.Tests")]

View File

@ -1,9 +1,9 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Web.Html.Contracts.Operations;
using ProSol.Web.Html.Data;
using ProSol.Web.Html.Messaging;
using ProSol.Html.Contracts.Data;
using ProSol.Html.Contracts.Operations;
using ProSol.Html.Data;
using ProSol.Html.Messaging;
namespace ProSol.Web.Html;
namespace ProSol.Html;
/// <summary>
/// Processes the html input, provides push-notifications when html tag met for <see cref="IObserver<TagsProviderMessage"/>.

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Tools.Extracting;
namespace ProSol.Html.Tools.Extracting;
internal static class AttributeExtractor
{

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Tools.Extracting;
namespace ProSol.Html.Tools.Extracting;
internal sealed class AttributeValuesExtractor
{

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Tools.Extracting;
namespace ProSol.Html.Tools.Extracting;
internal sealed class TagNameExtractor
{

View File

@ -1,8 +1,8 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Web.Html.Data;
using ProSol.Web.Html.Tools.Extracting;
using ProSol.Html.Contracts.Data;
using ProSol.Html.Data;
using ProSol.Html.Tools.Extracting;
namespace ProSol.Web.Html.Tools;
namespace ProSol.Html.Tools;
internal class HistoryTracker
{

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Tools;
namespace ProSol.Html.Tools;
internal static class StringExtensions
{

View File

@ -1,6 +1,6 @@
using ProSol.Web.Html.Data;
using ProSol.Html.Data;
namespace ProSol.Web.Html.Tools;
namespace ProSol.Html.Tools;
internal static class TagDetector
{

View File

@ -1,4 +1,4 @@
namespace ProSol.Web.Html.Tools;
namespace ProSol.Html.Tools;
internal static class TagsNavigator
{

5
src/Usings.cs Normal file
View File

@ -0,0 +1,5 @@
global using ProSol.Html.Tools;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("ProSol.Html.Tests")]

View File

@ -1,22 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>ProSol.Web.Html.TagsProvider</id>
<title>ProSol.Web.Html.TagsProvider</title>
<version>1.0.1</version>
<id>ProSol.Html.TagsProvider</id>
<title>ProSol.Html.TagsProvider</title>
<version>1.0.2</version>
<authors>Alex Kozachenko</authors>
<owners>Alex Kozachenko</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<readme type="file">docs\Readme.md</readme>
<description>A tool for extracting tags from HTML, via push-notifications. </description>
<description>
TagsProvider is a tool for extracting HTML tags from a string, in event-driven way.
Helps to extract text, structured data, from a specific site.
</description>
<dependencies>
<group targetFramework="net8.0" />
</dependencies>
<tags> tool extraction html observer observer-pattern </tags>
<tags> tool extraction web html observer observer-pattern design-patterns </tags>
</metadata>
<files>
<file src="bin\Release\net8.0\ProSol.Web.Html.dll" target="lib\net8.0" />
<file src="bin\Release\net8.0\ProSol.Html.dll" target="lib\net8.0" />
<file src="..\Readme.md" target="docs\" />
</files>
</package>

View File

@ -1,7 +1,7 @@
using ProSol.Web.Html;
using ProSol.Web.Html.Tests.TestHelpers;
using ProSol.Html;
using ProSol.Html.Tests.TestHelpers;
namespace ProSol.Web.Html.Tests.KnownIssues;
namespace ProSol.Html.Tests.KnownIssues;
public class TagsProvider_KnownIssues
{

View File

@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProSol.Web.Html\ProSol.Web.Html.csproj" />
<ProjectReference Include="..\src\ProSol.Html.csproj" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,7 @@
using ProSol.Web.Html;
using ProSol.Web.Html.Tests.TestHelpers;
using ProSol.Html;
using ProSol.Html.Tests.TestHelpers;
namespace ProSol.Web.Html.Tests;
namespace ProSol.Html.Tests;
public class TagsProvider_MessageHistory_Tests
{

View File

@ -1,7 +1,7 @@
using ProSol.Web.Html;
using ProSol.Web.Html.Tests.TestHelpers;
using ProSol.Html;
using ProSol.Html.Tests.TestHelpers;
namespace ProSol.Web.Html.Tests;
namespace ProSol.Html.Tests;
public class TagsProvider_MultipleTags_Tests
{

View File

@ -1,7 +1,7 @@
using ProSol.Web.Html;
using ProSol.Web.Html.Tests.TestHelpers;
using ProSol.Html;
using ProSol.Html.Tests.TestHelpers;
namespace ProSol.Web.Html.Tests;
namespace ProSol.Html.Tests;
public class TagsProvider_NamedListeners_Tests
{

View File

@ -1,7 +1,7 @@
using ProSol.Web.Html;
using ProSol.Web.Html.Tests.TestHelpers;
using ProSol.Html;
using ProSol.Html.Tests.TestHelpers;
namespace ProSol.Web.Html.Tests;
namespace ProSol.Html.Tests;
public class TagsProvider_SingleTag_Tests
{

View File

@ -1,6 +1,6 @@
using ProSol.Web.Html.Contracts.Data;
using ProSol.Html.Contracts.Data;
namespace ProSol.Web.Html.Tests.TestHelpers;
namespace ProSol.Html.Tests.TestHelpers;
internal class TagsProviderListener : IObserver<TagsProviderMessage>
{