Compare commits

..

No commits in common. "main" and "v0.4.0" have entirely different histories.
main ... v0.4.0

25 changed files with 800 additions and 390 deletions

View File

@ -5,16 +5,15 @@ on: [push]
jobs:
run-ci-linux:
runs-on: ubuntu-latest
env:
TYPST_INSTALL: /usr/local
TYPST_VERSION: 0.11.1
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies for Nix setup action
run: |
apt update -y
apt install sudo -y
- name: Setup Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Install Typst CLI
run: curl -fsSL https://typst.community/typst-install/install.sh | sh -s "$TYPST_VERSION"
- name: Set up Python 3
run: apt update -y && apt install python3-pip -y
- name: Run CI
run: nix-shell --run ./run-ci.sh
run: bash -c ./run-ci.sh

View File

@ -1,31 +1,28 @@
name: release
on:
on:
push:
tags:
- 'v*.*.*'
- '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install dependencies for Nix setup action
run: |
apt update -y
apt install sudo -y
- name: Setup Nix
uses: cachix/install-nix-action@v27
- uses: actions/checkout@v3
with:
nix_path: nixpkgs=channel:nixos-unstable
fetch-depth: 0
- name: Install Typst CLI
run: curl -fsSL https://typst.community/typst-install/install.sh | sh -s "$TYPST_VERSION"
- name: Set up Python 3
run: apt update -y && apt install python3-pip -y
- name: Run CI
run: nix-shell --run ./run-ci.sh
run: bash -c ./run-ci.sh
- name: Setup go
uses: https://github.com/actions/setup-go@v4
with:
go-version: '>=1.20.1'
- name: Create release
- name: Create release
id: create-release
uses: https://gitea.com/actions/release-action@main
with:

View File

@ -5,12 +5,16 @@ on: [push]
jobs:
run-ci-linux:
runs-on: ubuntu-latest
env:
TYPST_INSTALL: $HOME/.typst
TYPST_VERSION: 0.11.1
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Nix
uses: cachix/install-nix-action@v27
- name: Install Typst CLI
run: curl -fsSL https://typst.community/typst-install/install.sh | sh -s "$TYPST_VERSION"
- uses: actions/setup-python@v5
with:
nix_path: nixpkgs=channel:nixos-unstable
python-version: '3.11'
- name: Run CI
run: nix-shell --run ./run-ci.sh
run: export PATH="$TYPST_INSTALL/bin:$PATH" && bash -c ./run-ci.sh

View File

@ -1,30 +1,32 @@
name: release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*.*.*'
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
release:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Nix
uses: cachix/install-nix-action@v27
- name: Install Typst CLI
run: curl -fsSL https://typst.community/typst-install/install.sh | sh -s "$TYPST_VERSION"
- uses: actions/setup-python@v5
with:
nix_path: nixpkgs=channel:nixos-unstable
python-version: '3.11'
- name: Run CI
run: nix-shell --run ./run-ci.sh
- name: Setup go
uses: https://github.com/actions/setup-go@v4
run: export PATH="$TYPST_INSTALL/bin:$PATH" && bash -c ./run-ci.sh
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
go-version: '>=1.20.1'
- name: Create release
id: create-release
uses: https://gitea.com/actions/release-action@main
with:
files: |-
example.pdf
api_key: '${{secrets.RELEASE_TOKEN}}'
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

20
base16/abb.yml Normal file
View File

@ -0,0 +1,20 @@
# Base16 ABB branded color scheme
scheme-author: "Sven Vogel"
scheme-slug: "abb-base16"
scheme-name: "ABB Base16"
base00: "ffffff" # Default Background
base01: "fafafa" # Lighter Background
base02: "f0f0f0" # Selection Background
base03: "6e6e6e" # Comments, Invisibles, Line Highlighting
base04: "000000" # Dark Foreground
base05: "000000" # Default Foreground, Caret, Delimiters, Operators
base06: "fafafa" # Light Foreground (Not often used)
base07: "fafafa" # Light Background (Not often used)
base08: "262626" # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted
base09: "004c97" # Integers, Boolean, Constants, XML Attributes, Markup Link Url
base0A: "ff000f" # Classes, Markup Bold, Search Text Background
base0B: "004c97" # Strings, Inherited Class, Markup Code, Diff Inserted
base0C: "262626" # Support, Regular Expressions, Escape Characters, Markup Quotes
base0D: "007a33" # Functions, Methods, Attribute IDs, Headings
base0E: "ff000f" # Keywords, Storage, Selector, Markup Italic, Diff Changed
base0F: "6e6e6e" # Deprecated, Opening/Closing Embedded Language Tags

