Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page-bordering:1.0.0 #1653

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/preview/page-bordering/1.0.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2025 Shumpei-Tanaka

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.
175 changes: 175 additions & 0 deletions packages/preview/page-bordering/1.0.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<a name="readme-top"></a>

<!-- Project Shields -->

[![GitHub release (latest SemVer)][release-shield]][release-url][![GitHub License][license-shield]][license-url]

[![Paypal][Paypal-shield]][Paypal-url][![BuyMeACoffee][BuyMeACoffee-sheild]][BuyMeACoffee-url]

<!-- Project Logo -->
<br />
<div align="center">
<a href="https://github.com/Shumpei-Tanaka/typst-page-bordering">
<img src="assets/page-bordering-example-table-header-footer.png" alt="Logo" width="50%" height="50%">
</a>

<h3 align="center">page-bordering</h3>

<p align="center">
Way to write border around page margin and header/footer.
<br />
<a href="https://github.com/Shumpei-Tanaka/typst-page-bordering/issues">Report Bug</a>
·
<a href="https://github.com/Shumpei-Tanaka/typst-page-bordering/issues">Request Feature</a>
</p>
</div>

<!-- Table of Contents -->

1. [About The Project](#about-the-project)
2. [Demo](#demo)
1. [Page border include table header/footer](#page-border-include-table-headerfooter)
2. [Page border exclude header/footer](#page-border-exclude-headerfooter)
3. [Page border include header/footer](#page-border-include-headerfooter)
3. [Usage](#usage)
4. [Following Rules](#following-rules)
5. [Contributing](#contributing)
1. [How to contributing](#how-to-contributing)
6. [License](#license)
7. [Contact](#contact)
8. [Say Thank You](#say-thank-you)

## About The Project

Way to write border around page margin and header/footer.

It is often required in business scene.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Demo

### Page border include table header/footer

<img src="assets/page-bordering-example-table-header-footer.png" alt="Page border include table header/footer" width="50%" height="50%">

### Page border exclude header/footer

<img src="assets/page-bordering-example-normal-header-footer.png" alt="Page border exclude header/footer" width="50%" height="50%">

### Page border include header/footer

<img src="assets/page-bordering-example-normal-header-footer-border.png" alt="Page border include header/footer" width="50%" height="50%">

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Usage

This package provide a function: `page-bordering`.

import / setting script is shown below.

```typst
#import "@preview/page-bordering:1.0.0": page-bordering
#show: page-bordering.with(
margin: (left: 30pt, right: 30pt, top: 60pt, bottom: 60pt),
expand: 15pt,
space-top: 15pt,
space-bottom: 15pt,
stroke-header: none,
stroke-footer: none,
header: "",
footer: "",
)
```

`margin` is passed in `page()` function.

`margin` must to be dictionary include 4 direction.

`header` and `footer` is called outside of `page()`.

You can define like `#let header = [element]`, `#let header = {calls}`.

`stroke-header` and `stroke-footer` is used to config stroke border around header/footer.

`margin`, `space-top`, `space-bottom` and `expand` works like below.

![page-bordering-show-setting](assets/page-bordering-show-setting.png)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Following Rules

This repository follows below rules.

- [Github-Flow][github-flow-url]
- [Semantic Versioning][semver-url]

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Contributing

Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks!

### How to contributing

1. Fork the Project
2. Create your Feature Branch (`git checkout -b AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin AmazingFeature`)
5. Open a Pull Request

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## License

The source code is licensed MIT. See [LICENSE][license-url].

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Contact

- Shumpei-Tanaka
- [email protected]
- [S6T5: My Homepage][s6t5-url]

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## Say Thank You

If my works feels you helpful, I would be happy to have your support for me :D

links are below.

- [https://www.paypal.me/s6tanaka][Paypal-url]
- [https://www.buymeacoffee.com/s6tanaka][BuyMeACoffee-url]

[![Paypal][Paypal-shield]][Paypal-url][![BuyMeACoffee][BuyMeACoffee-sheild]][BuyMeACoffee-url]

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- Markdown Links & Images -->

[release-shield]: https://img.shields.io/github/v/release/Shumpei-Tanaka/typst-page-bordering?style=flat-square&sort=semver
[release-url]: https://github.com/Shumpei-Tanaka/typst-page-bordering/releases/latest
[license-shield]: https://img.shields.io/github/license/Shumpei-Tanaka/typst-page-bordering?flat-square
[license-url]: /LICENSE
[contributors-shield]: https://img.shields.io/github/contributors/Shumpei-Tanaka/typst-page-bordering.svg?style=flat-square
[contributors-url]: https://github.com/Shumpei-Tanaka/typst-page-bordering/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/Shumpei-Tanaka/typst-page-bordering.svg?style=flat-square
[forks-url]: https://github.com/Shumpei-Tanaka/typst-page-bordering/network/members
[stars-shield]: https://img.shields.io/github/stars/Shumpei-Tanaka/typst-page-bordering.svg?style=flat-square
[stars-url]: https://github.com/Shumpei-Tanaka/typst-page-bordering/stargazers
[issues-shield]: https://img.shields.io/github/issues/Shumpei-Tanaka/typst-page-bordering.svg?style=flat-square
[issues-url]: https://github.com/Shumpei-Tanaka/typst-page-bordering/issues
[Paypal-shield]: https://img.shields.io/badge/paypal.me-s6tanaka-white?style=flat-square&logo=paypal
[Paypal-url]: https://paypal.me/s6tanaka
[BuyMeACoffee-sheild]: https://img.shields.io/badge/buy_me_a_coffee-s6tanaka-white?style=flat-square&logo=buymeacoffee&logocolor=#FFDD00
[BuyMeACoffee-url]: https://www.buymeacoffee.com/s6tanaka
[github-flow-url]: https://docs.github.com/en/get-started/quickstart/github-flow
[semver-url]: https://semver.org/
[s6t5-url]: https://shumpei-tanaka.github.io/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions packages/preview/page-bordering/1.0.0/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
COMMAND := typst compile -f png --root .

OBJDIR := assets
SRCDIR := examples

SRCSUF := .typ
ADDSUF :=
TGTEXTSUF := .png
TGTSUF := $(ADDSUF)$(TGTEXTSUF)

SRCS := $(wildcard $(SRCDIR)/*$(SRCSUF))
TGTS := $(notdir $(SRCS:$(SRCSUF)=$(TGTSUF)))
TGTS := $(addprefix $(OBJDIR)/, $(TGTS))

TARGET := _TARGET

all: $(TARGET)

$(TARGET): $(TGTS)

$(TGTS): | $(OBJDIR)
$(OBJDIR):
mkdir -p $(OBJDIR)

$(OBJDIR)/%$(TGTSUF): $(SRCDIR)/%$(SRCSUF)
@echo Create $@ from $^
$(COMMAND) $^ $(@:$(TGTSUF)=$(TGTEXTSUF)) && oxipng $(@:$(TGTSUF)=$(TGTEXTSUF)) -o 4 --strip safe --alpha $(@:$(TGTSUF)=$(TGTEXTSUF))

.PHONY: clean
clean:
rm $(TGTS)
61 changes: 61 additions & 0 deletions packages/preview/page-bordering/1.0.0/src/page-bordering.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#let page-bordering(
margin: (left: 30pt, right: 30pt, top: 60pt, bottom: 60pt),
expand: 15pt,
space-top: 15pt,
space-bottom: 15pt,
stroke-header: none,
stroke-footer: none,
header: "",
footer: "",
body,
) = {
if not (
type(margin) == dictionary and "left" in margin and "right" in margin and "top" in margin and "bottom" in margin
) {
[`page-bordering` failed.

*Please set page-bordering(margin: ) as dictionary of 4 direction.*

e.g.
```
page-bordering(
margin: (left: 30pt, right: 30pt, top: 60pt, bottom: 60pt),
),
```
]
return
}
set page(margin: margin)

let (left: ml, right: mr, top: mt, bottom: mb) = margin
let insetL = ml - expand
let insetR = mr - expand
set page(
background: {
grid(
rows: (mt - expand, 100% - mt + expand * 2 - mb, mb - expand),
rect(
width: 100%,
height: 100%,
inset: (left: insetL, right: insetR, bottom: 0pt, top: space-top),
stroke: stroke-header,
outset: (left: -insetL, right: -insetR, top: -space-top),
)[
#header
],
rect(width: 100%, height: 100%, outset: (left: -insetL, right: -insetR)),
rect(
width: 100%,
height: 100%,
inset: (left: insetL, right: insetR, top: 0pt, bottom: space-bottom),
stroke: stroke-footer,
outset: (left: -insetL, right: -insetR, bottom: -space-bottom),
)[
#footer
],
)
},
)
body
}
83 changes: 83 additions & 0 deletions packages/preview/page-bordering/1.0.0/template/page-bordering.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

#let header = {
set align(bottom)
show table.cell.where(y: 0): set align(left)
set text(weight: "bold")
table(
stroke: (y: none),
columns: (0.8fr, 1.4fr, 0.8fr),
rows: 1fr,
table.hline(),
[Document ID], [Title], [page],
[PREFIX-12345678],
[Product Specification document],
[
#context counter(page).display(
"1 / 1",
both: true,
)
],
)
}

#let footer = {
set text(weight: "bold")
table(
stroke: (y: none),
columns: (0.8fr, 1.4fr, 0.8fr),
rows: 1fr,
[PREFIX-12345678],
[Product Specification document],
[
#context counter(page).display(
"1 / 1",
both: true,
)
],
table.hline(),
)
}
#import "@preview/page-bordering:1.0.0": page-bordering
#show: page-bordering.with(
margin: (left: 30pt, right: 30pt, top: 60pt, bottom: 60pt),
expand: 15pt,
space-top: 15pt,
space-bottom: 15pt,
stroke-header: none,
stroke-footer: none,
header: header,
footer: footer,
)

= Scope

This specification applies to a product.

= Model

Target is below.
- [type1]
- [type2]
- [type3]


= Document History
#table(
columns: (auto, auto, auto, 1fr),
[Version], [Date], [Author], [Modification],
[1.0.1],
[yyyy/mm/dd],
[Shumpei Tanaka],
[
- fix ~~~
- add aaa
],

[1.0.0],
[yyyy/mm/dd],
[Shumpei Tanaka],
[
- first vertion
],
)

17 changes: 17 additions & 0 deletions packages/preview/page-bordering/1.0.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "page-bordering"
version = "1.0.0"
entrypoint = "src/page-bordering.typ"
authors = ["Shumpei Tanaka"]
license = "MIT"
description = "Way to write border around page margin and header/footer."
homepage = "https://shumpei-tanaka.github.io/"
repository = "https://github.com/Shumpei-Tanaka/typst-page-bordering"
categories = ["layout", "office", "report"]
compiler = "0.12.0"
exclude = ["examples", "makefile", "assets"]

[template]
path = "template"
entrypoint = "page-bordering.typ"
thumbnail = "assets/page-bordering-example-table-header-footer.png"