Skip to content

Commit

Permalink
README: update.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jun 9, 2024
1 parent bd5d569 commit 9cc3600
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The bundled [`entities.json`](/entities.json) is sourced from <https://www.w3.or

Modelled on [Philip Jackson's `entities` crate](https://github.com/p-jackson/entities) for Rust.


## Overview

The core datatypes are:
Expand All @@ -30,15 +31,23 @@ pub const ENTITIES: [_]Entity
pub fn lookup(entity: []const u8) ?Entity
```

## Usage

build.zig:
## Serving suggestion

Add it to your `build.zig.zon`:

```
zig fetch --save https://github.com/kivikakk/htmlentities.zig/archive/bd5d569a245c7c8e83812eadcb5761b7ba76ef04.tar.gz
```

In your `build.zig`:

```zig
exe.addPackagePath("htmlentities", "vendor/htmlentities.zig/src/main.zig");
const htmlentities_dep = b.dependency("htmlentities.zig", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("htmlentities", htmlentities_dep.module("htmlentities"));
```

main.zig:
In your `main.zig`:

```zig
const std = @import("std");
Expand All @@ -56,6 +65,7 @@ Output:
eacute: Entity{ .entity = &eacute;, .codepoints = Codepoints{ .Single = 233 }, .characters = é }
```


## Help wanted

Ideally we'd do the JSON parsing and struct creation at comptime. The std JSON
Expand Down
6 changes: 0 additions & 6 deletions zig.mod

This file was deleted.

0 comments on commit 9cc3600

Please sign in to comment.