Microformats 1.1.2

dotnet add package Microformats --version 1.1.2                
NuGet\Install-Package Microformats -Version 1.1.2                
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="Microformats" Version="1.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microformats --version 1.1.2                
#r "nuget: Microformats, 1.1.2"                
#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 Microformats as a Cake Addin
#addin nuget:?package=Microformats&version=1.1.2

// Install Microformats as a Cake Tool
#tool nuget:?package=Microformats&version=1.1.2                

Project Logo Microformats .NET

A .NET Microformats2 parser.

This parser implements the full Microformats2 specification, including backwards compatibility with classic Microformats.

Implementation

This parser does not restrict the property or microformat names to those explicitly mentioned in the specification. Any h-*, p-*, u-*, e-*, dt-* will be handelled with regard to the parsing rules for that type.

Key Features

Installation

This library is distributed as a NuGet package. To install with the .NET CLI run dotnet add package Microformats --version {version number}

Quick Start

Parse a HTML string

 var parser = new Mf2();
 var html = "...";
 var result = parser.Parse(html);

Configure the parser

var parser = new Mf2().WithOptions(o =>
{
    o.DiscoverLang = true;
    o.UpgradeClassicMicroformats = true;
    o.BaseUri = new Uri("http://example.org");
    return o;
}); ;
 var html = "...";
 var result = parser.Parse(html);

Example

Here is an example parsing someone's h-card.

 var parser = new Mf2();
 var html = "<a class=\"h-card\" href=\"{website address}\"><img alt=\"{name of person}\" src=\"{address of photo}\" /></a>";
 var result = parser.Parse(html);

 result.Items[0].Get(Props.NAME)[0]; //Access name
 result.Items[0].Get(Props.URL)[0]; //Access website
 result.Items[0].Get(Props.PHOTO)[0]; //Access photo

Usage notes

  • All the different Microformats (h-*) parsed are held in the result.Items array.
  • Access the string value for a property using the .Get({name}) method. This returns an array of all values for that property, typically it will be just one if present.
  • Some properties can have a more complex data structure which are represented by the types MfImage, and MfEmbedded. Use the generic .Get<Type>({name}) to access the underlying complex type.
  • Unsure of the underlying type? Use the .TryGet<T>({name}, out T result) and fallback on the string version on failure.
  • Well known properties from the spec are in the Props class (e.g. Props.NAME), these are just strings, you can pass in any non-standard property as long as it follows the p-*, u-* etc. pattern. (e.g. .Get("p-some-non-standard-prop")).

Roadmap

  • Format to JSON

Contributing

Contributions are very welcome!

Ways to contribute

  • Fix an existing issue and submit a pull request
  • Review open pull requests
  • Report a new issue
  • Make a suggestion/ contribute to a discussion

Acknowledgments

The project logo is derived from the microformats logo mark by Rémi Prévost.

License

MIT

Product 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Microformats:

Package Downloads
AspNet.Security.IndieAuth

ASP.NET Core authentication handler enabling IndieAuth authentication.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 216 8/16/2023
1.1.1 175 8/16/2023
1.1.0 175 8/16/2023
1.0.0 166 8/16/2023
0.1.0 168 8/16/2023

Update package description