Compare commits

..

No commits in common. "ea26a0215d7c9701442e423bf08f4482805d4d89" and "b6f2c233acec3175a41307c6d8a0efc37681d58b" have entirely different histories.

7 changed files with 90 additions and 50 deletions

23
algs.typ Normal file
View File

@ -0,0 +1,23 @@
// 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
}
)
}

43
compsci.typ Normal file
View File

@ -0,0 +1,43 @@
// 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,
)
]
}

View File

@ -1,6 +1,6 @@
// general document
#import "main.typ": gen_preamble, doc_template, lref, source_code, status
#import "main.typ": gen_preamble, doc_template, lref
#let template(
title: none,

19
index.typ Normal file
View File

@ -0,0 +1,19 @@
// templates for online lecture notes
#import "main.typ": gen_preamble, doc_template, lref
#let template(
title: none,
authors: none,
subtitle: [Index of resources],
body
) = {
doc_template(title: title, {
gen_preamble(
title: title,
authors: authors,
prefix: [_#{subtitle}_],
)
body
})
}

View File

@ -78,7 +78,6 @@
[
#{gen_authors(authors: authors)}
]
linebreak()
suffix
})
)
@ -166,48 +165,3 @@
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,
)
]
}

View File

@ -1,6 +1,7 @@
// templates for compsci problem documents outside of contests
#import "main.typ": gen_preamble, doc_template, mono_font, lref, source_code, status
#import "main.typ": gen_preamble, doc_template, mono_font, lref
#import "compsci.typ": source_code, status
#let template(
title: none,
@ -16,7 +17,7 @@
prefix: status(stat: stat),
suffix: {
if (problem_url != none) {
[#link(problem_url)]
[#linebreak()#link(problem_url)]
}
}
)

View File

@ -1,6 +1,6 @@
// templates for online lecture notes
#import "../main.typ": gen_preamble, doc_template, mono_font, lref
#import "main.typ": gen_preamble, doc_template, mono_font, lref
#let template(
title: none,