30
base16/generator.py Normal file
View File

@ -0,0 +1,30 @@
import yaml
import logging
import sys
import re
global data
def replace_tag(match):
return data[match.group(1)]
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
with open(sys.argv[1], 'r') as file:
data = yaml.safe_load(file)
content = ""
with open(sys.argv[2], "r") as file:
logger.info(f"opened file: {sys.argv[2]}")
content = file.read()
logger.info(f"read file: {sys.argv[2]}")
logger.info(f"converting...")
content = re.sub("\\{\\{([a-z0-9-]+)\\}\\}", replace_tag, content, 0, re.IGNORECASE)
with open(sys.argv[3], "w") as file:
logger.info(f"writing changes...")
file.write(content)

1
base16/requirements.txt Normal file
View File

@ -0,0 +1 @@
pyyaml

561
base16/template.tmTheme Normal file
View File

@ -0,0 +1,561 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Template: Chris Kempson, Scheme: {{scheme-author}}</string>
<key>name</key>
<string>Base16 {{scheme-name}}</string>
<key>semanticClass</key>
<string>theme.base16.{{scheme-slug}}</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>gutterSettings</key>
<dict>
<key>background</key>
<string>#{{base01}}</string>
<key>divider</key>
<string>#{{base01}}</string>
<key>foreground</key>
<string>#{{base03}}</string>
<key>selectionBackground</key>
<string>#{{base02}}</string>
<key>selectionForeground</key>
<string>#{{base04}}</string>
</dict>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base00}}</string>
<key>caret</key>
<string>#{{base05}}</string>
<key>foreground</key>
<string>#{{base05}}</string>
<key>invisibles</key>
<string>#{{base03}}</string>
<key>lineHighlight</key>
<string>#{{base03}}55</string>
<key>selection</key>
<string>#{{base02}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base05}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base03}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base05}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base05}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base05}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base08}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
<key>scope</key>
<string>entity.name.function, meta.require, support.function.any-method, variable.function, variable.annotation, support.macro</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0D}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Labels</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0F}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>support.class, entity.name.class, entity.name.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0A}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base07}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
<key>scope</key>
<string>keyword.other.special-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0D}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0C}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Strings, Inherited Class</string>
<key>scope</key>
<string>string, constant.other.symbol, entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0B}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Integers</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Floats</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constants</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tags</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base08}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attribute IDs</string>
<key>scope</key>
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0D}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Selector</string>
<key>scope</key>
<string>meta.selector</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Headings</string>
<key>scope</key>
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#{{base0D}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Units</string>
<key>scope</key>
<string>keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>scope</key>
<string>markup.bold, punctuation.definition.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#{{base0A}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Italic</string>
<key>scope</key>
<string>markup.italic, punctuation.definition.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Code</string>
<key>scope</key>
<string>markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0B}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Text</string>
<key>scope</key>
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base08}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Url</string>
<key>scope</key>
<string>meta.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Lists</string>
<key>scope</key>
<string>markup.list</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base08}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Quotes</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base09}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Separator</string>
<key>scope</key>
<string>meta.separator</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base02}}</string>
<key>foreground</key>
<string>#{{base05}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0B}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base08}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Colors</string>
<key>scope</key>
<string>constant.other.color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0C}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0C}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape Characters</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0C}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded</string>
<key>scope</key>
<string>punctuation.section.embedded, variable.interpolation</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#{{base0E}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base08}}</string>
<key>foreground</key>
<string>#{{base07}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Broken</string>
<key>scope</key>
<string>invalid.broken</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base09}}</string>
<key>foreground</key>
<string>#{{base00}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base0F}}</string>
<key>foreground</key>
<string>#{{base07}}</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Unimplemented</string>
<key>scope</key>
<string>invalid.unimplemented</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#{{base03}}</string>
<key>foreground</key>
<string>#{{base07}}</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>

0
generate-theme.sh Executable file → Normal file
View File

View File

