Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wisp3rwind committed Nov 19, 2024
0 parents commit 584fbc5
Show file tree
Hide file tree
Showing 16 changed files with 2,063 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
tests:
strategy:
matrix:
typst-version: ["0.12"]
# the docs don't need to build with all versions supported by the package;
# the latest one is enough
# include:
# - typst-version: "0.12"
# doc: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Probe runner package cache
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: imagemagick cargo
version: 1.0

- name: Install oxipng from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: oxipng

- name: Install just from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: just

- name: Install typst-test from github
uses: baptiste0928/cargo-install@v3
with:
crate: typst-test
git: https://github.com/tingerrr/typst-test.git
tag: ci-semi-stable

- name: Setup typst
id: setup-typst
uses: typst-community/setup-typst@v3
with:
typst-version: ${{ matrix.typst-version }}

- name: Run test suite
run: just test

- name: Archive diffs
uses: actions/upload-artifact@v4
if: always()
with:
name: typst-${{ steps.setup-typst.outputs.typst-version }}-diffs
path: |
tests/**/diff/*.png
tests/**/out/*.png
tests/**/ref/*.png
retention-days: 5

- name: Build docs
if: ${{ matrix.doc }}
run: just doc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/*/out
tests/*/diff
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [unreleased](https://github.com/wisp3rwind/typst-guide-lines/releases/tag/<tag>)

## Added

## Removed

## Changed

## Migration Guide from v0.1.x

# [v0.1.0](https://github.com/wisp3rwind/typst-guide-lines/releases/tag/v0.1.0)
Initial release
24 changes: 24 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
root := justfile_directory()

export TYPST_ROOT := root


[private]
default:
@just --list --unsorted

# run reference tests
test *args:
typst-test run {{ args }}

# update reference tests
update *args:
typst-test update {{ args }}

# compile examples for README to svg
examples:
for f in "{{ root }}/docs"/*.typ; do rm -f "${f/.typ/}"-*.svg; typst compile "$f" "${f/.typ/-p\{0p\}.svg}"; done

# install the package into the specified target folder (which may be @local)
install target="@local":
./scripts/install "{{target}}"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 wisp3rwind

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# The `guide-lines` Package

Show borders around the main text area, header and footer in Typst documents.

This may be useful to understand and debug layout issues.
The idea is similar to the LaTeX [`layout`](https://ctan.org/pkg/layout)
package.

## Usage

```typst
#import "@preview/guide-lines:v0.1.0": background
#set page(paper: "a6")
#set page(background: background())
#lorem(100)
#pagebreak()
#set page(background: background(stroke: blue + 1pt))
#lorem(100)
```

![Output of the usage example, page 1](/docs/example-1-p1.svg) ![Output of the usage example, page 2](/docs/example-1-p2.svg)

## Known issues

The following limitations are known, PRs to address them are always welcome!:

- If `page.margin` contains the `inside` or `outside` keys, and `page.binding`
is set to `auto`, the package will currently assume an LTR document with
binding on the left side. It would be correct to follow Typst and determine
the binding according to the text direction.

## Acknowledgements
The following Typst issues and forum post inspired this package and informed
its design and implementation:

- https://github.com/typst/typst/issues/5311
Loading

0 comments on commit 584fbc5

Please sign in to comment.