Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
lib.typ
|
||||
config/universities.yaml
|
||||
|
||||
*.pdf
|
||||
4
appendices.typ
Normal file
4
appendices.typ
Normal file
@@ -0,0 +1,4 @@
|
||||
#import "utils.typ": code
|
||||
|
||||
= Код програми sample.c <foo-c>
|
||||
#code(read("assets/sample.c"))
|
||||
30
assets/sample.c
Normal file
30
assets/sample.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
int i, j;
|
||||
|
||||
// Number of rows
|
||||
int rows = 3;
|
||||
|
||||
// Taking first character of alphabet
|
||||
// which is useful to print pattern
|
||||
char character = 'A';
|
||||
|
||||
// This loop is used to identify
|
||||
// number rows
|
||||
for (i = 0; i < rows; i++) {
|
||||
// This for loop is used to
|
||||
// identify number of columns
|
||||
// based on the rows
|
||||
for (j = 0; j <= i; j++) {
|
||||
// Printing character to get
|
||||
// the required pattern
|
||||
printf("%c ", character);
|
||||
|
||||
// Incrementing character value so
|
||||
// that it will print the next character
|
||||
character++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
2
assets/table.csv
Normal file
2
assets/table.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
1,2,3,4
|
||||
5,6,7,8
|
||||
|
3
chapters/1.typ
Normal file
3
chapters/1.typ
Normal file
@@ -0,0 +1,3 @@
|
||||
#import "/lib.typ": *
|
||||
|
||||
#lorem(200)
|
||||
26
config/doc.toml
Normal file
26
config/doc.toml
Normal file
@@ -0,0 +1,26 @@
|
||||
university = "ХНУРЕ"
|
||||
|
||||
subject = "ЕРВ"
|
||||
type = "ЛБ"
|
||||
number = 3
|
||||
|
||||
[[mentors]]
|
||||
name = "Шевченко Т. Г."
|
||||
degree = "Доцент кафедри ПІ"
|
||||
gender = "m"
|
||||
|
||||
[[mentors]]
|
||||
name = "Франко І. Я."
|
||||
degree = "Асистент кафедри ПІ"
|
||||
gender = "m"
|
||||
|
||||
[[authors]]
|
||||
name = "Косач Л. П."
|
||||
edu_program = "ПЗПІ"
|
||||
group = "23-2"
|
||||
gender = "f"
|
||||
variant = 8
|
||||
# For coursework
|
||||
full_name_gen = "Косач Лариси Петрівни"
|
||||
course = 2
|
||||
semester = 4
|
||||
BIN
figures/Google-Logo-700x394.png
Normal file
BIN
figures/Google-Logo-700x394.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
96
flake.lock
generated
Normal file
96
flake.lock
generated
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"local-nure": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1768300920,
|
||||
"narHash": "sha256-Ndy2YhxHFyMCy0B5oT+nRlA3T8S16u1AzPCKlK9UJ4I=",
|
||||
"path": "/storage/git/typst_nure_template",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "/storage/git/typst_nure_template",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1763421233,
|
||||
"narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"local-nure": "local-nure",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"typix": "typix"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"typix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1762505280,
|
||||
"narHash": "sha256-9/DYuuh14LCQDpWZceY2GF3UvUX2PCrH9eqryBULOqk=",
|
||||
"owner": "loqusion",
|
||||
"repo": "typix",
|
||||
"rev": "489712e2665e1991d17e574b2a69662011cb9113",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "loqusion",
|
||||
"repo": "typix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
163
flake.nix
Normal file
163
flake.nix
Normal file
@@ -0,0 +1,163 @@
|
||||
{
|
||||
description = "A Nix flake for compiling NURE works";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
typix.url = "github:loqusion/typix";
|
||||
typix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# local-nure.url = "git+ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template";
|
||||
local-nure.url = "path:/storage/git/typst_nure_template";
|
||||
# local-nure.url = "git+ssh://gitea@gitea.linerds.us/unexplrd/typst_nure_template";
|
||||
local-nure.flake = false;
|
||||
|
||||
# Example of downloading icons from a non-flake source
|
||||
# font-awesome = {
|
||||
# url = "github:FortAwesome/Font-Awesome";
|
||||
# flake = false;
|
||||
# };
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
nixpkgs,
|
||||
typix,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib;
|
||||
# inherit (lib.strings) escapeShellArg;
|
||||
|
||||
typixLib = typix.lib.${system};
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
(lib.fileset.fromSource (typixLib.cleanTypstSource ./.))
|
||||
(lib.fileset.maybeMissing ./chapters)
|
||||
(lib.fileset.maybeMissing ./config/authors.toml)
|
||||
(lib.fileset.maybeMissing ./config/subject.toml)
|
||||
(lib.fileset.maybeMissing ./figures)
|
||||
(lib.fileset.maybeMissing ./utils.typ)
|
||||
];
|
||||
};
|
||||
commonArgs = {
|
||||
typstSource = "main.typ";
|
||||
|
||||
fontPaths = [
|
||||
"${pkgs.liberation_ttf}/share/fonts/truetype"
|
||||
];
|
||||
|
||||
# Make sure to override outdated files/links (in case of updated flake.lock)
|
||||
# (may be undesirable with config/universities.yaml in case of custom subjects)
|
||||
forceVirtualPaths = true;
|
||||
|
||||
virtualPaths = [
|
||||
# Add paths that must be locally accessible to typst here
|
||||
{
|
||||
dest = "lib.typ";
|
||||
src = "${inputs.local-nure}/lib.typ";
|
||||
}
|
||||
{
|
||||
dest = "config/universities.yaml";
|
||||
src = "${inputs.local-nure}/config/universities.yaml";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# mkTypstPackagesDrv = name: entries: let
|
||||
# linkFarmEntries =
|
||||
# lib.foldl (set: {
|
||||
# name,
|
||||
# version,
|
||||
# namespace,
|
||||
# input,
|
||||
# }:
|
||||
# set
|
||||
# // {
|
||||
# "${namespace}/${name}/${version}" = input;
|
||||
# })
|
||||
# {}
|
||||
# entries;
|
||||
# in
|
||||
# pkgs.linkFarm name linkFarmEntries;
|
||||
|
||||
# unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [
|
||||
# {
|
||||
# name = "nure";
|
||||
# version = "0.1.0";
|
||||
# namespace = "local";
|
||||
# input = inputs.local-nure;
|
||||
# }
|
||||
# ];
|
||||
|
||||
# Any transitive dependencies must be added here
|
||||
# See https://loqusion.github.io/typix/recipes/using-typst-packages.html#the-typstpackages-attribute
|
||||
# unstable_typstPackages = [
|
||||
# {
|
||||
# name = "oxifmt";
|
||||
# version = "0.2.1";
|
||||
# hash = "sha256-8PNPa9TGFybMZ1uuJwb5ET0WGIInmIgg8h24BmdfxlU=";
|
||||
# }
|
||||
# ];
|
||||
|
||||
# Compile a Typst project, *without* copying the result
|
||||
# to the current directory
|
||||
build-drv = typixLib.buildTypstProject (commonArgs
|
||||
// {
|
||||
inherit src;
|
||||
# inherit unstable_typstPackages;
|
||||
# TYPST_PACKAGE_PATH = unpublishedTypstPackages;
|
||||
});
|
||||
|
||||
# Compile a Typst project, and then copy the result
|
||||
# to the current directory
|
||||
build-script = typixLib.buildTypstProjectLocal (commonArgs
|
||||
// {
|
||||
inherit src;
|
||||
# inherit unstable_typstPackages;
|
||||
# TYPST_PACKAGE_PATH = unpublishedTypstPackages;
|
||||
});
|
||||
|
||||
# Watch a project and recompile on changes
|
||||
watch-script = typixLib.watchTypstProject (commonArgs
|
||||
// {
|
||||
# typstWatchCommand = "TYPST_PACKAGE_PATH=${escapeShellArg unpublishedTypstPackages} typst watch";
|
||||
});
|
||||
in {
|
||||
checks = {inherit build-drv build-script watch-script;};
|
||||
|
||||
packages.default = build-drv;
|
||||
|
||||
apps = rec {
|
||||
default = watch;
|
||||
build = flake-utils.lib.mkApp {
|
||||
drv = build-script;
|
||||
};
|
||||
watch = flake-utils.lib.mkApp {
|
||||
drv = watch-script;
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = typixLib.devShell {
|
||||
inherit (commonArgs) fontPaths virtualPaths;
|
||||
packages =
|
||||
[
|
||||
# WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
|
||||
# See https://github.com/loqusion/typix/issues/2
|
||||
# build-script
|
||||
watch-script
|
||||
]
|
||||
++ (with pkgs; [
|
||||
# More packages can be added here, like typstfmt
|
||||
just
|
||||
typstfmt
|
||||
yq
|
||||
]);
|
||||
};
|
||||
});
|
||||
}
|
||||
29
justfile
Normal file
29
justfile
Normal file
@@ -0,0 +1,29 @@
|
||||
alias w := watch
|
||||
alias c := compile
|
||||
|
||||
alias nw := nix-watch
|
||||
alias nb := nix-build
|
||||
alias ns := nix-shell
|
||||
|
||||
file := "main.typ"
|
||||
out := `cat doc.toml | tomlq '.doctype + (.worknumber | tostring) + "_" + (.authors[0].name | split(" ")[0]) + "_" + (.authors[0].edu + "-" + .authors[0].group) + "_" + .subject + ".pdf"'`
|
||||
|
||||
[group('typst')]
|
||||
watch:
|
||||
typst w {{file}} {{out}}
|
||||
[group('typst')]
|
||||
compile:
|
||||
typst c {{file}} {{out}}
|
||||
|
||||
copy-done:
|
||||
cp main.pdf ../{{out}}
|
||||
|
||||
[group('nix')]
|
||||
nix-shell:
|
||||
nix shell nixpkgs#{yq,typst}
|
||||
[group('nix')]
|
||||
nix-watch:
|
||||
nix run .#watch
|
||||
[group('nix')]
|
||||
nix-build:
|
||||
nix run .#build
|
||||
51
main.typ
Normal file
51
main.typ
Normal file
@@ -0,0 +1,51 @@
|
||||
#import "/lib.typ": *
|
||||
#import "/utils.typ": *
|
||||
|
||||
// #show: correctly-indent-list-and-enum-items
|
||||
|
||||
// #show: dstu-style // Для рефератів, нестандартних робіт, тощо
|
||||
#show: pz-lb.with(
|
||||
..toml("config/doc.toml"),
|
||||
title: lorem(2),
|
||||
)
|
||||
|
||||
== #lorem(2)
|
||||
#v(-spacing)
|
||||
=== #lorem(5)
|
||||
|
||||
#lorem(20)
|
||||
|
||||
+ #lorem(10)
|
||||
+ #lorem(10)
|
||||
+ #lorem(10)
|
||||
+ #lorem(10)
|
||||
$ 1/2 dot 3 = 3/2 $
|
||||
+ #lorem(10)
|
||||
$ 1/2 dot 3 = 3/2 $
|
||||
+ #lorem(10)
|
||||
+ #lorem(10)
|
||||
+ #lorem(10)
|
||||
|
||||
#lorem(20)
|
||||
|
||||
#img("figures/Google-Logo-700x394.png", [Корпорація зла], width: 60%)
|
||||
|
||||
|
||||
#lorem(50)
|
||||
|
||||
#figure(caption: "Приклад коду на C", code(read("assets/sample.c")))
|
||||
|
||||
#lorem(20)
|
||||
|
||||
#figure(
|
||||
caption: [Цифри],
|
||||
table(
|
||||
columns: 4,
|
||||
table.header([Один], [Два], [Три], [Чотири]),
|
||||
..csv("assets/table.csv").flatten(),
|
||||
),
|
||||
)
|
||||
|
||||
#lorem(20)
|
||||
|
||||
#appendices-style(include "appendices.typ")
|
||||
106
utils.typ
Normal file
106
utils.typ
Normal file
@@ -0,0 +1,106 @@
|
||||
/// takes in a string of code, e.g. #code(read("foo.c"))
|
||||
#let code(content) = raw(block: true, theme: none, content)
|
||||
|
||||
/// include chapters by file names from /chapters
|
||||
#let chapters(ch) = (
|
||||
array(ch).map(chapter => include str(chapter) + ".typ").join()
|
||||
)
|
||||
|
||||
#let pz-header(worknumber, name) = columns[#text(weight: "bold", [
|
||||
#align(left)[Практичне заняття №#worknumber]
|
||||
#colbreak()
|
||||
#align(right)[#name]
|
||||
])]
|
||||
|
||||
/// https://forum.typst.app/t/how-to-make-bullet-list-item-bodies-flow-like-paragraphs/3756/3?u=andrew
|
||||
/// Spacing doesn't work the same way as native solution if par leading and
|
||||
/// spacing are different.
|
||||
#let correctly-indent-list-and-enum-items(doc) = {
|
||||
let first-line-indent() = if type(par.first-line-indent) == dictionary {
|
||||
par.first-line-indent.amount
|
||||
} else {
|
||||
par.first-line-indent
|
||||
}
|
||||
|
||||
show list: li => {
|
||||
for (i, it) in li.children.enumerate() {
|
||||
let nesting = state("list-nesting", 0)
|
||||
let indent = context h((nesting.get() + 1) * li.indent)
|
||||
let get-nesting() = calc.div-euclid(nesting.get(), 10)
|
||||
let marker = context {
|
||||
let n = get-nesting()
|
||||
if type(li.marker) == array {
|
||||
li.marker.at(calc.rem-euclid(n, li.marker.len()))
|
||||
} else if type(li.marker) == content {
|
||||
li.marker
|
||||
} else {
|
||||
li.marker(n)
|
||||
}
|
||||
}
|
||||
let parents = state("enum-parents", ()) // Support enum nesting.
|
||||
let body = {
|
||||
parents.update(arr => arr + (-1,))
|
||||
nesting.update(x => x + 10)
|
||||
it.body + parbreak()
|
||||
nesting.update(x => x - 10)
|
||||
parents.update(arr => arr.slice(0, -1))
|
||||
}
|
||||
let content = {
|
||||
marker
|
||||
h(li.body-indent)
|
||||
body
|
||||
}
|
||||
context pad(left: int(nesting.get() != 0) * li.indent, content)
|
||||
}
|
||||
}
|
||||
|
||||
show enum: en => {
|
||||
let start = if en.start == auto {
|
||||
if en.children.first().has("number") {
|
||||
if en.reversed { en.children.first().number } else { 1 }
|
||||
} else {
|
||||
if en.reversed { en.children.len() } else { 1 }
|
||||
}
|
||||
} else {
|
||||
en.start
|
||||
}
|
||||
let number = start
|
||||
for (i, it) in en.children.enumerate() {
|
||||
number = if it.number != auto { it.number } else { number }
|
||||
if en.reversed { number = start - i }
|
||||
let parents = state("enum-parents", ())
|
||||
let get-parents() = parents.get().filter(x => x >= 0)
|
||||
let indent = context h((get-parents().len() + 1) * en.indent)
|
||||
let num = if en.full {
|
||||
context numbering(en.numbering, ..get-parents(), number)
|
||||
} else {
|
||||
numbering(en.numbering, number)
|
||||
}
|
||||
let max-num = if en.full {
|
||||
context numbering(en.numbering, ..get-parents(), en.children.len())
|
||||
} else {
|
||||
numbering(en.numbering, en.children.len())
|
||||
}
|
||||
num = context box(
|
||||
width: measure(max-num).width,
|
||||
align(right, text(overhang: false, num)),
|
||||
)
|
||||
let list-nesting = state("list-nesting", 0) // Support list nesting.
|
||||
let body = {
|
||||
parents.update(arr => arr + (number,))
|
||||
list-nesting.update(x => x + 1)
|
||||
it.body + parbreak()
|
||||
list-nesting.update(x => x - 1)
|
||||
parents.update(arr => arr.slice(0, -1))
|
||||
}
|
||||
if not en.reversed { number += 1 }
|
||||
let content = {
|
||||
num
|
||||
h(en.body-indent)
|
||||
body
|
||||
}
|
||||
context pad(left: int(parents.get().len() != 0) * en.indent, content)
|
||||
}
|
||||
}
|
||||
doc
|
||||
}
|
||||
Reference in New Issue
Block a user