@ -25,29 +25,19 @@ function enter-section() {
printf "\\n"
eval "$2"
exit_status=$?
if [ "$3" == "should fail" ]; then
log "INFO" "expected to fail..."
if [ $exit_status -eq 0 ]; then
abort "command: $2 failed in section: $1 with: $exit_status"
fi
else
log "INFO" "expected to pass..."
if [ ! $exit_status -eq 0 ]; then
abort "command: $2 failed in section: $1 with: $exit_status"
fi
if [ $? -neq $3 ]; then
abort "command: $2 failed in section: $1"
fi
printf "\\n"
log "INFO" "section $1 completed successfully"
}
enter-section "Typstyle checking" "./run-fmt.sh --check src/lib.typ" 0
enter-section "Compiling template..." "typst compile template/main.typ --root . example.pdf"
enter-section "TEST: local template import" "typst compile tests/local-import/main.typ --root ."
enter-section "TEST: invalid config case 1" "typst compile tests/invalid-config/test-case-1.typ --root ." "should fail"
enter-section "TEST: invalid config case 2" "typst compile tests/invalid-config/test-case-2.typ --root ."
enter-section "TEST: invalid config case 3" "typst compile tests/invalid-config/test-case-3.typ --root ." "should fail"
enter-section "BUILD: ABB code theme" "./generate-theme.sh" 0
enter-section "Compiling template..." "typst compile template/main.typ --root . example.pdf" 0
enter-section "TEST: local template import" "typst compile tests/local-import/main.typ --root ." 0
enter-section "TEST: invalid config case 1" "typst compile tests/invalid-config/test-case-1.typ --root ." 1
enter-section "TEST: invalid config case 2" "compile tests/invalid-config/test-case-2.typ" 0
enter-section "TEST: invalid config case 3" "typst compile tests/invalid-config/test-case-3.typ --root ." 1
log "INFO" "CI completed successfully"

View File

@ -1,42 +0,0 @@
#!/bin/bash
function format() {
# format file
# typstyle --format $1
if [ -z "$1" ]; then
return
fi
local wd=$(dirname $(realpath "$1"))
echo "processing file $1..."
typstyle "$2" "$1" > /dev/null
if [ $? -eq 1 ]; then
echo "failed format validation: $1"
exit 1
fi
local imports=$(rg "#import \"([a-z0-9/\-]+\.typ)\"" -Nor '$1' "$1")
# format all included files
while IFS= read -r line; do
if [ -z "$line" ]; then
continue
fi
format "$wd/$line" "$2"
done <<< "$imports"
}
case $1 in
"--format")
format "$2" "--inplace"
;;
"--check")
format "$2" "--check"
;;
*)
echo "unknown option: $1"
exit 1
;;
esac

View File

@ -1,13 +0,0 @@
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.mkShellNoCC {
packages = with pkgs; [
python312
python312Packages.pyyaml
typst
typstyle
];
}

View File

