Skip to content

Commit 58f75cb

Browse files
committed
update to 0.4.0
1 parent 459a58b commit 58f75cb

File tree

10 files changed

+169
-213
lines changed

10 files changed

+169
-213
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.github
22
/new
3-
/old
3+
/old
4+
/old_just

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [v0.4.0](https://github.com/maucejo/elsearticle/releases/tag/v0.4.0)
2+
3+
- Add equation sub-numbering based on the `equate` package
4+
15
# [v0.3.0](https://github.com/maucejo/elsearticle/releases/tag/v0.3.0)
26

37
- Add the `line-numbering` option to the `#elsearticle()` command

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Elsearticle template
22

3-
[![Generic badge](https://img.shields.io/badge/Version-0.3.0-cornflowerblue.svg)]()
3+
[![Generic badge](https://img.shields.io/badge/Version-0.4.0-cornflowerblue.svg)]()
44
[![MIT License](https://img.shields.io/badge/License-MIT-forestgreen)](https://github.com/maucejo/elsearticle/blob/main/LICENSE)
55
[![User Manual](https://img.shields.io/badge/doc-.pdf-mediumpurple)](https://github.com/maucejo/elsearticle/blob/main/docs/manual.pdf)
66

@@ -13,7 +13,7 @@ This section provides the minimal amount of information to get started with the
1313
To use the `elsearticle` template, you need to include the following line at the beginning of your `typ` file:
1414

1515
```typ
16-
#import "@preview/elsearticle:0.3.0": *
16+
#import "@preview/elsearticle:0.4.0": *
1717
```
1818

1919
### Initializing the template
@@ -87,7 +87,7 @@ The `elsearticle` template provides the `#nonumeq()` function to create unnmbere
8787
*Equations*
8888

8989
- [x] Proper referencing of equations w.r.t. the context
90-
- [ ] Numbering each equation of a system as "(1a)" -- _On going discussions at the Typst dev level_
90+
- [x] Use of the `equate` package to number each equation of a system as "(1a)"
9191

9292
*Other features*
9393

justfile

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
1-
root := justfile_directory()
2-
3-
export TYPST_ROOT := root
4-
5-
[private]
6-
default:
7-
@just --list --unsorted
8-
9-
# generate manual
10-
doc:
11-
typst compile docs/manual.typ docs/manual.pdf
12-
13-
# run test suite
14-
test *args:
15-
typst-test run {{ args }}
16-
17-
# update test cases
18-
update *args:
19-
typst-test update {{ args }}
20-
21-
# package the library into the specified destination folder
22-
package target:
23-
./scripts/package "{{target}}"
24-
25-
# install the library with the "@local" prefix
26-
install: (package "@local")
27-
28-
# install the library with the "@preview" prefix (for pre-release testing)
29-
install-preview: (package "@preview")
30-
31-
[private]
32-
remove target:
33-
./scripts/uninstall "{{target}}"
34-
35-
# uninstalls the library from the "@local" prefix
36-
uninstall: (remove "@local")
37-
38-
# uninstalls the library from the "@preview" prefix (for pre-release testing)
39-
uninstall-preview: (remove "@preview")
40-
41-
# Create and shrink thumbnails
42-
thumbnails:
43-
typst c template/main.typ thumbnails/{n}.png --root ./ --font-path ./
44-
oxipng -o 4 --strip safe --alpha thumbnails/*.png
45-
46-
example:
47-
typst c template/main.typ example.pdf --root ./ --font-path ./
48-
49-
# run ci suite
50-
ci: test doc thumbnails example
1+
package target:
2+
./scripts/package "{{target}}"
3+
4+
install:
5+
./scripts/package "@local"
6+
7+
install-preview:
8+
./scripts/package "@preview"
9+
10+
# uninstalls the library from the "@local" prefix
11+
uninstall:
12+
./scripts/uninstall "@local"
13+
14+
# uninstalls the library from the "@preview" prefix (for pre-release testing)
15+
uninstall-preview:
16+
./scripts/uninstall "@preview"
17+
18+
thumbnails:
19+
typst c template/main.typ thumbnails/{n}.png --root ./ --font-path ./
20+
oxipng -o 4 --strip safe --alpha thumbnails/*.png

scripts/package

Lines changed: 72 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,72 @@
1-
#!/usr/bin/env bash
2-
set -eu
3-
4-
# adapted from https://github.com/johannes-wolf/cetz/blob/35c0868378cea5ad323cc0d9c2f76de8ed9ba5bd/scripts/package
5-
# licensed under Apache License 2.0
6-
7-
. "$(dirname "${BASH_SOURCE[0]}")/setup"
8-
9-
if (( $# < 1 )) || [[ "${1:-}" == "help" ]]; then
10-
echo "package TARGET"
11-
echo ""
12-
echo "Packages all relevant files into a directory named '<name>/<version>'"
13-
echo "at TARGET. If TARGET is set to @local or @preview, the local Typst package"
14-
echo "directory will be used so that the package gets installed for local use."
15-
echo "The name and version are read from 'typst.toml' in the project root."
16-
echo ""
17-
echo "Local package prefix: $DATA_DIR/typst/package/local"
18-
echo "Local preview package prefix: $DATA_DIR/typst/package/preview"
19-
exit 1
20-
fi
21-
22-
TARGET="$(resolve-target "${1:?Missing target path, @local or @preview}")"
23-
echo "Install dir: $TARGET"
24-
25-
# ignore rules
26-
readarray -t ignores < <(grep -v '^#' .typstignore | grep '[^[:blank:]]')
27-
28-
# recursively print all files that are not excluded via .typstignore
29-
function enumerate {
30-
local root="$1"
31-
if [[ -f "$root" ]]; then
32-
echo "$root"
33-
else
34-
local files
35-
readarray -t files < <(find "$root" \
36-
-mindepth 1 -maxdepth 1 \
37-
-not -name .git \
38-
-not -name .typstignore)
39-
# declare -p files >&2
40-
41-
local f
42-
for f in "${files[@]}"; do
43-
local include
44-
include=1
45-
46-
local ignore
47-
for ignore in "${ignores[@]}"; do
48-
if [[ "$ignore" =~ ^! ]]; then
49-
ignore="${ignore:1}"
50-
if [[ "$f" == ./$ignore ]]; then
51-
# echo "\"$f\" matched \"!$ignore\"" >&2
52-
include=1
53-
fi
54-
elif [[ "$f" == ./$ignore ]]; then
55-
# echo "\"$f\" matched \"$ignore\"" >&2
56-
include=0
57-
fi
58-
done
59-
if [[ "$include" == 1 ]]; then
60-
enumerate "$f"
61-
fi
62-
done
63-
fi
64-
}
65-
66-
# List of all files that get packaged
67-
readarray -t files < <(enumerate ".")
68-
# declare -p files >&2
69-
70-
TMP="$(mktemp -d)"
71-
72-
for f in "${files[@]}"; do
73-
mkdir -p "$TMP/$(dirname "$f")" 2>/dev/null
74-
cp -r "$ROOT/$f" "$TMP/$f"
75-
done
76-
77-
TARGET="${TARGET:?}/${PKG_PREFIX:?}/${VERSION:?}"
78-
echo "Packaged to: $TARGET"
79-
if rm -r "${TARGET:?}" 2>/dev/null; then
80-
echo "Overwriting existing version."
81-
fi
82-
mkdir -p "$TARGET"
83-
84-
# include hidden files by setting dotglob
85-
shopt -s dotglob
86-
mv "$TMP"/* "$TARGET"
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
function read-toml() {
5+
local file="$1"
6+
local key="$2"
7+
# Read a key value pair in the format: <key> = "<value>"
8+
# stripping surrounding quotes.
9+
perl -lne "print \"\$1\" if /^${key}\\s*=\\s*\"(.*)\"/" < "$file"
10+
}
11+
12+
SOURCE="$(cd "$(dirname "$0")"; pwd -P)/.." # macOS has no realpath
13+
TARGET="${1:?Missing target path or @local}"
14+
VERSION="$(read-toml "$SOURCE/typst.toml" "version")"
15+
PKG_PREFIX="$(read-toml "$SOURCE/typst.toml" "name")"
16+
17+
# List of all files that get packaged
18+
files=(
19+
src/
20+
template/
21+
typst.toml
22+
LICENSE
23+
README.md
24+
docs/manual.typ
25+
docs/manual.pdf
26+
)
27+
28+
# Local package directories per platform
29+
if [[ "$OSTYPE" == "linux"* ]]; then
30+
DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}"
31+
elif [[ "$OSTYPE" == "darwin"* ]]; then
32+
DATA_DIR="$HOME/Library/Application Support"
33+
else
34+
DATA_DIR="${APPDATA}"
35+
fi
36+
37+
if (( $# < 1 )) || [[ "${1:-}" == "help" ]]; then
38+
echo "package TARGET"
39+
echo ""
40+
echo "Packages all relevant files into a directory named '${PKG_PREFIX}/<version>'"
41+
echo "at TARGET. If TARGET is set to @local, the local Typst package directory"
42+
echo "will be used so that the package gets installed for local use."
43+
echo "The version is read from 'typst.toml' in the project root."
44+
echo ""
45+
echo "Local package prefix: $DATA_DIR/typst/package/local"
46+
exit 1
47+
fi
48+
49+
if [[ "$TARGET" == "@local" ]] || [[ "$TARGET" == "install" ]]; then
50+
TARGET="${DATA_DIR}/typst/packages/local/"
51+
echo "Install dir: $TARGET"
52+
fi
53+
54+
if [[ "$TARGET" == "@preview" ]] || [[ "$TARGET" == "install-preview" ]]; then
55+
TARGET="${DATA_DIR}/typst/packages/preview/"
56+
echo "Install dir: $TARGET"
57+
fi
58+
59+
TMP="$(mktemp -d)"
60+
61+
for f in "${files[@]}"; do
62+
mkdir -p "$TMP/$(dirname "$f")" 2>/dev/null
63+
cp -r "$SOURCE/$f" "$TMP/$f"
64+
done
65+
66+
TARGET="${TARGET:?}/${PKG_PREFIX:?}/${VERSION:?}"
67+
echo "Packaged to: $TARGET"
68+
if rm -rf "${TARGET:?}" 2>/dev/null; then
69+
echo "Overwriting existing version."
70+
fi
71+
mkdir -p "$TARGET"
72+
mv "$TMP"/* "$TARGET"

scripts/setup

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)