CiteUrl.Core 1.0.1

dotnet add package CiteUrl.Core --version 1.0.1
                    
NuGet\Install-Package CiteUrl.Core -Version 1.0.1
                    
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="CiteUrl.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CiteUrl.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CiteUrl.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CiteUrl.Core --version 1.0.1
                    
#r "nuget: CiteUrl.Core, 1.0.1"
                    
#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.
#:package CiteUrl.Core@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CiteUrl.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CiteUrl.Core&version=1.0.1
                    
Install as a Cake Tool

CiteUrl.NET

A .NET 9 library for parsing and hyperlinking legal citations. C# port of the Python citeurl library by Simon Raindrum Sherred.

NuGet License

Features

  • 130+ Citation Formats: US federal and state case law, statutes, regulations, constitutions, and rules
  • Thread-Safe: Fully immutable design with lazy singleton for concurrent use
  • Memory Efficient: Streaming enumeration (IEnumerable<T>) for processing large documents
  • HTML/Markdown Links: Insert hyperlinks directly into your text
  • Authority Grouping: Group multiple citations to the same legal source
  • Shortform Resolution: Automatically links "Id." and shortform citations to their parent
  • YAML-Based Templates: Extensible citation patterns via YAML configuration
  • DI-Friendly: Optional dependency injection extensions
  • ReDoS Protection: Built-in regex timeout protection

Installation

dotnet add package CiteUrl.Core

For dependency injection support:

dotnet add package CiteUrl.Extensions.DependencyInjection

Quick Start

Find a Single Citation

using CiteUrl.Core.Templates;

var citation = Citator.Cite("See 42 U.S.C. § 1983 for details.");

Console.WriteLine(citation?.Text);  // "42 U.S.C. § 1983"
Console.WriteLine(citation?.Url);   // "https://www.law.cornell.edu/uscode/text/42/1983"
Console.WriteLine(citation?.Name);  // "42 U.S.C. § 1983"

Find All Citations

var text = @"
    Federal law provides civil rights remedies under 42 U.S.C. § 1983,
    and attorney's fees may be awarded pursuant to § 1988.
    See also Fed. R. Civ. P. 12(b)(6).
";

foreach (var citation in Citator.ListCitations(text))
{
    Console.WriteLine($"{citation.Name} -> {citation.Url}");
}

// Output:
// 42 U.S.C. § 1983 -> https://www.law.cornell.edu/uscode/text/42/1983
// § 1988 -> https://www.law.cornell.edu/uscode/text/42/1988
// Fed. R. Civ. P. 12(b)(6) -> https://www.law.cornell.edu/rules/frcp/rule_12
var text = "See 42 U.S.C. § 1983 and 29 C.F.R. § 1630.2 for details.";
var html = Citator.Default.InsertLinks(text);

Console.WriteLine(html);
// Output:
// See <a href="https://www.law.cornell.edu/uscode/text/42/1983" class="citation" title="42 U.S.C. § 1983">42 U.S.C. § 1983</a>
// and <a href="..." class="citation" title="29 C.F.R. § 1630.2">29 C.F.R. § 1630.2</a> for details.
var markdown = Citator.Default.InsertLinks(text, markupFormat: "markdown");

Console.WriteLine(markdown);
// Output:
// See [42 U.S.C. § 1983](https://www.law.cornell.edu/uscode/text/42/1983)
// and [29 C.F.R. § 1630.2](...) for details.

Group Citations by Authority

var text = @"
    See 42 U.S.C. § 1983 and § 1985. Also 42 U.S.C. § 1983 again.
";

var authorities = Citator.ListAuthorities(text);

foreach (var authority in authorities)
{
    Console.WriteLine($"{authority.Name}: {authority.Citations.Count} citations");
}

// Output:
// 42 U.S.C. § 1983: 2 citations
// 42 U.S.C. § 1985: 1 citation

Supported Citation Types

  • U.S. Case Law: Supreme Court, Circuit Courts, District Courts, Bankruptcy
  • State Case Law: All 50 states + territories
  • Federal Statutes: U.S. Code (USC)
  • Federal Regulations: Code of Federal Regulations (CFR)
  • State Codes: California, New York, Texas, and 47 other states
  • Constitutions: U.S. Constitution, state constitutions
  • Federal Rules: FRCP, FRE, FRAP, FRCrP, etc.
  • Secondary Sources: Law reviews, restatements

See USAGE.md for detailed examples of each citation type.

Advanced Usage

Custom YAML Templates

var yaml = @"
My Custom Citation:
  tokens:
    volume: \d+
    page: \d+
  pattern: 'Vol. {volume}, p. {page}'
  URL builder:
    parts: ['https://example.com/vol/', '{volume}', '/page/', '{page}']
";

var citator = Citator.FromYaml(yaml);
var citation = citator.Cite("See Vol. 123, p. 456");

Console.WriteLine(citation?.Url); // https://example.com/vol/123/page/456

Dependency Injection

// In Startup.cs or Program.cs
services.AddCiteUrl();

// In your service
public class MyService
{
    private readonly ICitator _citator;

    public MyService(ICitator citator)
    {
        _citator = citator;
    }

    public void ProcessLegalText(string text)
    {
        var citations = _citator.ListCitations(text);
        // ...
    }
}

Documentation

  • USAGE.md - Detailed usage guide with examples
  • API Reference - Full XML documentation available via IntelliSense in your IDE
  • Python Original - Original Python library

Contributing

Contributions welcome! Please see CONTRIBUTING.md for guidelines.

Attribution

This is a C# port of the Python citeurl library created by Simon Raindrum Sherred. The original Python library is licensed under the MIT License.

License

MIT License - see LICENSE for details.

Original Python library by Simon Raindrum Sherred, MIT License.

Status

🚧 Alpha - Core functionality complete, API may change before 1.0 release.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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 CiteUrl.Core:

Package Downloads
CiteUrl.Extensions.DependencyInjection

Dependency injection extensions for CiteUrl.Core library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 192 10/20/2025