@ -30,10 +30,7 @@ SOFTWARE.*/
#let __query_labels_with_key(loc, key, before: false) = {
if before {
query(
selector(label(__glossary_label_prefix + key)).before(
loc,
inclusive: false,
),
selector(label(__glossary_label_prefix + key)).before(loc, inclusive: false),
loc,
)
} else {
@ -59,18 +56,13 @@ SOFTWARE.*/
let entlong = entry.at("long", default: "")
let textLink = if display != none {
[#display]
} else if (
is_first or long == true
) and entlong != [] and entlong != "" and long != false {
} else if (is_first or long == true) and entlong != [] and entlong != "" and long != false {
[#entlong (#entry.short#suffix)]
} else {
[#entry.short#suffix]
}
[#link(
label(entry.key),
textLink,
)#label(__glossary_label_prefix + entry.key)]
[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else {
panic(__not-found-panic-error-msg(key))
}
@ -108,18 +100,13 @@ SOFTWARE.*/
[#entplural]
}
let textLink = if (
is_first or long == true
) and entlong != [] and entlong != "" and long != false {
let textLink = if (is_first or long == true) and entlong != [] and entlong != "" and long != false {
[#entlong (#short)]
} else {
[#short]
}
[#link(
label(entry.key),
textLink,
)#label(__glossary_label_prefix + entry.key)]
[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else {
panic(__not-found-panic-error-msg(key))
}
@ -129,9 +116,7 @@ SOFTWARE.*/
// show rule to make the references for glossarium
#let make-glossary(body) = {
show ref: r => {
if r.element != none and r.element.func() == figure and r
.element
.kind == __glossarium_figure {
if r.element != none and r.element.func() == figure and r.element.kind == __glossarium_figure {
// call to the general citing function
gls(str(r.target), suffix: r.citation.supplement)
} else {
@ -185,13 +170,7 @@ SOFTWARE.*/
numbering: none,
caption: {
context {
let key = if entry.key.ends-with("__glossary_entry") {
entry.key.replace("__glossary_entry", "")
} else {
entry.key
}
let term_references = __query_labels_with_key(here(), key)
let term_references = __query_labels_with_key(here(), entry.key)
if term_references.len() != 0 or show-all [
#let desc = entry.at("desc", default: "")
#let long = entry.at("long", default: "")
@ -199,15 +178,12 @@ SOFTWARE.*/
#let hasDesc = desc != "" and desc != []
#block(
below: 1.5em,
par(hanging-indent: 1em)[
#text(weight: "bold", entry.short)
#if hasLong and hasDesc [
(#text(entry.long))
] else if hasLong {
#if hasLong {
text(entry.long)
}
#if hasDesc [ #sym.dash.en ]
#if hasLong and hasDesc [:]
#if hasDesc [ #desc ]
#if disable-back-references != true {
term_references
@ -215,9 +191,7 @@ SOFTWARE.*/
.sorted(key: x => x.page())
.fold(
(values: (), pages: ()),
((values, pages), x) => if pages.contains(
x.page(),
) {
((values, pages), x) => if pages.contains(x.page()) {
(values: values, pages: pages)
} else {
values.push(x)
@ -231,10 +205,7 @@ SOFTWARE.*/
if page-numbering == none {
page-numbering = "1"
}
link(x)[#numbering(
page-numbering,
..counter(page).at(x),
)]
link(x)[#numbering(page-numbering, ..counter(page).at(x))]
}
)
.join(", ")

View File

@ -7,7 +7,7 @@
// Edited: 08.07.2024
// License: MIT
#let glossary(entries, config) = {
#let glossary(entries) = {
assert(
type(entries) == dictionary,
@ -54,13 +54,13 @@
message: "The optional group of glossary entry `" + k + "` is not a string",
)
} else {
let acronym_group = if config.lang == "de" {
"Abkürzungsverzeichnis"
let acronym_group = if (context text.lang) == "de" {
"Akronyme"
} else {
"List of Acronyms"
"Acronyms"
}
let glossary_group = if config.lang == "de" {
let glossary_group = if (context text.lang) == "de" {
"Begriffe"
} else {
"Glossary"
@ -75,14 +75,8 @@
// create dedicated entries for
// acronym and glossary
if "long" in v and "desc" in v {
processed_glossary.insert(
k,
(short: v.short, long: v.long, group: acronym_group),
)
processed_glossary.insert(
k + "__glossary_entry",
(short: v.short, desc: v.desc, long: v.long, group: glossary_group),
)
processed_glossary.insert(k, (short: v.short, long: v.long, group: acronym_group))
processed_glossary.insert(k + "__glossary_entry", (short: v.short, desc: v.desc, group: glossary_group))
} else {
processed_glossary.insert(k, v)
processed_glossary.at(k).group = group

View File

@ -31,13 +31,7 @@
inset: (left: 2pt, right: 2pt),
outset: (top: 4pt, bottom: 4pt),
fill: ABB-GRAY-06,
[#box(
fill: rgb(color),
radius: 2pt,
inset: 0pt,
width: 0.75em,
height: 0.75em,
) #text(
[#box(fill: rgb(color), radius: 2pt, inset: 0pt, width: 0.75em, height: 0.75em) #text(
font: default-config.style.code.font,
size: default-config.style.code.size,
content,
@ -46,17 +40,7 @@
}
#let url(label, content) = {
link(label)[#underline(
offset: 2pt,
stroke: 0.5pt + blue,
text(fill: blue)[
#content
#let domain = label.find(regex("\w+\.\w+(?:\.\w+)*"))
#if domain.len() > 0 [
(#domain)
]
],
)]
link(label)[#underline(offset: 2pt, stroke: 0.5pt + blue, text(fill: blue, content))]
}
// start of template pages and styles
@ -103,10 +87,10 @@
#if "glossary" in config.thesis and config.thesis.glossary != none {
print-glossary(
show-all: false,
show-all: true,
disable-back-references: true,
enable-group-pagebreak: true,
glossary(config.thesis.glossary, config),
glossary(config.thesis.glossary),
)
pagebreak(weak: true)

View File

@ -15,13 +15,13 @@
let author = config.author
if text.lang == "de" [
#heading(level: 1, "Sperrvermerk")
#heading(level: 1, "Sperrvermerk", supplement: [special])
] else if text.lang == "en" [
#heading(level: 1, "Confidentiality Statement")
#heading(level: 1, "Confidentiality Statement", supplement: [special])
]
if text.lang == "de" [
Der Inhalt dieser Arbeit mit dem Thema
Der Inhalt der dieser Arbeit mit dem Thema
] else if text.lang == "en" [
The content of this work with the topic
]
@ -43,11 +43,11 @@
set par(justify: true)
if text.lang == "de" [
darf weder als Ganzes noch in Auszügen Personen außerhalb des Prüfungsprozesses und des Evaluationsverfahrens zugänglich gemacht werden, sofern keine anderslautende Genehmigung der Ausbildungsstätte vorliegt.
] else if text.lang == "en" [
may not be made accessible to persons outside the examination process and the evaluation procedure, either as a whole or in excerpts, unless otherwise authorized by the training institution.
]
if text.lang == "de" [
darf weder als Ganzes noch in Auszügen Personen außerhalb des Prüfungsprozesses und des Evaluationsverfahrens zugänglich gemacht werden, sofern keine anderslautende Genehmigung der Ausbildungsstätte vorliegt.
] else if text.lang == "en" [
may not be made accessible to persons outside the examination process and the evaluation procedure, either as a whole or in excerpts, unless otherwise authorized by the training institution.
]
set align(horizon)

View File

@ -16,15 +16,6 @@
let elems = query(figure.where(kind: kind), here())
let count = elems.len()
show outline.entry: it => {
link(it.element.location())[
#v(12pt, weak: true)
#text(weight: "regular", it.body)
#box(width: 1fr, it.fill)
#[ #it.page]
]
}
// only show outline if there is something to list
if count > 0 {
pagebreak(weak: true)
@ -80,15 +71,9 @@
"Table of Contents"
}
let header-supplement = if (text.lang == "de") {
"Kapitel"
} else {
"chapter"
}
pagebreak(weak: true)
outline(
target: heading.where(supplement: [#header-supplement]),
target: heading.where(supplement: [chapter]),
title: title,
indent: auto,
)

View File

@ -16,8 +16,7 @@
// title
#v(2cm)
#set par(justify: false)
#text(size: 2em, weight: "semibold", hyphenate: false, thesis.title)
#text(size: 2em, weight: "semibold", thesis.title)
// subtitle
#text(size: 1.5em, thesis.subtitle)
@ -64,9 +63,7 @@
stroke: none,
[*Verfasser:*], author.name,
[*Bearbeitungszeitraum:*], thesis.timeframe,
[*Matrikelnummer, Kurs:*],
str(author.matriculation-number) + ", " + author.course,
[*Matrikelnummer, Kurs:*], str(author.matriculation-number) + ", " + author.course,
[*Ausbildungsbetrieb:*], author.company,
[*Betrieblicher Betreuer:*], author.supervisor,
[*Abgabedatum:*], thesis.submission-date,
@ -79,9 +76,7 @@
stroke: none,
[*Author:*], author.name,
[*Editing period:*], thesis.timeframe,
[*Matriculation number, course:*],
str(author.matriculation-number) + ", " + author.course,
[*Matriculation number, course:*], str(author.matriculation-number) + ", " + author.course,
[*Training company:*], author.company,
[*Company supervisor:*], author.supervisor,
[*Submission date:*], thesis.submission-date,

View File

@ -12,13 +12,7 @@
#let watermark-color = luma(50%).transparentize(70%)
#let watermark-pattern = pattern(size: (5pt, 5pt))[
#place(
line(
start: (50%, 0%),
end: (50%, 100%),
stroke: (paint: watermark-color, thickness: 3pt),
),
)
#place(line(start: (50%, 0%), end: (50%, 100%), stroke: (paint: watermark-color, thickness: 3pt)))
]
#let watermark(config) = if config.draft {
@ -35,10 +29,7 @@
#linebreak()
document version.
#linebreak()
#text(
size: 0.75em,
"Further usage without the authors consent is not permitted.",
)]]]
#text(size: 0.75em, "Further usage without the authors consent is not permitted.")]]]
}
#let numberingH(c) = {
@ -78,13 +69,7 @@
weight: "semibold",
)
let header-supplement = if config.lang == "de" {
"Kapitel"
} else {
"chapter"
}
set heading(supplement: [#header-supplement])
set heading(supplement: [chapter])
set math.equation(numbering: "(1)")
@ -126,51 +111,37 @@
e => {
let (i, l) = e
let n = i + 1
let n_str = if (calc.rem(n, 1) == 0) or (true and i == 0) {
text(
font: style.code.font,
size: style.code.size,
fill: ABB-BLACK,
str(n),
)
} else {
none
}
let n_str = if (calc.rem(n, 1) == 0) or (true and i == 0) { text(font: style.code.font, size: style.code.size, fill: ABB-BLACK, str(n)) } else { none }
(n_str + h(0.5em), raw(block: true, lang: lang, l))
},
)
} else {
(
(1fr,),
(left,),
e => {
let (i, l) = e
raw(block: true, lang: lang, l)
},
)
})
}
else {
( ( 1fr, ),
( left, ),
e => {
let (i, l) = e
raw(block: true, lang: lang, l)
}
)
}
}
}
grid(
stroke: none,
columns: columns,
rows: (auto,),
gutter: 0pt,
inset: 0.25em,
align: (col, _) => align.at(col),
fill: ABB-GRAY-06,
..content
.text
.split("\n")
.enumerate()
.map(make_row)
.flatten()
.map(c => if c.has("text") and c.text == "" {
v(1em)
} else {
c
})
)
},
grid(
stroke: none,
columns: columns,
rows: (auto,),
gutter: 0pt,
inset: 0.25em,
align: (col, _) => align.at(col),
fill: ABB-GRAY-06,
..content
.text
.split("\n")
.enumerate()
.map(make_row)
.flatten()
.map(c => if c.has("text") and c.text == "" { v(1em) } else { c })
)
}
)
#v(-1em)
#align(center + top, it.caption)
@ -207,20 +178,8 @@
stroke: (x, y) => (
left: none,
right: none,
top: if y == 0 {
1.5pt
} else if y < 2 {
1pt
} else {
0.5pt
},
bottom: if y == 0 {
1pt
} else {
1.5pt
},
),
)
top: if y == 0 { 1.5pt } else if y < 2 { 1pt } else { 0.5pt },
bottom: if y == 0 { 1pt } else { 1.5pt } ))
// make table header bold
show table.cell.where(y: 0): set text(weight: "bold")
@ -229,8 +188,7 @@
set par(
justify: true,
first-line-indent: 1em,
leading: 1em,
)
leading: 1em)
// give links a color
show link: set text(fill: style.link.color)
@ -243,26 +201,17 @@
header-ascent: style.header.content-padding,
footer-descent: style.header.content-padding,
margin: (
top: style.page.margin.top + style.header.underline-top-padding + style
.header
.content-padding,
top: style.page.margin.top + style.header.underline-top-padding + style.header.content-padding,
bottom: style.page.margin.bottom + style.footer.content-padding,
left: style.page.margin.left,
right: style.page.margin.right,
),
right: style.page.margin.right),
numbering: (..nums) => {
let current-page = here().page()
if current-page == 1 {
if current-page == 1{
[]
} else if query(<end-of-prelude>)
.first()
.location()
.page() > current-page {
} else if query(<end-of-prelude>).first().location().page() > current-page {
numbering("I", nums.pos().first())
} else if query(<end-of-content>)
.first()
.location()
.page() >= current-page {
} else if query(<end-of-content>).first().location().page() >= current-page {
numbering("1", nums.pos().first())
} else {
numbering("a", nums.pos().first())
@ -279,11 +228,7 @@
set align(center)
numbering("I", page-counter)
} else if query(<end-of-content>).first().location().page() >= page-number {
numbering(
"1 / 1",
page-counter,
counter(page).at(<end-of-content>).last(),
)
numbering("1 / 1", page-counter, counter(page).at(<end-of-content>).last())
} else {
numbering("a", page-counter)
}
@ -303,13 +248,7 @@
// right align logo of DHBW
align(right, image("res/DHBW.svg", height: style.header.logo-height)))
} else if query(<end-of-content>)
.first()
.location()
.page() >= current-page and query(<end-of-prelude>)
.first()
.location()
.page() < current-page + 1 {
} else if query(<end-of-content>).first().location().page() >= current-page and query(<end-of-prelude>).first().location().page() < current-page + 1 {
let heading = currentH()
heading.at(0)
@ -322,8 +261,7 @@
v(style.header.underline-top-padding - 1em)
line(length: 100%)
}
},
)
})
body
}

