chore(glossy): format with typestyle

This commit is contained in:
swaits committed 2025-10-26 16:00:23 -06:00
1 parent 6d83a858c8
commit 022892df88
25 files changed
+345 -209

No files matched your search

+1 -1
View File
@@ -1,2 +1,2 @@
#import "src/gloss.typ": init-glossary, glossary #import "src/gloss.typ": glossary, init-glossary
#import "src/themes.typ": * #import "src/themes.typ": *
+88 -27
View File
@@ -59,7 +59,7 @@
longplural: entry.at("longplural", default: __pluralize(long)), longplural: entry.at("longplural", default: __pluralize(long)),
longarticle: entry.at("longarticle", default: __determine_article(long)), longarticle: entry.at("longarticle", default: __determine_article(long)),
description: entry.at("description", default: none), description: entry.at("description", default: none),
group: entry.at("group", default: "") group: entry.at("group", default: ""),
) )
} }
@@ -149,7 +149,9 @@
counter(__gloss_label_prefix + key).step() counter(__gloss_label_prefix + key).step()
} }
if count-as-first-use { if count-as-first-use {
counter(__gloss_label_prefix + key + __gloss_first_use_counter_postfix).step() counter(
__gloss_label_prefix + key + __gloss_first_use_counter_postfix,
).step()
} }
} }
@@ -181,7 +183,9 @@
// boolean: If the entry is used above the location in the document // boolean: If the entry is used above the location in the document
// //
#let __is_term_first_used(key, location: none) = { #let __is_term_first_used(key, location: none) = {
let c = counter(__gloss_label_prefix + key + __gloss_first_use_counter_postfix) let c = counter(
__gloss_label_prefix + key + __gloss_first_use_counter_postfix,
)
c = if location == none { c.final() } else { c.at(location) } c = if location == none { c.final() } else { c.at(location) }
c.at(0) > 0 c.at(0) > 0
} }
@@ -195,7 +199,9 @@
// none: Updates state as a side effect // none: Updates state as a side effect
// //
#let __reset_term_first_used(key, location: none) = { #let __reset_term_first_used(key, location: none) = {
counter(__gloss_label_prefix + key + __gloss_first_use_counter_postfix).update(0) counter(
__gloss_label_prefix + key + __gloss_first_use_counter_postfix,
).update(0)
} }
// Determine if the glossary contains a visible entry // Determine if the glossary contains a visible entry
@@ -236,8 +242,23 @@
// content: The fully formatted term, including optional article, capitalization, // content: The fully formatted term, including optional article, capitalization,
// usage tracking metadata, and the chosen form (short, long, or both). // usage tracking metadata, and the chosen form (short, long, or both).
// //
#let __gls(key, modes-modifiers: array, format-term: function, show-term: function, term-links: true, display-text: none) = { #let __gls(
let possible_modes = ("auto", "both", "short", "long", "supplement", "description", "reset") key,
modes-modifiers: array,
format-term: function,
show-term: function,
term-links: true,
display-text: none,
) = {
let possible_modes = (
"auto",
"both",
"short",
"long",
"supplement",
"description",
"reset",
)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Normalize mode & modifier inputs AND check if the modifiers are valid // Normalize mode & modifier inputs AND check if the modifiers are valid
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -255,7 +276,10 @@
} else if it in ("both", "short", "long", "reset", "cap", "pl") { } else if it in ("both", "short", "long", "reset", "cap", "pl") {
return it return it
} else if it in ("auto", "description", "supplement") { } else if it in ("auto", "description", "supplement") {
panic(it, "is a valid mode, but is not used by applying a modifier with this name. Read the documentation.") panic(
it,
"is a valid mode, but is not used by applying a modifier with this name. Read the documentation.",
)
} else { } else {
panic(it, "is not a recognized mode or modifier.") panic(it, "is not a recognized mode or modifier.")
} }
@@ -269,7 +293,8 @@
// Determine the requested modes (plural) and the modifier array // Determine the requested modes (plural) and the modifier array
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
modes-modifiers.push("__MIDDLE_ITEM") // unused modifier modes-modifiers.push("__MIDDLE_ITEM") // unused modifier
let (requested_modes, modifiers) = modes-modifiers.sorted(key: it => { let (requested_modes, modifiers) = modes-modifiers
.sorted(key: it => {
if it in possible_modes { if it in possible_modes {
// It is a 'mode' // It is a 'mode'
return -1 return -1
@@ -279,7 +304,8 @@
// It is a 'modifier' // It is a 'modifier'
return 1 return 1
} }
}).split("__MIDDLE_ITEM") })
.split("__MIDDLE_ITEM")
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Check for illegal mode and/or modifier combinations // Check for illegal mode and/or modifier combinations
@@ -335,12 +361,18 @@
// Manage term usage counting and determine if it's the first reference // Manage term usage counting and determine if it's the first reference
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let is_first_use = not __is_term_first_used(key, location: here()) let is_first_use = not __is_term_first_used(key, location: here())
let default-count-as-first-use = (requested_mode == "auto" or requested_mode == "both") let default-count-as-first-use = (
requested_mode == "auto" or requested_mode == "both"
)
let force-count-as-first-use = "use" in modifiers let force-count-as-first-use = "use" in modifiers
let force-skip-as-first-use = "no-use" in modifiers let force-skip-as-first-use = "no-use" in modifiers
let wants_reference = "noindex" not in modifiers let wants_reference = "noindex" not in modifiers
__mark_term_used(key, wants_reference, force-count-as-first-use __mark_term_used(
or (not force-skip-as-first-use and default-count-as-first-use)) key,
wants_reference,
force-count-as-first-use
or (not force-skip-as-first-use and default-count-as-first-use),
)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Helper Functions // Helper Functions
@@ -376,7 +408,7 @@
// - If mode is "short", return the short article. // - If mode is "short", return the short article.
// - If mode is "long" or "both", return the long article. // - If mode is "long" or "both", return the long article.
// The calling logic ensures that when mode = "long" or "both", a long form exists. // The calling logic ensures that when mode = "long" or "both", a long form exists.
let get_article = (mode) => { let get_article = mode => {
let wants_article = "an" in modifiers let wants_article = "an" in modifiers
if not wants_article { if not wants_article {
none none
@@ -406,7 +438,10 @@
} }
let long_available = entry.long != none let long_available = entry.long != none
let mode = if (requested_mode == "both" or requested_mode == "long") and not long_available { let mode = if (
(requested_mode == "both" or requested_mode == "long")
and not long_available
) {
// The fall back case, because long form is not available, but it is requested // The fall back case, because long form is not available, but it is requested
"short" "short"
} else { } else {
@@ -481,9 +516,13 @@
// //
#let __create_backlinks(key) = { #let __create_backlinks(key) = {
return query(__term_label(key)) // find all reference return query(__term_label(key)) // find all reference
.map(meta => { // extract location and page number (or symbol) .map(meta => {
// extract location and page number (or symbol)
let loc = meta.location() let loc = meta.location()
let page = numbering(__default(loc.page-numbering(), "1"), ..counter(page).at(loc)) let page = numbering(
__default(loc.page-numbering(), "1"),
..counter(page).at(loc),
)
(loc, page) (loc, page)
}) })
.dedup(key: ((loc, page)) => page) // deduplicate by page .dedup(key: ((loc, page)) => page) // deduplicate by page
@@ -559,17 +598,23 @@
format-term: __default-format-term, format-term: __default-format-term,
show-term: __default-show-term, show-term: __default-show-term,
term-links: false, term-links: false,
body body,
) = context { ) = context {
// Type checking // Type checking
let checked-entries = (:) let checked-entries = (:)
for (key, entry) in entries { for (key, entry) in entries {
let checked-key = z.parse(key, z.string(), scope: ("dictionary key",)) let checked-key = z.parse(key, z.string(), scope: ("dictionary key",))
let checked-entry = z.parse(entry, dict-schema, scope: ("dictionary entry",)) let checked-entry = z.parse(entry, dict-schema, scope: (
"dictionary entry",
))
checked-entries.insert(checked-key, checked-entry) checked-entries.insert(checked-key, checked-entry)
} }
let checked-format-term = z.parse(show-term, z.function(), scope: ("format-term",)) let checked-format-term = z.parse(show-term, z.function(), scope: (
let checked-show-term = z.parse(show-term, z.function(), scope: ("show-term",)) "format-term",
))
let checked-show-term = z.parse(show-term, z.function(), scope: (
"show-term",
))
let checked-body = z.parse(body, z.content(), scope: ("body",)) let checked-body = z.parse(body, z.content(), scope: ("body",))
// Process and store each glossary entry // Process and store each glossary entry
@@ -590,7 +635,12 @@
// - That "key" does not correspond to an actual entry, // - That "key" does not correspond to an actual entry,
// - There is at least one modifier, // - There is at least one modifier,
// - The first modifier corresponds to an existing entry key. // - The first modifier corresponds to an existing entry key.
let can_swap = (lower(raw_key) == "a" or lower(raw_key) == "an") and not __has_entry(raw_key) and raw_modifiers.len() > 0 and __has_entry(raw_modifiers.first()) let can_swap = (
(lower(raw_key) == "a" or lower(raw_key) == "an")
and not __has_entry(raw_key)
and raw_modifiers.len() > 0
and __has_entry(raw_modifiers.first())
)
// If we can swap, use the first modifier as the key and insert "a" as the first modifier. // If we can swap, use the first modifier as the key and insert "a" as the first modifier.
let (key, modifiers) = if can_swap { let (key, modifiers) = if can_swap {
@@ -602,7 +652,14 @@
// Now see if this is an actual glossary term key // Now see if this is an actual glossary term key
if __has_entry(key) { if __has_entry(key) {
// Found in dictionary, render via __gls() // Found in dictionary, render via __gls()
__gls(key, modes-modifiers: modifiers.map(lower), format-term: format-term, show-term: show-term, term-links: term-links, display-text: supplement) __gls(
key,
modes-modifiers: modifiers.map(lower),
format-term: format-term,
show-term: show-term,
term-links: term-links,
display-text: supplement,
)
} else { } else {
// Not one of ours, so just pass it through // Not one of ours, so just pass it through
r r
@@ -658,7 +715,9 @@
// Type checking // Type checking
let checked-title = z.parse(title, z.content(), scope: ("title",)) let checked-title = z.parse(title, z.content(), scope: ("title",))
let checked-groups = z.parse(groups, groups-list-schema, scope: ("groups",)) let checked-groups = z.parse(groups, groups-list-schema, scope: ("groups",))
let checked-ignore-case = z.parse(ignore-case, z.boolean(), scope: ("ignore-case",)) let checked-ignore-case = z.parse(ignore-case, z.boolean(), scope: (
"ignore-case",
))
let checked-theme = z.parse(theme, theme-schema, scope: ("theme",)) let checked-theme = z.parse(theme, theme-schema, scope: ("theme",))
// Collect and organize entries by group // Collect and organize entries by group
@@ -706,7 +765,7 @@
long: entry.at("long"), long: entry.at("long"),
description: entry.at("description"), description: entry.at("description"),
label: [#metadata(key)#__entry_label(key)], label: [#metadata(key)#__entry_label(key)],
pages: __create_backlinks(key) pages: __create_backlinks(key),
)) ))
} }
} }
@@ -719,7 +778,9 @@
let sorted_entries = if sort { let sorted_entries = if sort {
current_entries current_entries
// 1. create array of tuples with (lower [if ignore-case], entry) // 1. create array of tuples with (lower [if ignore-case], entry)
.map(e => { if ignore-case { (lower(e.short), e) } else { (e.short, e) } }) .map(e => {
if ignore-case { (lower(e.short), e) } else { (e.short, e) }
})
// 2. sort the tuples (by first element then second) // 2. sort the tuples (by first element then second)
.sorted() // NOTE: sorted() is NOT language-aware .sorted() // NOTE: sorted() is NOT language-aware
// 3. strip away the tuple's first element, leaving an array of entries // 3. strip away the tuple's first element, leaving an array of entries
@@ -747,10 +808,10 @@
output.len(), output.len(),
for (i, entry) in entries.enumerate() { for (i, entry) in entries.enumerate() {
(checked-theme.entry)(entry, i, entries.len()) (checked-theme.entry)(entry, i, entries.len())
} },
) )
group_index += 1 group_index += 1
} },
) )
] ]
} }
+3 -3
View File
@@ -10,8 +10,8 @@
longplural: z.content(optional: true), longplural: z.content(optional: true),
description: z.content(optional: true), description: z.content(optional: true),
group: z.content(optional: true), group: z.content(optional: true),
) ),
) ),
) )
#let theme-schema = z.dictionary( #let theme-schema = z.dictionary(
@@ -19,7 +19,7 @@
section: z.function(), section: z.function(),
group: z.function(), group: z.function(),
entry: z.function(), entry: z.function(),
) ),
) )
#let groups-list-schema = z.array(pre-transform: z.coerce.array) #let groups-list-schema = z.array(pre-transform: z.coerce.array)
+3 -5
View File
@@ -5,7 +5,6 @@
v(1em) v(1em)
body body
}, },
group: (name, index, total, body) => { group: (name, index, total, body) => {
if name != "" and total > 1 { if name != "" and total > 1 {
v(1.5em) v(1.5em)
@@ -16,7 +15,6 @@
} }
body body
}, },
entry: (entry, index, total) => { entry: (entry, index, total) => {
let short-display = text(weight: "bold", entry.short) let short-display = text(weight: "bold", entry.short)
let long-display = if entry.long == none { let long-display = if entry.long == none {
@@ -40,10 +38,10 @@
columns: (1fr, auto), columns: (1fr, auto),
gutter: 0.75em, gutter: 0.75em,
[#short-display#long-display#description#entry.label], [#short-display#long-display#description#entry.label],
text(fill: rgb("#666666"), entry.pages.join(", ")) text(fill: rgb("#666666"), entry.pages.join(", ")),
)
}
) )
},
),
) )
}, },
) )
+3 -5
View File
@@ -15,7 +15,6 @@
heading(level: 1, title) heading(level: 1, title)
body body
}, },
// Renders a group of related glossary terms // Renders a group of related glossary terms
// Parameters: // Parameters:
// name: Group name (empty string for ungrouped terms) // name: Group name (empty string for ungrouped terms)
@@ -28,7 +27,6 @@
} }
body body
}, },
// Renders a single glossary entry with term, definition, and page references // Renders a single glossary entry with term, definition, and page references
// Parameters: // Parameters:
// entry: Dictionary containing term data: // entry: Dictionary containing term data:
@@ -62,9 +60,9 @@
left: 1em, left: 1em,
bottom: 0.5em, bottom: 0.5em,
block( block(
[#term#entry.label#long-form#description #h(1em) (pp. #entry.pages.join(", "))] [#term#entry.label#long-form#description #h(1em) (pp. #entry.pages.join(", "))],
) ),
) ),
) )
}, },
) )
+3 -5
View File
@@ -5,7 +5,6 @@
heading(level: 1, smallcaps(title)) heading(level: 1, smallcaps(title))
body body
}, },
group: (name, index, total, body) => { group: (name, index, total, body) => {
if name != "" and total > 1 { if name != "" and total > 1 {
v(1em) v(1em)
@@ -14,7 +13,6 @@
} }
body body
}, },
entry: (entry, index, total) => { entry: (entry, index, total) => {
let short-display = text(weight: "regular", entry.short) let short-display = text(weight: "regular", entry.short)
let long-display = if entry.long == none { let long-display = if entry.long == none {
@@ -38,10 +36,10 @@
columns: (1fr, auto), columns: (1fr, auto),
gutter: 1em, gutter: 1em,
[#short-display#entry.label#long-display#description#entry.label], [#short-display#entry.label#long-display#description#entry.label],
[#entry.pages.join(", ")] [#entry.pages.join(", ")],
)
}
) )
},
),
) )
}, },
) )
+6 -8
View File
@@ -17,7 +17,6 @@
heading(level: 1, outlined: false, text(weight: "bold", size: 1.1em, title)) heading(level: 1, outlined: false, text(weight: "bold", size: 1.1em, title))
body body
}, },
// Renders a group of related glossary terms // Renders a group of related glossary terms
// Parameters: // Parameters:
// name: Group name (empty string for ungrouped terms) // name: Group name (empty string for ungrouped terms)
@@ -30,13 +29,12 @@
spacing: 0.5em, spacing: 0.5em,
pad( pad(
top: 0.5em, top: 0.5em,
text(weight: "bold", size: 0.9em, name) text(weight: "bold", size: 0.9em, name),
) ),
) )
} }
body body
}, },
// Renders a single glossary entry with term, definition, and page references // Renders a single glossary entry with term, definition, and page references
// Parameters: // Parameters:
// entry: Dictionary containing term data: // entry: Dictionary containing term data:
@@ -53,7 +51,7 @@
size: 0.65em, size: 0.65em,
weight: "medium", weight: "medium",
fill: gray.darken(60%), fill: gray.darken(60%),
entry.short entry.short,
) )
let long-form = if entry.long == none { let long-form = if entry.long == none {
@@ -83,9 +81,9 @@
text( text(
size: 0.6em, size: 0.6em,
fill: gray.darken(20%), fill: gray.darken(20%),
entry.pages.join(", ") entry.pages.join(", "),
) ),
) ),
) )
}, },
) )
+10 -6
View File
@@ -4,13 +4,13 @@
heading(level: 1, title) heading(level: 1, title)
body body
}, },
group: (name, index, total, body) => { group: (name, index, total, body) => {
if name != "" and total > 1 { if name != "" and total > 1 {
heading(level: 2, name) heading(level: 2, name)
} }
table(columns: 4, table(
columns: 4,
stroke: none, stroke: none,
inset: (x, y) => { inset: (x, y) => {
if (x == 0) { if (x == 0) {
@@ -22,11 +22,15 @@
} }
}, },
table.header([*Abbreviation*], [*Full Name*], [*Description*], [*Pages*]), table.header([*Abbreviation*], [*Full Name*], [*Description*], [*Pages*]),
..body ..body,
) )
}, },
entry: (entry, index, total) => { entry: (entry, index, total) => {
(entry.short + entry.label, entry.long, entry.description, entry.pages.join(", ")) (
} entry.short + entry.label,
entry.long,
entry.description,
entry.pages.join(", "),
)
},
) )
+9 -7
View File
@@ -15,7 +15,6 @@
heading(level: 1, title) heading(level: 1, title)
columns(2, body) columns(2, body)
}, },
// Renders a group of related glossary terms // Renders a group of related glossary terms
// Parameters: // Parameters:
// name: Group name (empty string for ungrouped terms) // name: Group name (empty string for ungrouped terms)
@@ -28,7 +27,6 @@
} }
body body
}, },
// Renders a single glossary entry with term, definition, and page references // Renders a single glossary entry with term, definition, and page references
// Parameters: // Parameters:
// entry: Dictionary containing term data: // entry: Dictionary containing term data:
@@ -62,11 +60,15 @@
grid( grid(
columns: (auto, 1fr, 1em, auto), columns: (auto, 1fr, 1em, auto),
align: (left, center, center, right), align: (left, center, center, right),
[#short-display#entry.label#long-display#description], // Term with label [#short-display#entry.label#long-display#description],
[#repeat(h(0.25em) + "." + h(0.25em))], // Dotted leader line // Term with label
[ . ], // A 1em wide dot so we definitely get some break between term and pages [#repeat(h(0.25em) + "." + h(0.25em))],
[#entry.pages.join(", ")] // Page references // Dotted leader line
) [ . ],
// A 1em wide dot so we definitely get some break between term and pages
[#entry.pages.join(", ")],
// Page references
),
) )
}, },
) )
+14 -3
View File
@@ -16,8 +16,8 @@
} }
// Helper functions for checking endings // Helper functions for checking endings
let ends_with = (suffix) => lower(word).ends-with(suffix) let ends_with = suffix => lower(word).ends-with(suffix)
let ends_with_any = (suffixes) => suffixes.any((suffix) => ends_with(suffix)) let ends_with_any = suffixes => suffixes.any(suffix => ends_with(suffix))
// Map of irregular plurals for common words // Map of irregular plurals for common words
let irregulars = ( let irregulars = (
@@ -80,7 +80,18 @@
// Irregular suffixes // Irregular suffixes
let f_to_ves = ("leaf", "loaf", "calf", "half", "wolf", "thief") let f_to_ves = ("leaf", "loaf", "calf", "half", "wolf", "thief")
let fe_to_ves = ("wife", "knife", "life") let fe_to_ves = ("wife", "knife", "life")
let o_to_os = ("photo", "piano", "halo", "radio", "video", "studio", "solo", "taco", "memo", "zero") let o_to_os = (
"photo",
"piano",
"halo",
"radio",
"video",
"studio",
"solo",
"taco",
"memo",
"zero",
)
// Convenience // Convenience
let w = lower(word) let w = lower(word)
+38 -17
View File
@@ -6,10 +6,11 @@
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures"), description: "A document on how to run all the test procedures",
),
) )
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)]) #show: init-glossary.with(myGlossary, show-term: body => [#emph(body)])
#set heading(numbering: "1.1") #set heading(numbering: "1.1")
#set page(numbering: "1") #set page(numbering: "1")
@@ -43,8 +44,15 @@ Now make sure I get your @tps:short reports by 2pm!
These modifiers are semantically mutually exclusive. When multiple are used, These modifiers are semantically mutually exclusive. When multiple are used,
`glossy` throws an error to the compiler, explaining the problem. `glossy` throws an error to the compiler, explaining the problem.
#import "/src/gloss.typ": __gls, __default-format-term #import "/src/gloss.typ": __default-format-term, __gls
#let manual-gls(key, mods) = __gls(key, modes-modifiers: mods, format-term: __default-format-term, show-term: (body) => [#strong(body)], term-links: false, display-text: none) #let manual-gls(key, mods) = __gls(
key,
modes-modifiers: mods,
format-term: __default-format-term,
show-term: body => [#strong(body)],
term-links: false,
display-text: none,
)
#assert-panic(manual-gls.with("tps", ("short", "long"))) #assert-panic(manual-gls.with("tps", ("short", "long")))
#let msg-short-long = "panicked with: \"Cannot mix modes \", (\"short\", \"long\"), \", pick one.\"" #let msg-short-long = "panicked with: \"Cannot mix modes \", (\"short\", \"long\"), \", pick one.\""
#let msg-short-both = "panicked with: \"Cannot mix modes \", (\"short\", \"both\"), \", pick one.\"" #let msg-short-both = "panicked with: \"Cannot mix modes \", (\"short\", \"both\"), \", pick one.\""
@@ -55,14 +63,29 @@ These modifiers are semantically mutually exclusive. When multiple are used,
columns: 2, columns: 2,
table.header([*Input*], [*Error*]), table.header([*Input*], [*Error*]),
[`@tps:short:long` ], [#assert.eq(catch(manual-gls.with("tps", ("short", "long"))), [`@tps:short:long` ],
msg-short-long)#msg-short-long], [#assert.eq(
[`@tps:short:both` ], [#assert.eq(catch(manual-gls.with("tps", ("short", "both"))), catch(manual-gls.with("tps", ("short", "long"))),
msg-short-both)#msg-short-both], msg-short-long,
[`@tps:long:both` ], [#assert.eq(catch(manual-gls.with("tps", ("long", "both"))), )#msg-short-long],
msg-long-both)#msg-long-both],
[`@tps:short:long:both`], [#assert.eq(catch(manual-gls.with("tps", ("short", "long", "both"))), [`@tps:short:both` ],
msg-short-long-both)#msg-short-long-both], [#assert.eq(
catch(manual-gls.with("tps", ("short", "both"))),
msg-short-both,
)#msg-short-both],
[`@tps:long:both` ],
[#assert.eq(
catch(manual-gls.with("tps", ("long", "both"))),
msg-long-both,
)#msg-long-both],
[`@tps:short:long:both`],
[#assert.eq(
catch(manual-gls.with("tps", ("short", "long", "both"))),
msg-short-long-both,
)#msg-short-long-both],
) )
#let my-theme = ( #let my-theme = (
@@ -88,12 +111,10 @@ These modifiers are semantically mutually exclusive. When multiple are used,
block( block(
grid( grid(
columns: (auto, 1fr, auto), columns: (auto, 1fr, auto),
output, output, repeat([#h(0.25em) . #h(0.25em)]), entry.pages.join(", "),
repeat([#h(0.25em) . #h(0.25em)]), ),
entry.pages.join(", "),
) )
) },
}
) )
#glossary(theme: my-theme) #glossary(theme: my-theme)
+53 -22
View File
@@ -7,20 +7,23 @@
short: "HTML", short: "HTML",
long: "Hypertext Markup Language", long: "Hypertext Markup Language",
description: "A standard language for creating web pages", description: "A standard language for creating web pages",
group: "Web"), group: "Web",
),
css: ( css: (
short: "CSS", short: "CSS",
long: "Cascading Style Sheets", long: "Cascading Style Sheets",
description: "A language used for describing the presentation of a document", description: "A language used for describing the presentation of a document",
group: "Web"), group: "Web",
),
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures"), description: "A document on how to run all the test procedures",
unused: "Unused term, which shouldn't print in the glossary." ),
unused: "Unused term, which shouldn't print in the glossary.",
) )
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)]) #show: init-glossary.with(myGlossary, show-term: body => [#emph(body)])
#set heading(numbering: "1.1") #set heading(numbering: "1.1")
#set page(height: auto, width: 6.5in, margin: 1em, numbering: "1") #set page(height: auto, width: 6.5in, margin: 1em, numbering: "1")
@@ -81,8 +84,15 @@ Articles are incompatible with the `pl` (plural) modifier.
These modifiers are semantically mutually exclusive. When multiple are used, These modifiers are semantically mutually exclusive. When multiple are used,
`glossy` throws an error to the compiler, explaining the problem. `glossy` throws an error to the compiler, explaining the problem.
#import "/src/gloss.typ": __gls, __default-format-term #import "/src/gloss.typ": __default-format-term, __gls
#let manual-gls(key, mods) = __gls(key, modes-modifiers: mods, format-term: __default-format-term, show-term: (body) => [#strong(body)], term-links: false, display-text: none) #let manual-gls(key, mods) = __gls(
key,
modes-modifiers: mods,
format-term: __default-format-term,
show-term: body => [#strong(body)],
term-links: false,
display-text: none,
)
#assert-panic(manual-gls.with("tps", ("short", "long"))) #assert-panic(manual-gls.with("tps", ("short", "long")))
#let msg-short-long = "panicked with: \"Cannot mix modes \", (\"short\", \"long\"), \", pick one.\"" #let msg-short-long = "panicked with: \"Cannot mix modes \", (\"short\", \"long\"), \", pick one.\""
#let msg-short-both = "panicked with: \"Cannot mix modes \", (\"short\", \"both\"), \", pick one.\"" #let msg-short-both = "panicked with: \"Cannot mix modes \", (\"short\", \"both\"), \", pick one.\""
@@ -93,14 +103,29 @@ These modifiers are semantically mutually exclusive. When multiple are used,
columns: 2, columns: 2,
table.header([*Input*], [*Error*]), table.header([*Input*], [*Error*]),
[`@tps:short:long` ], [#assert.eq(catch(manual-gls.with("tps", ("short", "long"))), [`@tps:short:long` ],
msg-short-long)#msg-short-long], [#assert.eq(
[`@tps:short:both` ], [#assert.eq(catch(manual-gls.with("tps", ("short", "both"))), catch(manual-gls.with("tps", ("short", "long"))),
msg-short-both)#msg-short-both], msg-short-long,
[`@tps:long:both` ], [#assert.eq(catch(manual-gls.with("tps", ("long", "both"))), )#msg-short-long],
msg-long-both)#msg-long-both],
[`@tps:short:long:both`], [#assert.eq(catch(manual-gls.with("tps", ("short", "long", "both"))), [`@tps:short:both` ],
msg-short-long-both)#msg-short-long-both], [#assert.eq(
catch(manual-gls.with("tps", ("short", "both"))),
msg-short-both,
)#msg-short-both],
[`@tps:long:both` ],
[#assert.eq(
catch(manual-gls.with("tps", ("long", "both"))),
msg-long-both,
)#msg-long-both],
[`@tps:short:long:both`],
[#assert.eq(
catch(manual-gls.with("tps", ("short", "long", "both"))),
msg-short-long-both,
)#msg-short-long-both],
) )
#let my-theme = ( #let my-theme = (
@@ -126,14 +151,20 @@ These modifiers are semantically mutually exclusive. When multiple are used,
block( block(
grid( grid(
columns: (auto, 1fr, auto), columns: (auto, 1fr, auto),
output, output, repeat([#h(0.25em) . #h(0.25em)]), entry.pages.join(", "),
repeat([#h(0.25em) . #h(0.25em)]), ),
entry.pages.join(", "),
) )
) },
}
) )
#glossary(theme: my-theme) #glossary(theme: my-theme)
#glossary(title: "Glossary with just empty group", groups: ("",), theme: theme-basic) #glossary(
#glossary(title: "Glossary with just Web group", groups: ("Web",), theme: theme-compact) title: "Glossary with just empty group",
groups: ("",),
theme: theme-basic,
)
#glossary(
title: "Glossary with just Web group",
groups: ("Web",),
theme: theme-compact,
)
+8 -19
View File
@@ -54,7 +54,6 @@
("usage", "a"), ("usage", "a"),
("user", "a"), ("user", "a"),
("utensil", "a"), ("utensil", "a"),
// Acronym tests // Acronym tests
("ASCII", "an"), ("ASCII", "an"),
("CFO", "a"), ("CFO", "a"),
@@ -80,9 +79,7 @@
("WWW", "a"), ("WWW", "a"),
("X.Y.Z.", "an"), ("X.Y.Z.", "an"),
("YAML", "a"), ("YAML", "a"),
// Extra tests (courtesy of LLM) // Extra tests (courtesy of LLM)
// Common English words starting with vowels // Common English words starting with vowels
("idea", "an"), ("idea", "an"),
("island", "an"), ("island", "an"),
@@ -94,7 +91,6 @@
("octopus", "an"), ("octopus", "an"),
("atom", "an"), ("atom", "an"),
("item", "an"), ("item", "an"),
// Words starting with vowel but "yoo" sound (thus 'a') // Words starting with vowel but "yoo" sound (thus 'a')
("universe", "a"), ("universe", "a"),
("unicycle", "a"), ("unicycle", "a"),
@@ -106,7 +102,6 @@
("useful", "a"), ("useful", "a"),
("utility", "a"), ("utility", "a"),
("utopia", "a"), ("utopia", "a"),
// More common vowel words with a/an // More common vowel words with a/an
("umbrella", "an"), // repeated but reaffirming ("umbrella", "an"), // repeated but reaffirming
("eggplant", "an"), ("eggplant", "an"),
@@ -118,7 +113,6 @@
("aroma", "an"), ("aroma", "an"),
("ear", "an"), ("ear", "an"),
("ocean", "an"), ("ocean", "an"),
// Words starting with 'h' but pronounced, so 'a' // Words starting with 'h' but pronounced, so 'a'
("house", "a"), // repeated for emphasis ("house", "a"), // repeated for emphasis
("hammer", "a"), ("hammer", "a"),
@@ -130,14 +124,12 @@
("holiday", "a"), ("holiday", "a"),
("harmony", "a"), ("harmony", "a"),
("hover", "a"), ("hover", "a"),
// More silent 'h' words (already in set, but variations) // More silent 'h' words (already in set, but variations)
("honorific", "an"), ("honorific", "an"),
("honorarium", "an"), ("honorarium", "an"),
("honesties", "an"), ("honesties", "an"),
("hourly", "an"), ("hourly", "an"),
("heirloom", "an"), ("heirloom", "an"),
// Words starting with 'e' + 'u' combo with "yoo" sound // Words starting with 'e' + 'u' combo with "yoo" sound
("Europe", "a"), // repeated ("Europe", "a"), // repeated
("European", "a"), // repeated ("European", "a"), // repeated
@@ -149,7 +141,6 @@
("euthanasia", "a"), ("euthanasia", "a"),
("eugenics", "a"), ("eugenics", "a"),
("Eurasia", "a"), ("Eurasia", "a"),
// Common consonant-start words // Common consonant-start words
("book", "a"), ("book", "a"),
("pen", "a"), ("pen", "a"),
@@ -161,7 +152,6 @@
("river", "a"), ("river", "a"),
("mountain", "a"), ("mountain", "a"),
("cloud", "a"), ("cloud", "a"),
// More vowel-start words // More vowel-start words
("ostrich", "an"), ("ostrich", "an"),
("amphibian", "an"), ("amphibian", "an"),
@@ -173,7 +163,6 @@
("aisle", "an"), ("aisle", "an"),
("oracle", "an"), ("oracle", "an"),
("overcoat", "an"), ("overcoat", "an"),
// More acronym/initialism tests: // More acronym/initialism tests:
("ATM", "an"), // A = 'ay' ("ATM", "an"), // A = 'ay'
("EPA", "an"), // E = 'ee' ("EPA", "an"), // E = 'ee'
@@ -185,7 +174,6 @@
("OSHA", "an"), // O = 'oh' ("OSHA", "an"), // O = 'oh'
("RAM", "an"), // R = 'ar' ("RAM", "an"), // R = 'ar'
("SMS", "an"), // repeated, S = 'ess' ("SMS", "an"), // repeated, S = 'ess'
// Acronyms starting with consonant sound letters // Acronyms starting with consonant sound letters
("GIF", "a"), // G = 'jee', repeated ("GIF", "a"), // G = 'jee', repeated
("CFO", "a"), // C = 'see', repeated (consonant sound 's') ("CFO", "a"), // C = 'see', repeated (consonant sound 's')
@@ -197,7 +185,6 @@
("UPS", "a"), // U = 'yoo' sound, hence 'a' ("UPS", "a"), // U = 'yoo' sound, hence 'a'
("VIP", "a"), // V = 'vee' starts with 'v' consonant sound ("VIP", "a"), // V = 'vee' starts with 'v' consonant sound
("WIPO", "a"), // W = 'double-u' starts with 'd' consonant sound ("WIPO", "a"), // W = 'double-u' starts with 'd' consonant sound
// More tricky 'u' words with 'yoo' sound for 'a' // More tricky 'u' words with 'yoo' sound for 'a'
("unify", "a"), ("unify", "a"),
("unilateral", "a"), ("unilateral", "a"),
@@ -209,7 +196,6 @@
("ugly", "an"), // repeated, 'uh-glee' ("ugly", "an"), // repeated, 'uh-glee'
("upper", "an"), // 'uh-pur' (vowel sound but actually 'uh' sound = 'an'? Actually "upper" starts with a simple vowel sound 'uh', so should it be 'an'? It's commonly "an upper hand". ("upper", "an"), // 'uh-pur' (vowel sound but actually 'uh' sound = 'an'? Actually "upper" starts with a simple vowel sound 'uh', so should it be 'an'? It's commonly "an upper hand".
("update", "an"), // 'up-date' starts with 'uh' vowel sound → 'an update' normally. Actually we say "an update" commonly. Correcting to 'an': ("update", "an"), // 'up-date' starts with 'uh' vowel sound → 'an update' normally. Actually we say "an update" commonly. Correcting to 'an':
// Words starting with 'u' that actually take "an" // Words starting with 'u' that actually take "an"
// (because they start with a vowel sound 'uh'): // (because they start with a vowel sound 'uh'):
("under", "an"), ("under", "an"),
@@ -225,7 +211,6 @@
("universal", "a"), ("universal", "a"),
("umbrella", "an"), // repeated ("umbrella", "an"), // repeated
("upset", "an"), // 'uh-pset' vowel start ("upset", "an"), // 'uh-pset' vowel start
// More vowel words to ensure coverage: // More vowel words to ensure coverage:
("animal", "an"), ("animal", "an"),
("image", "an"), ("image", "an"),
@@ -240,7 +225,6 @@
("item", "an"), // repeated ("item", "an"), // repeated
("isotope", "an"), ("isotope", "an"),
("opera", "an"), ("opera", "an"),
// Words starting with vowels but pronounced with consonant sound 'y' → 'a' // Words starting with vowels but pronounced with consonant sound 'y' → 'a'
("euphemistic", "a"), // repeated ("euphemistic", "a"), // repeated
("euphoric", "a"), ("euphoric", "a"),
@@ -252,7 +236,6 @@
("eureka", "a"), // repeated ("eureka", "a"), // repeated
("euphonious", "a"), ("euphonious", "a"),
("Eurasia", "a"), ("Eurasia", "a"),
// Common consonant-start words: // Common consonant-start words:
("milk", "a"), ("milk", "a"),
("road", "a"), ("road", "a"),
@@ -264,7 +247,6 @@
("knife", "a"), // 'knife' actually starts with /n/ sound because 'k' is silent. "a knife" or "an knife"? It's "a knife" (starts with 'n' consonant sound?), actually 'kn' in 'knife' is silent, so 'knife' is pronounced 'nife' with a consonant sound 'n', so "a knife" is correct. ("knife", "a"), // 'knife' actually starts with /n/ sound because 'k' is silent. "a knife" or "an knife"? It's "a knife" (starts with 'n' consonant sound?), actually 'kn' in 'knife' is silent, so 'knife' is pronounced 'nife' with a consonant sound 'n', so "a knife" is correct.
("glass", "a"), ("glass", "a"),
("window", "a"), ("window", "a"),
// Final checks with tricky silent letters: // Final checks with tricky silent letters:
("gnome", "a"), // 'g' silent, pronounced 'nome' with 'n' consonant sound → 'a gnome' ("gnome", "a"), // 'g' silent, pronounced 'nome' with 'n' consonant sound → 'a gnome'
("gnat", "a"), // 'nat' consonant sound → 'a gnat' ("gnat", "a"), // 'nat' consonant sound → 'a gnat'
@@ -280,7 +262,14 @@
#for (word, article) in tests { #for (word, article) in tests {
let chosen = __determine_article(word) let chosen = __determine_article(word)
if chosen != article { if chosen != article {
panic("bad choice! word: " + word + ", article: " + article + ", chosen: " + chosen) panic(
"bad choice! word: "
+ word
+ ", article: "
+ article
+ ", chosen: "
+ chosen,
)
} }
} }
+24 -15
View File
@@ -5,20 +5,24 @@
short: "HTML", short: "HTML",
long: "Hypertext Markup Language", long: "Hypertext Markup Language",
description: "A standard language for creating web pages", description: "A standard language for creating web pages",
group: "Web"), group: "Web",
),
css: ( css: (
short: "CSS", short: "CSS",
long: "Cascading Style Sheets", long: "Cascading Style Sheets",
description: "A language used for describing the presentation of a document", description: "A language used for describing the presentation of a document",
group: "Web"), group: "Web",
),
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures"), description: "A document on how to run all the test procedures",
),
concise: "Concise syntax!", concise: "Concise syntax!",
shortonly: ( shortonly: (
short: "shortonly!!!"), short: "shortonly!!!",
unused: "Unused term, which shouldn't print in the glossary." ),
unused: "Unused term, which shouldn't print in the glossary.",
) )
#set page(width: 6.5in, height: auto, margin: 1em) #set page(width: 6.5in, height: auto, margin: 1em)
@@ -26,9 +30,7 @@
#let test-content = { #let test-content = {
table( table(
columns: 3, columns: 3,
table.header( table.header([`short`], [`long`], [`both`]),
[`short`], [`long`], [`both`],
),
[@html:short], [@html:long], [@html:both], [@html:short], [@html:long], [@html:both],
[@css:short], [@css:long], [@css:both], [@css:short], [@css:long], [@css:both],
@@ -79,7 +81,7 @@
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
#let format-uppercase-short(mode, short-form, long-form) = { #let format-uppercase-short(mode, short-form, long-form) = {
let short-up = upper(short-form); let short-up = upper(short-form)
if mode == "short" { if mode == "short" {
short-up short-up
} else if mode == "long" { } else if mode == "long" {
@@ -108,8 +110,8 @@
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
#let format-conditional-separator(mode, short-form, long-form) = { #let format-conditional-separator(mode, short-form, long-form) = {
let separator = if short-form.len() > 4 { " / " } else { ", " }; let separator = if short-form.len() > 4 { " / " } else { ", " }
let has_long = long-form != none and long-form != ""; let has_long = long-form != none and long-form != ""
if mode == "short" { if mode == "short" {
short-form short-form
@@ -124,7 +126,10 @@
} }
} }
#init-glossary(myGlossary, format-term: format-conditional-separator)[#test-content] #init-glossary(
myGlossary,
format-term: format-conditional-separator,
)[#test-content]
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
// 1. Braces and Labels // 1. Braces and Labels
@@ -145,7 +150,9 @@
// 2. Mode-Based Prefix // 2. Mode-Based Prefix
// Idea: Add a prefix indicating the mode, and then show the term(s). // Idea: Add a prefix indicating the mode, and then show the term(s).
#let format-mode-prefix(mode, short-form, long-form) = { #let format-mode-prefix(mode, short-form, long-form) = {
let prefix = if mode == "short" { "S:" } else if mode == "long" { "L:" } else { "B:" }; let prefix = if mode == "short" { "S:" } else if mode == "long" {
"L:"
} else { "B:" }
if mode == "short" { if mode == "short" {
prefix + short-form prefix + short-form
} else if mode == "long" { } else if mode == "long" {
@@ -161,7 +168,7 @@
// 3. Conditional Fallback for Missing Long // 3. Conditional Fallback for Missing Long
// Idea: If no long-form is provided, use the short-form in all cases. // Idea: If no long-form is provided, use the short-form in all cases.
#let format-fallback-long(mode, short-form, long-form) = { #let format-fallback-long(mode, short-form, long-form) = {
let has_long = long-form != none and long-form != ""; let has_long = long-form != none and long-form != ""
if mode == "short" { if mode == "short" {
short-form short-form
} else if mode == "long" { } else if mode == "long" {
@@ -193,7 +200,9 @@
// Idea: In both mode, append the length of each string. // Idea: In both mode, append the length of each string.
#let format-length-info(mode, short-form, long-form) = { #let format-length-info(mode, short-form, long-form) = {
let s_len = str(short-form.len()) let s_len = str(short-form.len())
let l_len = if long-form != none and long-form != "" { str(long-form.len()) } else { "0" } let l_len = if long-form != none and long-form != "" {
str(long-form.len())
} else { "0" }
if mode == "short" { if mode == "short" {
short-form + " [len:" + s_len + "]" short-form + " [len:" + s_len + "]"
+2 -2
View File
@@ -19,7 +19,7 @@
This should be a link, too: @WWW This should be a link, too: @WWW
#glossary() #glossary()
] ],
) )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -41,5 +41,5 @@
This should be a link, too: @ML This should be a link, too: @ML
#print-glossary(entry-list) #print-glossary(entry-list)
] ],
) )
+3 -3
View File
@@ -12,21 +12,21 @@ Reference: @pbr, @zbuffer
] ]
#t("abbreviations") // "string" : str #t("abbreviations") // "string" : str
#t(("abbreviations")) // ("string") : str #t("abbreviations") // ("string") : str
#t(("abbreviations",)) // ("string",) : array(str) #t(("abbreviations",)) // ("string",) : array(str)
#t(("abbreviations", "abbreviations")) // ("string","string",) : array(str) #t(("abbreviations", "abbreviations")) // ("string","string",) : array(str)
#pagebreak(weak: true) #pagebreak(weak: true)
#t("") // empty string should be the empty group #t("") // empty string should be the empty group
#t(("")) // empty string should be the empty group #t("") // empty string should be the empty group
#t(("",)) // empty string should be the empty group #t(("",)) // empty string should be the empty group
#t(("", "")) // empty string should be the empty group #t(("", "")) // empty string should be the empty group
#pagebreak(weak: true) #pagebreak(weak: true)
#t(none) // none should be all groups #t(none) // none should be all groups
#t((none)) // none should be all groups #t(none) // none should be all groups
#pagebreak(weak: true) #pagebreak(weak: true)
+7 -4
View File
@@ -5,17 +5,20 @@
short: "HTML", short: "HTML",
long: "Hypertext Markup Language", long: "Hypertext Markup Language",
description: "A standard language for creating web pages", description: "A standard language for creating web pages",
group: "Web"), group: "Web",
),
css: ( css: (
short: "CSS", short: "CSS",
long: "Cascading Style Sheets", long: "Cascading Style Sheets",
description: "A language used for describing the presentation of a document", description: "A language used for describing the presentation of a document",
group: "Web"), group: "Web",
),
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures"), description: "A document on how to run all the test procedures",
unused: "Unused term, which shouldn't print in the glossary." ),
unused: "Unused term, which shouldn't print in the glossary.",
) )
#show: init-glossary.with(myGlossary) #show: init-glossary.with(myGlossary)
+7 -4
View File
@@ -5,17 +5,20 @@
short: "HTML", short: "HTML",
long: "Hypertext Markup Language", long: "Hypertext Markup Language",
description: "A standard language for creating web pages", description: "A standard language for creating web pages",
group: "Web"), group: "Web",
),
css: ( css: (
short: "CSS", short: "CSS",
long: "Cascading Style Sheets", long: "Cascading Style Sheets",
description: "A language used for describing the presentation of a document", description: "A language used for describing the presentation of a document",
group: "Web"), group: "Web",
),
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures"), description: "A document on how to run all the test procedures",
unused: "Unused term, which shouldn't print in the glossary." ),
unused: "Unused term, which shouldn't print in the glossary.",
) )
#show: init-glossary.with(myGlossary) #show: init-glossary.with(myGlossary)
+1 -1
View File
@@ -20,7 +20,7 @@
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures" description: "A document on how to run all the test procedures",
), ),
) )
+1 -1
View File
@@ -298,7 +298,7 @@
+ ". Expected: " + ". Expected: "
+ (if expected == none { "none" } else { str(expected) }) + (if expected == none { "none" } else { str(expected) })
+ ", got: " + ", got: "
+ (if result == none { "none" } else { str(result) }) + (if result == none { "none" } else { str(result) }),
) )
} }
} }
+46 -39
View File
@@ -37,43 +37,37 @@
short: "HTML", short: "HTML",
long: "Hypertext Markup Language", long: "Hypertext Markup Language",
description: "A standard language for creating web pages", description: "A standard language for creating web pages",
group: "Web" group: "Web",
), ),
css: ( css: (
short: "CSS", short: "CSS",
long: "Cascading Style Sheets", long: "Cascading Style Sheets",
description: "A language used for describing the presentation of documents", description: "A language used for describing the presentation of documents",
group: "Web" group: "Web",
), ),
// Term with no description // Term with no description
js: ( js: (
short: "JS", short: "JS",
long: "JavaScript", long: "JavaScript",
group: "Web" group: "Web",
), ),
// Term with only a short field // Term with only a short field
tcp: ( tcp: (
short: "TCP", short: "TCP",
group: "Networking" group: "Networking",
), ),
// Term with only a long field // Term with only a long field
// should panic! // should panic!
//udp: ( //udp: (
// long: "User Datagram Protocol", // long: "User Datagram Protocol",
// group: "Networking" // group: "Networking"
//), //),
// Term with short and description, but no long // Term with short and description, but no long
ip: ( ip: (
short: "IP", short: "IP",
description: "A unique identifier for a host or network interface", description: "A unique identifier for a host or network interface",
group: "Networking" group: "Networking",
), ),
// Term with custom articles and everything defined // Term with custom articles and everything defined
api: ( api: (
short: "API", short: "API",
@@ -81,35 +75,30 @@
description: "A set of protocols and tools for building software", description: "A set of protocols and tools for building software",
article: "an", // custom article for short form article: "an", // custom article for short form
longarticle: "an", // custom article for long form longarticle: "an", // custom article for long form
group: "Software" group: "Software",
), ),
// Term starting with a vowel, no custom article, to test default a/an logic // Term starting with a vowel, no custom article, to test default a/an logic
xml: ( xml: (
short: "XML", short: "XML",
long: "Extensible Markup Language", long: "Extensible Markup Language",
description: "A markup language defining rules for encoding documents", description: "A markup language defining rules for encoding documents",
group: "Data" group: "Data",
), ),
// Term starting with a consonant, no custom article // Term starting with a consonant, no custom article
cpu: ( cpu: (
short: "CPU", short: "CPU",
long: "Central Processing Unit", long: "Central Processing Unit",
description: "The primary component of a computer that performs calculations", description: "The primary component of a computer that performs calculations",
group: "Hardware" group: "Hardware",
), ),
// Term without any fields (just a string), should be handled gracefully // Term without any fields (just a string), should be handled gracefully
bare: "A bare term with no fields", bare: "A bare term with no fields",
// Term with only description // Term with only description
// should panic! // should panic!
//desconly: ( //desconly: (
// description: "Just a description, no short or long", // description: "Just a description, no short or long",
// group: "Misc" // group: "Misc"
//), //),
// Term with article fields but missing short and long (should test fallback) // Term with article fields but missing short and long (should test fallback)
// should panic! // should panic!
//articonly: ( //articonly: (
@@ -118,51 +107,46 @@
// description: "Has only articles and a description", // description: "Has only articles and a description",
// group: "Misc" // group: "Misc"
//), //),
// Term with uppercase key // Term with uppercase key
SSL: ( SSL: (
short: "SSL", short: "SSL",
long: "Secure Sockets Layer", long: "Secure Sockets Layer",
description: "A protocol for encrypting information over the internet", description: "A protocol for encrypting information over the internet",
group: "Security" group: "Security",
), ),
// Term that will not be referenced // Term that will not be referenced
unusedterm: ( unusedterm: (
short: "UNUSED", short: "UNUSED",
long: "Unused Term", long: "Unused Term",
description: "Should not appear since it's never referenced" description: "Should not appear since it's never referenced",
), ),
// Term that tests pluralization with custom fields maybe // Term that tests pluralization with custom fields maybe
doc: ( doc: (
short: "doc", short: "doc",
long: "document", long: "document",
description: "A single piece of written matter", description: "A single piece of written matter",
group: "Misc" group: "Misc",
), ),
// Terms that might require checking conflicting modifiers // Terms that might require checking conflicting modifiers
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document describing test procedures", description: "A document describing test procedures",
group: "Testing" group: "Testing",
), ),
// Term that might appear multiple times // Term that might appear multiple times
http: ( http: (
short: "HTTP", short: "HTTP",
long: "Hypertext Transfer Protocol", long: "Hypertext Transfer Protocol",
description: "A protocol for distributed, collaborative, hypermedia information systems", description: "A protocol for distributed, collaborative, hypermedia information systems",
group: "Web" group: "Web",
) ),
) )
// Initialize the glossary with a custom show-term callback // Initialize the glossary with a custom show-term callback
#show: init-glossary.with( #show: init-glossary.with(
exhaustiveGlossary, exhaustiveGlossary,
show-term: (body) => [#strong(body)] show-term: body => [#strong(body)],
) )
#set heading(numbering: "1.1") #set heading(numbering: "1.1")
@@ -294,8 +278,15 @@ This document tries all reference forms and modifiers on a large set of terms.
== Conflicting multiple modifiers combined (short, long, both together) == Conflicting multiple modifiers combined (short, long, both together)
Assert that a panic occurs. Assert that a panic occurs.
#import "/src/gloss.typ": __gls, __default-format-term #import "/src/gloss.typ": __default-format-term, __gls
#let manual-gls(key, mods) = __gls(key, modes-modifiers: mods, format-term: __default-format-term, show-term: (body) => [#strong(body)], term-links: false, display-text: none) #let manual-gls(key, mods) = __gls(
key,
modes-modifiers: mods,
format-term: __default-format-term,
show-term: body => [#strong(body)],
term-links: false,
display-text: none,
)
//- @tps:short:long //- @tps:short:long
#assert-panic(manual-gls.with("tps", ("short", "long"))) #assert-panic(manual-gls.with("tps", ("short", "long")))
//- @tps:short:both //- @tps:short:both
@@ -360,7 +351,7 @@ Assert that a panic occurs.
[`@api:cap` ], [@api:cap], ["capitalize"], [`@api:cap` ], [@api:cap], ["capitalize"],
[`@api:pl` ], [@api:pl], ["plural"], [`@api:pl` ], [@api:pl], ["plural"],
[`@api:long:cap`], [@api:long:cap], ["long + cap"], [`@api:long:cap`], [@api:long:cap], ["long + cap"],
[`@api:both:pl` ], [@api:both:pl], ["both + pl"] [`@api:both:pl` ], [@api:both:pl], ["both + pl"],
) )
== Multiple glossaries with themes and group filtering == Multiple glossaries with themes and group filtering
@@ -377,7 +368,11 @@ Assert that a panic occurs.
== Networking Only == Networking Only
#glossary(title: "Networking Terms", groups: ("Networking",), theme: theme-basic) #glossary(
title: "Networking Terms",
groups: ("Networking",),
theme: theme-basic,
)
== Misc and Data == Misc and Data
@@ -385,17 +380,29 @@ Assert that a panic occurs.
== Just Testing terms == Just Testing terms
#glossary(title: "Testing Terms", groups: ("Testing",), theme: theme-chicago-index) #glossary(
title: "Testing Terms",
groups: ("Testing",),
theme: theme-chicago-index,
)
== Hardware group == Hardware group
#glossary(title: "Hardware Terms", groups: ("Hardware",), theme: theme-chicago-index) #glossary(
title: "Hardware Terms",
groups: ("Hardware",),
theme: theme-chicago-index,
)
== Unreferenced entries == Unreferenced entries
#glossary(title: "Unreferenced (Should Contain Unused?)", groups: ("Security",), theme: theme-chicago-index) #glossary(
title: "Unreferenced (Should Contain Unused?)",
groups: ("Security",),
theme: theme-chicago-index,
)
== Empty group glossary == Empty group glossary
#glossary(title: "Empty Group Glossary", groups: (""), theme: theme-basic) #glossary(title: "Empty Group Glossary", groups: "", theme: theme-basic)
= End of Brutal Test = End of Brutal Test
+5 -2
View File
@@ -25,7 +25,7 @@
#outline(title: "List of Figures", target: figure.where(kind: image)) #outline(title: "List of Figures", target: figure.where(kind: image))
#block( #block(
height: 7em, height: 7em,
glossary(title: "List of Abbreviations", theme: theme-twocol) glossary(title: "List of Abbreviations", theme: theme-twocol),
) )
#line(length: 100%) #line(length: 100%)
@@ -47,7 +47,10 @@
#figure([], caption: [`@ShortInCaption:short` = "@ShortInCaption:short"]) #figure([], caption: [`@ShortInCaption:short` = "@ShortInCaption:short"])
#figure([], caption: [`@LongInCaption:long` = "@LongInCaption:long"]) #figure([], caption: [`@LongInCaption:long` = "@LongInCaption:long"])
#figure([], caption: [`@BothInCaption:both:nospend` = "@BothInCaption:both:nospend"]) #figure(
[],
caption: [`@BothInCaption:both:nospend` = "@BothInCaption:both:nospend"],
)
#figure([], caption: [`@NormalInCaption` = "@NormalInCaption"]) #figure([], caption: [`@NormalInCaption` = "@NormalInCaption"])
#line(length: 100%) #line(length: 100%)
+4 -4
View File
@@ -2,7 +2,7 @@
#show: init-glossary.with(( #show: init-glossary.with((
one: "this is term one", one: "this is term one",
two: "term two also" two: "term two also",
)) ))
#set page( #set page(
@@ -19,15 +19,15 @@ shown anyway.
#glossary( #glossary(
theme: theme-chicago-index, theme: theme-chicago-index,
show-all: true show-all: true,
) )
#glossary( #glossary(
theme: theme-compact, theme: theme-compact,
show-all: true show-all: true,
) )
#glossary( #glossary(
theme: theme-table, theme: theme-table,
show-all: true show-all: true,
) )
+2 -2
View File
@@ -22,11 +22,11 @@
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures" description: "A document on how to run all the test procedures",
), ),
) )
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)]) #show: init-glossary.with(myGlossary, show-term: body => [#emph(body)])
#set page(numbering: "1") #set page(numbering: "1")
+4 -4
View File
@@ -8,7 +8,7 @@
), ),
iphone: ( iphone: (
short: "iPhone", short: "iPhone",
description: "Revolutionized phones." description: "Revolutionized phones.",
), ),
css: ( css: (
short: "CSS", short: "CSS",
@@ -21,11 +21,11 @@
tps: ( tps: (
short: "TPS", short: "TPS",
long: "test procedure specification", long: "test procedure specification",
description: "A document on how to run all the test procedures" description: "A document on how to run all the test procedures",
), ),
) )
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)]) #show: init-glossary.with(myGlossary, show-term: body => [#emph(body)])
#set page( #set page(
margin: 1cm, margin: 1cm,
@@ -50,6 +50,6 @@
inset: 1em, inset: 1em,
stroke: 1pt + gray, stroke: 1pt + gray,
height: if theme.first() == "theme-twocol" { 1.5in } else { auto }, height: if theme.first() == "theme-twocol" { 1.5in } else { auto },
glossary(title: raw(theme.first()), theme: theme.last(), ignore-case: true) glossary(title: raw(theme.first()), theme: theme.last(), ignore-case: true),
) )
} }