An open API service indexing awesome lists of open source software.

https://github.com/braheezy/zibra

Web browser from scratch
https://github.com/braheezy/zibra

zig

Last synced: about 1 year ago
JSON representation

Web browser from scratch

Awesome Lists containing this project

README

          

# zibra

> [!WARNING]
> This project is actively in work! `HEAD` usually works but it may be broken or produce nasty results.

This repo holds my Zig code for the browser implemented in [Web Browser Engineering](https://browser.engineering/).

## Usage

You'll need Zig installed.

Clone the project

```sh
git clone https://github.com/braheezy/zibra.git
```

To build the project, run:

```sh
zig build
cp zig-out/bin/zibra .
```

`zibra` (optionally) takes one URL and displays the result in a window:

```sh
zibra https://example.org
```

Run without a URL for a default HTML.

## Supported Features

`zibra` is small but supports the basics:

- HTTP/1.1
- HTTPS
- `file://` URIs
- `data:` URIs
- Entity support:
- `&` → `&` (ampersand)
- `<` → `<` (less than)
- `>` → `>` (greater than)
- `"` → `"` (quotation mark)
- `'` → `'` (apostrophe)
- `­` → `­` (soft hyphen)
- Connections that live beyond single request for `Connection: keep-alive` header
- Redirects
- `Cache-Control` header
- `Content-Encoding: gzip` and `Transfer-Encoding: chunked` headers
- Emojis and CJK text
- Various tags for styling:
- `Bold`
- `Italic`
- `Larger text`
- `Smaller text`
- `Superscript`
- `

Centered title

`: An `h1` with `class` set to `title` will be centered
- `Abbreviations`
- `
Preformatted text
`: Including bold and italic variants
- HTML parsing features:
- Automatic insertion of implicit ``, ``, and `` tags
- Proper handling of self-closing tags like ``, `
`, and ``
- Support for quoted, unquoted, and boolean HTML attributes

## Development

There's more Zig commands:

```sh
# build and run
zig build run -- https://example.com
# Run tests
zig build test
```

To test chunked gzip responses, run `gzipServer.py` locally.

## Known Issues

- On Mac, the content is stretched while the window is being resized. Apparently this is known behavior in SDL2 because Mac blocks the main thread while the mouse is being held down to resize windows, preventing SDL from rendering the content properly...I think.