forked from typst/packages
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
1,018 changed files
with
96,308 additions
and
5 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
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
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,51 @@ | ||
name: Test PR | ||
on: | ||
pull_request: {} | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract package names and versions from changed files | ||
id: extract_package | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { data: files } = await github.rest.pulls.listFiles({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.payload.pull_request.number, | ||
}); | ||
const packages = new Set(); | ||
files.forEach(file => { | ||
const match = file.filename.match(/^packages\/preview\/([^\/]+)\/([^\/]+)\//); | ||
if (match) { | ||
packages.add(`${match[1]}/${match[2]}`); | ||
} | ||
}); | ||
let sparseCheckoutPaths; | ||
if (packages.size === 0) { | ||
sparseCheckoutPaths = "packages/"; | ||
} else { | ||
sparseCheckoutPaths = Array.from(packages).map(pkg => `packages/preview/${pkg}/`).join('\n'); | ||
} | ||
core.setOutput('sparse_checkout_paths', sparseCheckoutPaths); | ||
- uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
${{ steps.extract_package.outputs.sparse_checkout_paths }} | ||
bundler/ | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
workspaces: bundler | ||
|
||
- name: Build bundler | ||
run: cargo build --release --manifest-path bundler/Cargo.toml | ||
|
||
- name: Test packaging | ||
run: bundler/target/release/bundler |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Jonathan Halmen | ||
|
||
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,89 @@ | ||
# Abbr -- eviations made simple | ||
|
||
Short package for making the handling of abbreviations, acronyms, and | ||
initialisms _easy_. | ||
|
||
Declare your abbreviations anywhere, use everywhere -- they get picked up | ||
automatically. | ||
|
||
## Features | ||
- Automatic plurals, with optional overrides. | ||
- Automatic 1- or 2-column sorted list of abbreviations | ||
- Automatic links to list of abbreviations, if included. | ||
- styling configuration | ||
|
||
## Getting started | ||
|
||
```typst | ||
#import "@preview/abbr:0.1.0" | ||
#abbr.list() | ||
#abbr.make( | ||
("PDE", "Partial Differential Equation"), | ||
("BC", "Boundary Condition"), | ||
("DOF", "Degree of Freedom", "Degrees of Freedom"), | ||
) | ||
= Constrained Equations | ||
#abbr.pla[BC] constrain the #abbr.pla[DOF] of the #abbr.pla[PDE] they act on.\ | ||
#abbr.pla[BC] constrain the #abbr.pla[DOF] of the #abbr.pla[PDE] they act on. | ||
#abbr.add("MOL", "Method of Lines") | ||
The #abbr.a[MOL] is a procedure to solve #abbr.pla[PDE] in time. | ||
``` | ||
 | ||
|
||
|
||
## API Reference | ||
### Configuration | ||
- **style**`(func)`\ | ||
Set a callable for styling the short version in the text. | ||
|
||
### Creation | ||
- **add**`(short, long, long-plural)`\ | ||
Add single entry to use later.\ | ||
`long-plural` is *optional*, if not given but used, an `s` is appended to create a | ||
plural. | ||
|
||
- **make**`(list, of, entries)`\ | ||
Add multiple entries, each of the form `(short, long, long-plural)`. | ||
|
||
### Listing | ||
- **list**`(title)`\ | ||
Create an outline with all abbreviations in short and expanded form | ||
|
||
### Usage | ||
- **s**`()` - short\ | ||
force short form of abbreviation | ||
- **l**`()` - long\ | ||
force long form of abbreviation | ||
- **a**`()` - auto\ | ||
first occurence will be long form, the rest short | ||
- **pls**`()` - plural short\ | ||
plural short form | ||
- **pll**`()` - plural long\ | ||
plural long form | ||
- **pl**`()` - plural automatic\ | ||
plural. first occurence long form, then short | ||
|
||
|
||
## Why yet another Abbreviations package? | ||
|
||
This mostly exists because I started working on it before checking if somebody | ||
already made a package for it. After I saw that e.g. `acrotastic` exists, I kept | ||
convincing myself a new package still makes sense for the following reasons: | ||
* Getting to know Typst | ||
* More automatic handling than other packages | ||
* Ability to keep keys as [Content] instead of having to stringify everything | ||
|
||
Especially the last part seems to lower the friction of writing for me. It seems | ||
silly, I know. | ||
|
||
## Contributing | ||
|
||
Please head over to the [hub](https://sr.ht/~slowjo/typst-packages) to find the | ||
mailing list and ticket tracker. | ||
|
||
Or simply reach out on IRC ([#typst on | ||
libera.chat](https://web.libera.chat/gamja/?autojoin=#typst))! |
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,158 @@ | ||
|
||
#let stringify(text) = { | ||
if type(text) == str { | ||
return text | ||
} | ||
if "text" in text.fields() { | ||
return text.text | ||
} | ||
panic("Cannot stringify") | ||
} | ||
|
||
#let get(short) = { | ||
let key = stringify(short) | ||
let entry = state("abbr", (:)).get().at(key, default:none) | ||
return (key, entry) | ||
} | ||
|
||
#let warn(short) = [*(?? #short ??)*] | ||
|
||
#let style-default(short) = { | ||
let val = if text.weight <= "medium" { 15% } else { 30% } | ||
set text(fill: black.lighten(val)) | ||
show: strong | ||
short | ||
} | ||
|
||
#let incr(dct) = { | ||
dct.c+=1 | ||
state("abbr").update(it=>{ | ||
it.insert(dct.s, dct) | ||
return it | ||
}) | ||
} | ||
#let mark-used(dct) = { | ||
dct.list = true | ||
state("abbr").update(it=>{ | ||
it.insert(dct.s, dct) | ||
return it | ||
}) | ||
} | ||
|
||
/// add single entry | ||
#let add(short, ..entry) = context { | ||
let long = entry.at(0) | ||
let plural = entry.at(1, default:none) | ||
let (key, entry) = get(short) | ||
if entry == none { // do not update blindly, it'd reset the counter | ||
state("abbr").update(it => { | ||
let item = ( | ||
s: short, | ||
l: long, | ||
pl: plural, | ||
lbl: label(short + sym.hyph.point + long), | ||
c: 0, | ||
list: false, | ||
) | ||
it.insert(short, item) | ||
return it | ||
}) | ||
} | ||
} | ||
/// add list of entries | ||
#let make(..lst) = for (..abbr) in lst.pos() { add(..abbr) } | ||
|
||
/// short form of abbreviation with link | ||
#let s(short) = context { | ||
let dct = get(short).at(1) | ||
if dct == none { return warn(short) } | ||
mark-used(dct) | ||
let styleit = state("abbr-style", style-default).get() | ||
if query(dct.lbl).len() != 0 { | ||
link(dct.lbl, styleit(dct.s)) | ||
} else { | ||
styleit(dct.s) | ||
} | ||
} | ||
|
||
/// long form of abbreviation | ||
#let l(short) = context { | ||
let dct = get(short).at(1) | ||
if dct == none { return warn(short) } | ||
incr(dct) | ||
dct.l | ||
sym.paren.l | ||
sym.zwj | ||
s(dct.s) | ||
sym.zwj | ||
sym.paren.r | ||
} | ||
/// automatic short/long form | ||
#let a(short) = context { | ||
let (key, dct) = get(short) | ||
if dct == none { return warn(short); } | ||
if dct.c == 0 { l(key) } | ||
else { s(key) } | ||
} | ||
/// short form plural | ||
#let pls(short) = { | ||
let styleit = state("abbr-style", style-default).get() | ||
[#s(short)#styleit[s]] | ||
} | ||
/// long form plural | ||
#let pll(short) = context { | ||
let dct = get(short).at(1) | ||
if dct == none { return warn(short) } | ||
incr(dct) | ||
if dct.pl != none { | ||
dct.pl | ||
} else { | ||
[#dct.l\s] | ||
} | ||
sym.paren.l | ||
sym.zwj | ||
pls(dct.s) | ||
sym.zwj | ||
sym.paren.r | ||
} | ||
/// automatic short/long form plural | ||
#let pla(short) = context { | ||
let (key, dct) = get(short) | ||
if dct == none { return warn(short); } | ||
if dct.c == 0 { pll(key) } | ||
else { pls(key) } | ||
} | ||
/// create list of abbreviations | ||
#let list( | ||
title: [List of Abbreviations], | ||
columns: 2, | ||
) = context { | ||
let lst = state("abbr", (:)).final().values() | ||
.filter(it => it.list).sorted(key: it => it.s) | ||
if lst.len() == 0 { return } | ||
let styleit = state("abbr-style", style-default).get() | ||
let make-entry(it) = (styleit[#it.s #it.lbl], it.l) | ||
if columns == 2 { | ||
let n = int(lst.len()/2) | ||
let last = if calc.odd(lst.len()) {lst.remove(n)} | ||
lst = lst.slice(0, n).zip(lst.slice(n)).flatten() | ||
if last != none { lst.push(last) } | ||
} else if columns != 1 { | ||
panic("abbr.list only supports 1 or 2 columns") | ||
} | ||
heading(numbering: none, title) | ||
table( | ||
columns: (auto, 1fr)*columns, | ||
stroke:none, | ||
..for entry in lst { make-entry(entry) } | ||
) | ||
} | ||
/// configure styling of abbreviations | ||
#let style(func) = { | ||
state("abbr-style", style-default).update(it => { | ||
if func == auto { | ||
return style-default | ||
} | ||
return func | ||
}) | ||
} |
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,17 @@ | ||
#set page(height:auto, width: 16cm, margin: 1em) | ||
#import "@preview/abbr:0.1.0" | ||
|
||
#abbr.list() | ||
#abbr.make( | ||
("PDE", "Partial Differential Equation"), | ||
("BC", "Boundary Condition"), | ||
("DOF", "Degree of Freedom", "Degrees of Freedom"), | ||
) | ||
|
||
= Constrained Equations | ||
|
||
#abbr.pla[BC] constrain the #abbr.pla[DOF] of the #abbr.pla[PDE] they act on.\ | ||
#abbr.pla[BC] constrain the #abbr.pla[DOF] of the #abbr.pla[PDE] they act on. | ||
|
||
#abbr.add("MOL", "Method of Lines") | ||
The #abbr.a[MOL] is a procedure to solve #abbr.pla[PDE] in time. |
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,11 @@ | ||
[package] | ||
name = "abbr" | ||
version = "0.1.0" | ||
entrypoint = "abbr.typ" | ||
authors = ["Jonathan Halmen <slowjo@halmen.xyz>"] | ||
license = "MIT" | ||
description = "An Abbreviations package." | ||
repository = "https://git.sr.ht/~slowjo/typst-abbr" | ||
keywords = ["abbreviation", "acronym"] | ||
categories = ["model"] | ||
exclude = ["example.*"] |
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 @@ | ||
Oops, something went wrong.