View File

@ -3,8 +3,8 @@
#import "abstract.typ": abstract, summary
#show: dhbw-template.with((
lang: "de",
region: "de",
lang: "en",
region: "en",
draft: false,
author: (
name: "Sven Vogel",
@ -51,7 +51,7 @@
#lorem(200)
@einstein
= Lorem Ipsum 3 <sec:hello>
= Lorem Ipsum 3
#lorem(15) t `Hello, World!` #lorem(50)
@ -68,7 +68,7 @@ $
lorem(200),
)
#url("https://github.com", "text") @sec:hello
#url("https://github.com", "text (github.com)")
#lorem(50)

View File

@ -1,7 +1,8 @@
#import "../../src/lib.typ": dhbw-template
#show: dhbw-template.with((
#show: dhbw-template.with(
config: (
lang: none,
region: "en",
author: (

View File

@ -1,34 +1,30 @@
#import "../../src/lib.typ": dhbw-template
#show: dhbw-template.with((
lang: "en",
this-key-is-not-in-config: "Ha Ha",
region: "en",
author: (
name: "Sven Vogel",
semester: 4,
program: "Informationtechnology",
course: "TINF19IT1",
faculty: "Technik",
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: "Benny Goodman",
matriculation-number: 123456789,
),
thesis: (
title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises",
submission-date: "23rd march 2020",
timeframe: "1st january 2020 - 20th march 2020",
kind: "T2000",
summary: none,
abstract: none,
keywords: ("IT", "other stuff"),
bibliography: none,
glossary: none,
appendices: none,
),
))
= Heading
#show: dhbw-template.with(
config: (
lang: "en",
this-key-is-not-in-config: "Ha Ha",
region: "en",
author: (
name: "Sven Vogel",
semester: 4,
program: "Informationtechnology",
course: "TINF19IT1",
faculty: "Technik",
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: "Benny Goodman",
matriculation-number: 123456789),
thesis: (
title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises",
submission-date: "23rd march 2020",
timeframe: "1st january 2020 - 20th march 2020",
kind: "T2000",
summary: none,
abstract: none,
keywords: ( "IT", "other stuff" ),
bibliography: none,
glossary: none,
appendices: none)))

