From 5bd1ffb4581d0bb717b2c11bb5fdf34267fa69d6 Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 01:58:05 -0400 Subject: [PATCH 01/12] creates full calendar w/ weeks numbered; shades days with the word exam --- examples/calendar_example.typ | 8 ++ src/calendars.typ | 241 ++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100644 examples/calendar_example.typ create mode 100644 src/calendars.typ diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ new file mode 100644 index 0000000..d66f93e --- /dev/null +++ b/examples/calendar_example.typ @@ -0,0 +1,8 @@ +#import "@preview/codepoint:0.2.1":labs +#import "../src/calendars.typ" + +#show: calendars.init + +#calendars.header((8, 12), (23, 12), title: "CS-1181 FA26") + +nsddsssssddddddxdddjdsddd \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ new file mode 100644 index 0000000..448cef8 --- /dev/null +++ b/src/calendars.typ @@ -0,0 +1,241 @@ +#let months = ( + ("January", 31), + ("February", 28), + ("March", 31), + ("April", 30), + ("May", 31), + ("June", 30), + ("July", 31), + ("August", 31), + ("September", 30), + ("October", 31), + ("November", 30), + ("December", 31) +) + +#let day-arr = ( + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", +) + +/// Initialize a lab with a show rule +/// +/// +/// Example: +/// ```typst +/// #show: labs.init +/// ``` +/// - body (content): body fo lab problem +#let init(body) = { + + assert( + type(body) == content or type(body) == str, + message: "Expected body to be content or str, but received" + str(type(body)) + ) + + + set page(margin: 20pt, width: 8.5in, height: auto) + set text( + font: ("Roboto"), + size: 11pt, + fill: black, + weight: "regular" + ) + set raw(theme: "../themes/codepoint.tmTheme") + show raw: set text(font: ("Courier", "Courier Prime"), weight: "bold", size: 10pt) + + // defaults to 1.2, but on labs specifically, this is not enough spacing + set par(spacing: 1.6em) + + body +} + +#let days-of-week(is-mon-start: false) = { + let days = day-arr + if is-mon-start { + let old = days.remove(0) + days.push("Sunday") + } + + table( + columns: (1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), + align: center, + stroke: none, + ..days.flatten() + ) +} + +#let month-header(month-id, is-mon-start: false) = { + assert( + type(month-id) == int, + message: "Expected month-id to be int, but received" + str(type(month-id)) + ) + + v(-10pt) + text[== #months.at(month-id).at(0)] + line(length: 100%, stroke: 1pt) + v(-15pt) + days-of-week(is-mon-start: is-mon-start) + v(-15pt) + line(length: 100%, stroke: 1pt) +} + +#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false) = { + let max-days = months.at(month-id).at(1) + + if last-month-max != none { + max-days = last-month-max + } + + if is-leap-year and month-id == 1 { + max-days = max-days + 1; + } + + let day-nums = () + let day = start + let reach-max = false + let week-count = last-week-num + + while calc.rem(day-nums.len(), 8) != 0 or not reach-max { + if calc.rem(day-nums.len(), 8) == 0 { + day-nums.push("week #" + str(week-count)) + week-count = week-count + 1 + } + day-nums.push(str(day)) + + day = day + 1 + if day > max-days { + day = 1 + reach-max = true + } + } + return (day-nums, week-count) +} + +#let construct-month-table(days) = { + v(-18pt) + + show table.cell: it => { + // matchs to the text "week #" followed by a one or two digit number + // rotates and bolds the text + show regex("week #\d{1,2}"): it => text(size:11pt, weight: "bold")[#rotate(-90deg, reflow: true)[#v(-20pt)#it]] + it + } + table( + columns: (0fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), + align: center, + rows: 60pt, + ..days.map(text-str => { + table.cell(fill: if text-str.contains("exam") { rgb("#a12310").lighten(40%) } else { none })[#text-str] + }) + //..days.flatten() + ) +} + +/// header: Render the document section header block for lab problems +/// - startMonth (content, str): Class name +/// - title (content, str): The title text for the specific lab problem +/// - number (int, string, none): Lab problem number, if applicable +#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false) = { + assert( + type(month-range) == array, + message: "Expected month-range to be array, but received " + str(type(month-range)) + ) + + assert( + type(month-range.at(0)) == int, + message: "Expected month-range to be array of int, but received " + str(type(month-range.at(0))) + ) + + assert( + type(month-range.at(1)) == int, + message: "Expected month-range to be array of int, but received " + str(type(month-range.at(1))) + ) + + assert( + month-range.at(1) > 0 and month-range.at(1) < 13, + message: "Second month-range value must be >0 and <13" + ) + + assert( + month-range.at(0) > 0 and month-range.at(0) < month-range.at(1), + message: "First month-range value must be >0 and <" + str(month-range.at(1)) + ) + + assert( + type(day-range) == array, + message: "Expected day-range to be array, but received " + str(type(day-range)) + ) + + assert( + type(day-range.at(0)) == int, + message: "Expected day-range to be array of int, but received " + str(type(day-range.at(0))) + ) + + assert( + type(day-range.at(1)) == int, + message: "Expected day-range to be array of int, but received " + str(type(day-range.at(1))) + ) + + assert( + day-range.at(0) > 0 and day-range.at(0) < 32 and day-range.at(1) > 0 and day-range.at(1) < 32, + message: "Day-range values must be >0 and <32" + ) + + assert( + type(title) == str or title == none, + message: "Expected title to be string, or none, but received " + str(type(title)) + ) + + assert( + type(is-leap-year) == bool or is-leap-year == none, + message: "Expected is-leap-year to be bool, or none, but received " + str(type(is-leap-year)) + ) + + assert( + type(is-mon-start) == bool or is-mon-start == none, + message: "Expected is-mon-start to be bool, or none, but received " + str(type(is-mon-start)) + ) + + if title != none { + text[= #title] + line(length: 100%, stroke: 2pt) + v(5pt) + } + + let month = month-range.at(0) - 1 + let start-day = day-range.at(0) + let days = (none, 1) + let end-day = none + + while month < month-range.at(1) { + // if we are at the last month, + // set the end-day the user requested + if month == month-range.at(1) - 1 { + end-day = day-range.at(1) + } + + month-header(month, is-mon-start: is-mon-start) + days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year) + construct-month-table(days.at(0)) + + start-day = int(days.last()) + 1 + // prevents starting a month on 32 or another not real day + if start-day > 10 { + start-day = 1 + } + month = month + 1 + } + + v(50pt) + // [1#align(left)[#v(-10pt)Exam \#1]] + days = ("week #1", "1-test", "1 exam") + construct-month-table(days) +} + + From 010afb4efbf862236b71f71385ec997a503bae3a Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 02:28:19 -0400 Subject: [PATCH 02/12] custom color coding added --- examples/calendar_example.typ | 13 +++++++++++-- src/calendars.typ | 35 +++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index d66f93e..0acddaf 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -3,6 +3,15 @@ #show: calendars.init -#calendars.header((8, 12), (23, 12), title: "CS-1181 FA26") +#let color-coding = ( + ("zyBooks", rgb("#10a178")), + ("lab", rgb("#104fa1")), + ("project", rgb("#a19e10")), + ("quiz", rgb("#a15d10")), + ("exam", rgb("#a11010")), + ("final", rgb("#a11010")) +) -nsddsssssddddddxdddjdsddd \ No newline at end of file +#calendars.header((8, 12), (23, 12), title: "CS-1181 FA26", color-codes: color-coding) + +nsddsssssddddddxdddjdsd \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 448cef8..0c0b82e 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -117,7 +117,7 @@ return (day-nums, week-count) } -#let construct-month-table(days) = { +#let construct-month-table(days, keywords) = { v(-18pt) show table.cell: it => { @@ -131,7 +131,30 @@ align: center, rows: 60pt, ..days.map(text-str => { - table.cell(fill: if text-str.contains("exam") { rgb("#a12310").lighten(40%) } else { none })[#text-str] + let all-pieces = text-str.split("-") + if all-pieces.len() == 1 { + table.cell()[#text-str] + } else { + let num = all-pieces.at(0) + let temp = [] + let content = text(weight: "bold")[#num] + let i = 1 + while i < all-pieces.len() { + temp = all-pieces.at(i) + let j = 0 + while j < keywords.len() { + if temp.contains(keywords.at(j).at(0)) { + temp = text(fill: keywords.at(j).at(1))[#temp] + break + } + j = j + 1 + } + content = content + align(left)[#v(-10pt)#temp] + i = i + 1 + } + table.cell()[#content] + } + //table.cell(fill: if text-str.contains("exam") { rgb("#a12310").lighten(40%) } else { none })[#text(fill: if text-str.contains("exam") { rgb("#a12310") } else { black })[#text-str]] }) //..days.flatten() ) @@ -141,7 +164,7 @@ /// - startMonth (content, str): Class name /// - title (content, str): The title text for the specific lab problem /// - number (int, string, none): Lab problem number, if applicable -#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false) = { +#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:none) = { assert( type(month-range) == array, message: "Expected month-range to be array, but received " + str(type(month-range)) @@ -222,7 +245,7 @@ month-header(month, is-mon-start: is-mon-start) days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year) - construct-month-table(days.at(0)) + construct-month-table(days.at(0), color-codes) start-day = int(days.last()) + 1 // prevents starting a month on 32 or another not real day @@ -234,8 +257,8 @@ v(50pt) // [1#align(left)[#v(-10pt)Exam \#1]] - days = ("week #1", "1-test", "1 exam") - construct-month-table(days) + days = ("week #1", "1-exam #1", "1-zyBooks #1-lab #1") + construct-month-table(days, color-codes) } From 79f3802aecbbc4e2ceb42e758cec7f42a1b85f9a Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 02:31:39 -0400 Subject: [PATCH 03/12] fixed so works if no color codes provided --- examples/calendar_example.typ | 11 +++++++++-- src/calendars.typ | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index 0acddaf..cfc6adf 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -12,6 +12,13 @@ ("final", rgb("#a11010")) ) -#calendars.header((8, 12), (23, 12), title: "CS-1181 FA26", color-codes: color-coding) -nsddsssssddddddxdddjdsd \ No newline at end of file + +#calendars.header( + (8, 12), + (23, 12), + title: "CS-1181 FA26", + color-codes: color-coding +) + +nsddsssssddddddxdddjdss \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 0c0b82e..54371b7 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -231,6 +231,10 @@ v(5pt) } + if color-codes == none { + color-codes = () + } + let month = month-range.at(0) - 1 let start-day = day-range.at(0) let days = (none, 1) From ced71eb9e293e8530734b0d2761fa37b3887f19b Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 02:55:01 -0400 Subject: [PATCH 04/12] added ability to gray out holidays --- examples/calendar_example.typ | 13 ++++++-- src/calendars.typ | 60 +++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index cfc6adf..ad040ac 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -12,13 +12,20 @@ ("final", rgb("#a11010")) ) - +#let holidays = ( + (9, 7), + (11, 11), + (11, 25), + (11, 26), + (11, 27) +) #calendars.header( (8, 12), (23, 12), title: "CS-1181 FA26", - color-codes: color-coding + color-codes: color-coding, + holidays: holidays ) -nsddsssssddddddxdddjdss \ No newline at end of file +nsddsssssddddddxdddjdsss \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 54371b7..b63639b 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -85,13 +85,16 @@ line(length: 100%, stroke: 1pt) } -#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false) = { +#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false, holidays:()) = { + // number of days in the month let max-days = months.at(month-id).at(1) + // override if different last day is provided if last-month-max != none { max-days = last-month-max } + // account for leap year if is-leap-year and month-id == 1 { max-days = max-days + 1; } @@ -101,17 +104,35 @@ let reach-max = false let week-count = last-week-num + // loops until the month max has been reached + // AND the week has been completed while calc.rem(day-nums.len(), 8) != 0 or not reach-max { + // inserts the week # tag at the beginning of each week if calc.rem(day-nums.len(), 8) == 0 { day-nums.push("week #" + str(week-count)) week-count = week-count + 1 } - day-nums.push(str(day)) + + let i = 0 + let day-text = str(day) + while i < holidays.len() { + let date = holidays.at(i) + if (date.at(0) == (month-id + 1)) and (date.at(1) == day) { + day-text = str(day) + "-holiday" + break + } + i = i + 1 + } + + // inserts the day number + day-nums.push(day-text) day = day + 1 + // resets day if the max is reached if day > max-days { day = 1 reach-max = true + month-id = month-id + 1 } } return (day-nums, week-count) @@ -135,24 +156,32 @@ if all-pieces.len() == 1 { table.cell()[#text-str] } else { + let fill-color = none let num = all-pieces.at(0) let temp = [] let content = text(weight: "bold")[#num] let i = 1 while i < all-pieces.len() { temp = all-pieces.at(i) - let j = 0 - while j < keywords.len() { - if temp.contains(keywords.at(j).at(0)) { - temp = text(fill: keywords.at(j).at(1))[#temp] - break + if temp.contains("holiday") { + fill-color = gray + } else { + // check all keywords and perform color coding as needed + let j = 0 + while j < keywords.len() { + if temp.contains(keywords.at(j).at(0)) { + temp = text(fill: keywords.at(j).at(1))[#temp] + break + } + j = j + 1 } - j = j + 1 + // append the text on a new line, left-justified + content = content + align(left)[#v(-10pt)#temp] } - content = content + align(left)[#v(-10pt)#temp] i = i + 1 } - table.cell()[#content] + + table.cell(fill: fill-color)[#content] } //table.cell(fill: if text-str.contains("exam") { rgb("#a12310").lighten(40%) } else { none })[#text(fill: if text-str.contains("exam") { rgb("#a12310") } else { black })[#text-str]] }) @@ -164,7 +193,7 @@ /// - startMonth (content, str): Class name /// - title (content, str): The title text for the specific lab problem /// - number (int, string, none): Lab problem number, if applicable -#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:none) = { +#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:(), holidays:()) = { assert( type(month-range) == array, message: "Expected month-range to be array, but received " + str(type(month-range)) @@ -225,16 +254,13 @@ message: "Expected is-mon-start to be bool, or none, but received " + str(type(is-mon-start)) ) + // format title if provided if title != none { text[= #title] line(length: 100%, stroke: 2pt) v(5pt) } - if color-codes == none { - color-codes = () - } - let month = month-range.at(0) - 1 let start-day = day-range.at(0) let days = (none, 1) @@ -242,13 +268,13 @@ while month < month-range.at(1) { // if we are at the last month, - // set the end-day the user requested + // set the end-day to what the user requested if month == month-range.at(1) - 1 { end-day = day-range.at(1) } month-header(month, is-mon-start: is-mon-start) - days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year) + days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, holidays: holidays) construct-month-table(days.at(0), color-codes) start-day = int(days.last()) + 1 From 36894b4f46fb53fcaea584f1ee0de2b42b86c7c6 Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 03:01:18 -0400 Subject: [PATCH 05/12] renamed to shading and allowed user to pick color --- examples/calendar_example.typ | 4 +++- src/calendars.typ | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index ad040ac..8c56020 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -20,12 +20,14 @@ (11, 27) ) +#let shading-coding = (holidays, gray) + #calendars.header( (8, 12), (23, 12), title: "CS-1181 FA26", color-codes: color-coding, - holidays: holidays + shading: shading-coding ) nsddsssssddddddxdddjdsss \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index b63639b..308ff2a 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -85,7 +85,7 @@ line(length: 100%, stroke: 1pt) } -#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false, holidays:()) = { +#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false, shading:()) = { // number of days in the month let max-days = months.at(month-id).at(1) @@ -115,10 +115,10 @@ let i = 0 let day-text = str(day) - while i < holidays.len() { - let date = holidays.at(i) + while i < shading.len() { + let date = shading.at(i) if (date.at(0) == (month-id + 1)) and (date.at(1) == day) { - day-text = str(day) + "-holiday" + day-text = str(day) + "-shade" break } i = i + 1 @@ -138,7 +138,7 @@ return (day-nums, week-count) } -#let construct-month-table(days, keywords) = { +#let construct-month-table(days, keywords, shading) = { v(-18pt) show table.cell: it => { @@ -163,8 +163,8 @@ let i = 1 while i < all-pieces.len() { temp = all-pieces.at(i) - if temp.contains("holiday") { - fill-color = gray + if temp.contains("shade") { + fill-color = shading } else { // check all keywords and perform color coding as needed let j = 0 @@ -193,7 +193,7 @@ /// - startMonth (content, str): Class name /// - title (content, str): The title text for the specific lab problem /// - number (int, string, none): Lab problem number, if applicable -#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:(), holidays:()) = { +#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:(), shading:()) = { assert( type(month-range) == array, message: "Expected month-range to be array, but received " + str(type(month-range)) @@ -274,8 +274,8 @@ } month-header(month, is-mon-start: is-mon-start) - days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, holidays: holidays) - construct-month-table(days.at(0), color-codes) + days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: shading.at(0)) + construct-month-table(days.at(0), color-codes, shading.at(1)) start-day = int(days.last()) + 1 // prevents starting a month on 32 or another not real day @@ -288,7 +288,7 @@ v(50pt) // [1#align(left)[#v(-10pt)Exam \#1]] days = ("week #1", "1-exam #1", "1-zyBooks #1-lab #1") - construct-month-table(days, color-codes) + construct-month-table(days, color-codes, shading.at(1)) } From b7f9daf19bd2020f130ca777947f7382bf112256 Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 03:26:25 -0400 Subject: [PATCH 06/12] fixed days of month not flowing correctly; added ability to have multiple different shading encodings --- examples/calendar_example.typ | 20 +++++++++++-- src/calendars.typ | 54 ++++++++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index 8c56020..d4071fa 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -20,14 +20,28 @@ (11, 27) ) -#let shading-coding = (holidays, gray) +#let finals-week = ( + (12, 7), + (12, 8), + (12, 9), + (12, 10), + (12, 11) +) + +#let holiday-encodings = (holidays, gray) +#let finals-encodings = (finals-week, rgb("#f59998")) + +#let shading-encodings = ( + holiday-encodings, + finals-encodings +) #calendars.header( (8, 12), (23, 12), title: "CS-1181 FA26", color-codes: color-coding, - shading: shading-coding + shading: shading-encodings ) -nsddsssssddddddxdddjdsss \ No newline at end of file +nsddsssssddddddxdddjs \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 308ff2a..1185ade 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -116,10 +116,15 @@ let i = 0 let day-text = str(day) while i < shading.len() { - let date = shading.at(i) - if (date.at(0) == (month-id + 1)) and (date.at(1) == day) { - day-text = str(day) + "-shade" - break + let j = 0 + let dates = shading.at(i) + while j < dates.len() { + let date = dates.at(j) + if (date.at(0) == (month-id + 1)) and (date.at(1) == day) { + day-text = str(day) + "-" + str(i) + break + } + j = j + 1 } i = i + 1 } @@ -135,10 +140,10 @@ month-id = month-id + 1 } } - return (day-nums, week-count) + return (day-nums, week-count, day) } -#let construct-month-table(days, keywords, shading) = { +#let construct-month-table(days, keywords, shading-colors) = { v(-18pt) show table.cell: it => { @@ -163,9 +168,15 @@ let i = 1 while i < all-pieces.len() { temp = all-pieces.at(i) - if temp.contains("shade") { - fill-color = shading - } else { + let shade-id = 0 + while shade-id < shading-colors.len() { + if temp.contains(str(shade-id)) { + fill-color = shading-colors.at(shade-id) + } + shade-id = shade-id + 1 + } + + if fill-color == none { // check all keywords and perform color coding as needed let j = 0 while j < keywords.len() { @@ -261,6 +272,23 @@ v(5pt) } + // construct arrays for dates to be shaded + // construct arrays for the color to shade + let dates = () + let colors = () + if type(shading.at(1)) == color { + dates.push(shading.at(0)) + colors.push(shading.at(1)) + } else { + let i = 0 + while i < shading.len() { + let pair = shading.at(i) + dates.push(pair.at(0)) + colors.push(pair.at(1)) + i = i + 1 + } + } + let month = month-range.at(0) - 1 let start-day = day-range.at(0) let days = (none, 1) @@ -274,10 +302,10 @@ } month-header(month, is-mon-start: is-mon-start) - days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: shading.at(0)) - construct-month-table(days.at(0), color-codes, shading.at(1)) + days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: dates) + construct-month-table(days.at(0), color-codes, colors) - start-day = int(days.last()) + 1 + start-day = days.at(2)//int(days.at(0).last()) + 1 // prevents starting a month on 32 or another not real day if start-day > 10 { start-day = 1 @@ -288,7 +316,7 @@ v(50pt) // [1#align(left)[#v(-10pt)Exam \#1]] days = ("week #1", "1-exam #1", "1-zyBooks #1-lab #1") - construct-month-table(days, color-codes, shading.at(1)) + construct-month-table(days, color-codes, colors) } From 1b3e85bd7efe86584c21075a8d9753c7be7caf4d Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 03:27:37 -0400 Subject: [PATCH 07/12] removed some now un-needed code --- examples/calendar_example.typ | 2 +- src/calendars.typ | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index d4071fa..eed6220 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -44,4 +44,4 @@ shading: shading-encodings ) -nsddsssssddddddxdddjs \ No newline at end of file +nsddsssssddddddxdd \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 1185ade..276493a 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -305,11 +305,7 @@ days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: dates) construct-month-table(days.at(0), color-codes, colors) - start-day = days.at(2)//int(days.at(0).last()) + 1 - // prevents starting a month on 32 or another not real day - if start-day > 10 { - start-day = 1 - } + start-day = days.at(2) month = month + 1 } From f2545c532dc1640ebb990975e8eb9cb26c0d1d9d Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 03:30:13 -0400 Subject: [PATCH 08/12] fixed issue where shade conditional was checking for contains instead of equal --- examples/calendar_example.typ | 2 +- src/calendars.typ | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index eed6220..65299b6 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -44,4 +44,4 @@ shading: shading-encodings ) -nsddsssssddddddxdd \ No newline at end of file +nsddsssssddddddxddd \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 276493a..8763666 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -158,6 +158,7 @@ rows: 60pt, ..days.map(text-str => { let all-pieces = text-str.split("-") + // if there is only a number if all-pieces.len() == 1 { table.cell()[#text-str] } else { @@ -170,7 +171,7 @@ temp = all-pieces.at(i) let shade-id = 0 while shade-id < shading-colors.len() { - if temp.contains(str(shade-id)) { + if temp == str(shade-id) { fill-color = shading-colors.at(shade-id) } shade-id = shade-id + 1 From 907367e2fcf94b425d710d91001d8e45cb707f4f Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 03:31:25 -0400 Subject: [PATCH 09/12] fixed issue where numbers were only bolded if other text was present --- examples/calendar_example.typ | 2 +- src/calendars.typ | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index 65299b6..f4bfd09 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -44,4 +44,4 @@ shading: shading-encodings ) -nsddsssssddddddxddd \ No newline at end of file +nsddsssssddddddxddds \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 8763666..5f98e1b 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -160,7 +160,7 @@ let all-pieces = text-str.split("-") // if there is only a number if all-pieces.len() == 1 { - table.cell()[#text-str] + table.cell()[#text(weight: "bold")[#text-str]] } else { let fill-color = none let num = all-pieces.at(0) From 272bb165c379b742e56618e358e9a25e6a2e7b97 Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 04:09:39 -0400 Subject: [PATCH 10/12] added ability to add assignments and other important dates --- examples/calendar_example.typ | 47 ++++++++++++++++++++++++++++++++--- src/calendars.typ | 27 ++++++++++++++------ 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index f4bfd09..121c2a5 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -7,9 +7,10 @@ ("zyBooks", rgb("#10a178")), ("lab", rgb("#104fa1")), ("project", rgb("#a19e10")), - ("quiz", rgb("#a15d10")), + ("QUIZ", rgb("#a15d10")), ("exam", rgb("#a11010")), - ("final", rgb("#a11010")) + ("FINAL", rgb("#a11010")), + ("MIDTERM", rgb("#a11010")), ) #let holidays = ( @@ -36,12 +37,50 @@ finals-encodings ) +#let due-dates = ( + (8, 30, "zyBooks #1"), + (9, 6, "zyBooks #2"), + (9, 13, "zyBooks #3"), + (9, 20, "zyBooks #4"), + (9, 27, "zyBooks #5"), + (10, 4, "zyBooks #6"), + (10, 11, "zyBooks #7"), + (10, 18, "zyBooks #8"), + (10, 25, "zyBooks #9"), + (11, 1, "zyBooks #10"), + (11, 8, "zyBooks #11"), + + (8, 30, "lab #1"), + (9, 6, "lab #2"), + (9, 13, "lab #3"), + (9, 20, "lab #4"), + (9, 27, "lab #5"), + (10, 4, "lab #6"), + (10, 11, "lab #7"), + (10, 18, "lab #8"), + (10, 25, "lab #9"), + (11, 1, "lab #10"), + (11, 8, "lab #11"), + (11, 15, "lab #12"), + + (9, 20, "project #1"), + (10, 11, "project #2"), + (11, 1, "project #3"), + (11, 22, "project #4"), + + (9, 18, "QUIZ #1"), + (10, 16, "MIDTERM"), + (11, 13, "QUIZ #2"), + (12, 11, "FINAL"), +) + #calendars.header( (8, 12), (23, 12), title: "CS-1181 FA26", color-codes: color-coding, - shading: shading-encodings + shading: shading-encodings, + due-dates: due-dates, ) -nsddsssssddddddxddds \ No newline at end of file +nsdd \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 5f98e1b..8ecdb0e 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -85,7 +85,7 @@ line(length: 100%, stroke: 1pt) } -#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false, shading:()) = { +#let construct-day-arr(month-id, start, last-month-max, last-week-num, is-leap-year: false, shading:(), assigns:()) = { // number of days in the month let max-days = months.at(month-id).at(1) @@ -121,7 +121,7 @@ while j < dates.len() { let date = dates.at(j) if (date.at(0) == (month-id + 1)) and (date.at(1) == day) { - day-text = str(day) + "-" + str(i) + day-text = day-text + "-" + str(i) break } j = j + 1 @@ -129,6 +129,15 @@ i = i + 1 } + i = 0 + while i < assigns.len() { + let item = assigns.at(i) + if (item.at(0) == (month-id + 1)) and (item.at(1) == day) { + day-text = day-text + "-" + item.at(2) + } + i = i + 1 + } + // inserts the day number day-nums.push(day-text) @@ -166,23 +175,28 @@ let num = all-pieces.at(0) let temp = [] let content = text(weight: "bold")[#num] + let skip = false let i = 1 while i < all-pieces.len() { + skip = false temp = all-pieces.at(i) + // checks if the cell should be shaded let shade-id = 0 while shade-id < shading-colors.len() { if temp == str(shade-id) { fill-color = shading-colors.at(shade-id) + skip = true } shade-id = shade-id + 1 } - if fill-color == none { + // only need to check for keywords if we determine it is not a shading key + if skip == false { // check all keywords and perform color coding as needed let j = 0 while j < keywords.len() { if temp.contains(keywords.at(j).at(0)) { - temp = text(fill: keywords.at(j).at(1))[#temp] + temp = text(weight: "bold", fill: keywords.at(j).at(1))[#temp] break } j = j + 1 @@ -205,7 +219,7 @@ /// - startMonth (content, str): Class name /// - title (content, str): The title text for the specific lab problem /// - number (int, string, none): Lab problem number, if applicable -#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:(), shading:()) = { +#let header(month-range, day-range, title:none, is-leap-year:false, is-mon-start:false, color-codes:(), shading:(), due-dates:()) = { assert( type(month-range) == array, message: "Expected month-range to be array, but received " + str(type(month-range)) @@ -303,7 +317,7 @@ } month-header(month, is-mon-start: is-mon-start) - days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: dates) + days = construct-day-arr(month, start-day, end-day, days.at(1), is-leap-year: is-leap-year, shading: dates, assigns: due-dates) construct-month-table(days.at(0), color-codes, colors) start-day = days.at(2) @@ -311,7 +325,6 @@ } v(50pt) - // [1#align(left)[#v(-10pt)Exam \#1]] days = ("week #1", "1-exam #1", "1-zyBooks #1-lab #1") construct-month-table(days, color-codes, colors) } From 0ae8bebb1c0cc0135ca8c379766e9cf3af58bcfe Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 04:13:58 -0400 Subject: [PATCH 11/12] clean-up; resize box heights --- examples/calendar_example.typ | 6 +++--- src/calendars.typ | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index 121c2a5..0bb4012 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -74,6 +74,8 @@ (12, 11, "FINAL"), ) + + #calendars.header( (8, 12), (23, 12), @@ -81,6 +83,4 @@ color-codes: color-coding, shading: shading-encodings, due-dates: due-dates, -) - -nsdd \ No newline at end of file +) \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index 8ecdb0e..e64fae9 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -164,7 +164,7 @@ table( columns: (0fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr), align: center, - rows: 60pt, + rows: 70pt, ..days.map(text-str => { let all-pieces = text-str.split("-") // if there is only a number @@ -209,9 +209,7 @@ table.cell(fill: fill-color)[#content] } - //table.cell(fill: if text-str.contains("exam") { rgb("#a12310").lighten(40%) } else { none })[#text(fill: if text-str.contains("exam") { rgb("#a12310") } else { black })[#text-str]] }) - //..days.flatten() ) } @@ -323,10 +321,6 @@ start-day = days.at(2) month = month + 1 } - - v(50pt) - days = ("week #1", "1-exam #1", "1-zyBooks #1-lab #1") - construct-month-table(days, color-codes, colors) } From 73f8377fc9bf6eab9821320d1bc6d1a85074d6f9 Mon Sep 17 00:00:00 2001 From: Clarissa Milligan Date: Fri, 24 Jul 2026 11:46:35 -0400 Subject: [PATCH 12/12] fix that shading didnt work without a param --- examples/calendar_example.typ | 17 +++++++++++------ src/calendars.typ | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/examples/calendar_example.typ b/examples/calendar_example.typ index 0bb4012..90a2a68 100644 --- a/examples/calendar_example.typ +++ b/examples/calendar_example.typ @@ -76,11 +76,16 @@ +//#calendars.header( +// (8, 12), +// (23, 12), +// title: "CS-1181 FA26", +// color-codes: color-coding, +// shading: shading-encodings, +// due-dates: due-dates, +//) + #calendars.header( - (8, 12), - (23, 12), - title: "CS-1181 FA26", - color-codes: color-coding, - shading: shading-encodings, - due-dates: due-dates, + (6, 7), + (21, 18) ) \ No newline at end of file diff --git a/src/calendars.typ b/src/calendars.typ index e64fae9..5cad1c8 100644 --- a/src/calendars.typ +++ b/src/calendars.typ @@ -289,17 +289,19 @@ // construct arrays for the color to shade let dates = () let colors = () - if type(shading.at(1)) == color { - dates.push(shading.at(0)) - colors.push(shading.at(1)) - } else { - let i = 0 - while i < shading.len() { - let pair = shading.at(i) - dates.push(pair.at(0)) - colors.push(pair.at(1)) - i = i + 1 - } + if shading != () { + if type(shading.at(1)) == color { + dates.push(shading.at(0)) + colors.push(shading.at(1)) + } else { + let i = 0 + while i < shading.len() { + let pair = shading.at(i) + dates.push(pair.at(0)) + colors.push(pair.at(1)) + i = i + 1 + } + } } let month = month-range.at(0) - 1