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
- Host: GitHub
- URL: https://github.com/braheezy/zibra
- Owner: braheezy
- Created: 2024-11-29T20:05:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-16T07:05:04.000Z (over 1 year ago)
- Last Synced: 2025-03-16T08:19:21.902Z (over 1 year ago)
- Topics: zig
- Language: Zig
- Homepage:
- Size: 350 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.