-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee0dcd6
commit e41e8a5
Showing
10 changed files
with
376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-s6t5-page-bordering"> | ||
<img src="assets/s6t5-page-bordering-example-table-header-footer.png" alt="Logo" width="50%" height="50%"> | ||
</a> | ||
|
||
<h3 align="center">s6t5-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-s6t5-page-bordering/issues">Report Bug</a> | ||
· | ||
<a href="https://github.com/Shumpei-Tanaka/typst-s6t5-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/s6t5-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/s6t5-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/s6t5-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: `s6t5-page-bordering`. | ||
|
||
import / setting script is shown below. | ||
|
||
```typst | ||
#import "@preview/s6t5-page-bordering:1.0.0": s6t5-page-bordering | ||
#show: s6t5-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. | ||
|
||
![s6t5-page-bordering-show-setting](assets/s6t5-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-s6t5-page-bordering?style=flat-square&sort=semver | ||
[release-url]: https://github.com/Shumpei-Tanaka/typst-s6t5-page-bordering/releases/latest | ||
[license-shield]: https://img.shields.io/github/license/Shumpei-Tanaka/typst-s6t5-page-bordering?flat-square | ||
[license-url]: /LICENSE | ||
[contributors-shield]: https://img.shields.io/github/contributors/Shumpei-Tanaka/typst-s6t5-page-bordering.svg?style=flat-square | ||
[contributors-url]: https://github.com/Shumpei-Tanaka/typst-s6t5-page-bordering/graphs/contributors | ||
[forks-shield]: https://img.shields.io/github/forks/Shumpei-Tanaka/typst-s6t5-page-bordering.svg?style=flat-square | ||
[forks-url]: https://github.com/Shumpei-Tanaka/typst-s6t5-page-bordering/network/members | ||
[stars-shield]: https://img.shields.io/github/stars/Shumpei-Tanaka/typst-s6t5-page-bordering.svg?style=flat-square | ||
[stars-url]: https://github.com/Shumpei-Tanaka/typst-s6t5-page-bordering/stargazers | ||
[issues-shield]: https://img.shields.io/github/issues/Shumpei-Tanaka/typst-s6t5-page-bordering.svg?style=flat-square | ||
[issues-url]: https://github.com/Shumpei-Tanaka/typst-s6t5-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/ |
Binary file added
BIN
+30.5 KB
...dering/1.0.0/assets/s6t5-page-bordering-example-normal-header-footer-border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.4 KB
...age-bordering/1.0.0/assets/s6t5-page-bordering-example-normal-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.3 KB
...page-bordering/1.0.0/assets/s6t5-page-bordering-example-table-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24 KB
...s/preview/s6t5-page-bordering/1.0.0/assets/s6t5-page-bordering-show-setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
61
packages/preview/s6t5-page-bordering/1.0.0/src/s6t5-page-bordering.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
#let s6t5-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 | ||
) { | ||
[`s6t5-page-bordering` failed. | ||
|
||
*Please set s6t5-page-bordering(margin: ) as dictionary of 4 direction.* | ||
|
||
e.g. | ||
``` | ||
s6t5-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
83
packages/preview/s6t5-page-bordering/1.0.0/template/s6t5-page-bordering.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/s6t5-page-bordering:1.0.0": s6t5-page-bordering | ||
#show: s6t5-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 | ||
], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "s6t5-page-bordering" | ||
version = "1.0.0" | ||
entrypoint = "src/s6t5-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-s6t5-page-bordering" | ||
categories = ["layout", "office", "report"] | ||
compiler = "0.12.0" | ||
exclude = ["examples", "makefile", "assets"] | ||
|
||
[template] | ||
path = "template" | ||
entrypoint = "s6t5-page-bordering.typ" | ||
thumbnail = "assets/s6t5-page-bordering-example-table-header-footer.png" |