From ea26a0215d7c9701442e423bf08f4482805d4d89 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 30 Mar 2024 15:51:39 -0400 Subject: [PATCH] clean up compsci templates --- algs.typ | 23 ----------------------- compsci.typ | 43 ------------------------------------------- general.typ | 2 +- main.typ | 45 +++++++++++++++++++++++++++++++++++++++++++++ problems.typ | 5 ++--- 5 files changed, 48 insertions(+), 70 deletions(-) delete mode 100644 algs.typ delete mode 100644 compsci.typ diff --git a/algs.typ b/algs.typ deleted file mode 100644 index 7906874..0000000 --- a/algs.typ +++ /dev/null @@ -1,23 +0,0 @@ -// templates for compsci notes - -#import "main.typ": gen_preamble, doc_template, mono_font, lref -#import "compsci.typ": source_code - -#let template( - title: none, - authors: none, - body -) = { - doc_template( - title: title, - { - gen_preamble( - title: title, - authors: authors, - prefix: [_Algorithm notes_] - ) - - body - } - ) -} diff --git a/compsci.typ b/compsci.typ deleted file mode 100644 index 2f9cedc..0000000 --- a/compsci.typ +++ /dev/null @@ -1,43 +0,0 @@ -// generic compsci utilities - -#import "main.typ": mono_font - -// did i finish this problem? -#let status(stat: "incomplete") = { - if stat == "complete" { - text(fill: rgb("#448d00"))[ - *Status*: Completed - ] - } else if stat == "cheated" { - text(fill: rgb("#aaaa22"))[ - *Status*: Solved with editorial - ] - } else { - text(fill: rgb("#aa4422"))[ - *Status*: Incomplete - ] - } -} - -// show associated source code -#let source_code( - lang: "cpp", - block: true, - src_path: "problems/src/", - // convert tabs to spaces - detab: true, - problem_id -) = { - let raw_text = read("../" + src_path + problem_id + "." + lang) - if detab { - raw_text = raw_text.replace("\t", " ") - } - - text(font: mono_font)[ - #raw( - raw_text, - block: true, - lang: lang, - ) - ] -} diff --git a/general.typ b/general.typ index 6c1a2a8..df010f5 100644 --- a/general.typ +++ b/general.typ @@ -1,6 +1,6 @@ // general document -#import "main.typ": gen_preamble, doc_template, lref +#import "main.typ": gen_preamble, doc_template, lref, source_code, status #let template( title: none, diff --git a/main.typ b/main.typ index 4b6ecbb..cccca61 100644 --- a/main.typ +++ b/main.typ @@ -166,3 +166,48 @@ v(29pt, weak: true) body } + + +//////////////////////////////// +// compsci notes utils +//////////////////////////////// + +// did i finish this problem? +#let status(stat: "incomplete") = { + if stat == "complete" { + text(fill: rgb("#448d00"))[ + *Status*: Completed + ] + } else if stat == "cheated" { + text(fill: rgb("#aaaa22"))[ + *Status*: Solved with editorial + ] + } else { + text(fill: rgb("#aa4422"))[ + *Status*: Incomplete + ] + } +} + +// show associated source code +#let source_code( + lang: "cpp", + block: true, + src_path: "problems/src/", + // convert tabs to spaces + detab: true, + problem_id +) = { + let raw_text = read("../" + src_path + problem_id + "." + lang) + if detab { + raw_text = raw_text.replace("\t", " ") + } + + text(font: mono_font)[ + #raw( + raw_text, + block: true, + lang: lang, + ) + ] +} diff --git a/problems.typ b/problems.typ index f4244e1..2ca1377 100644 --- a/problems.typ +++ b/problems.typ @@ -1,7 +1,6 @@ // templates for compsci problem documents outside of contests -#import "main.typ": gen_preamble, doc_template, mono_font, lref -#import "compsci.typ": source_code, status +#import "main.typ": gen_preamble, doc_template, mono_font, lref, source_code, status #let template( title: none, @@ -17,7 +16,7 @@ prefix: status(stat: stat), suffix: { if (problem_url != none) { - [#linebreak()#link(problem_url)] + [#link(problem_url)] } } )