View File

@ -1,26 +1,24 @@
#import "../../src/lib.typ": dhbw-template
#show: dhbw-template.with((
lang: "en",
region: "en",
author: (
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: none,
matriculation-number: 123456789,
),
thesis: (
title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises",
submission-date: "23rd march 2020",
timeframe: "1st january 2020 - 20th march 2020",
kind: "T2000",
summary: none,
abstract: none,
keywords: ("IT", "other stuff"),
bibliography: none,
glossary: none,
appendices: none,
),
))
#show: dhbw-template.with(
config: (
lang: "en",
region: "en",
author: (
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: none,
matriculation-number: 123456789),
thesis: (
title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises",
submission-date: "23rd march 2020",
timeframe: "1st january 2020 - 20th march 2020",
kind: "T2000",
summary: none,
abstract: none,
keywords: ( "IT", "other stuff" ),
bibliography: none,
glossary: none,
appendices: none)))

View File

@ -1,7 +1,8 @@
#import "../../src/lib.typ": dhbw-template
#show: dhbw-template.with((
#show: dhbw-template.with(
config: (
lang: "en",
region: "en",
author: (
@ -26,5 +27,3 @@
bibliography: none,
glossary: none,
appendices: none)))
= Heading

View File

@ -1,6 +1,6 @@
[package]
name = "dhbw-abb-typst-template"
version = "0.4.1"
version = "0.1.0"
entrypoint = "src/template.typ"
authors = ["Sven Vogel <sven.vogel1@de.abb.com>"]
license = "MIT"