Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86f16a7ac0
|
No files matched your search
@@ -41,7 +41,7 @@ different goals:
|
||||
### Import the package
|
||||
|
||||
```typst
|
||||
#import "@preview/glossy:0.2.1": *
|
||||
#import "@preview/glossy:0.2.2": *
|
||||
```
|
||||
|
||||
### Defining Glossary Terms
|
||||
|
||||
@@ -271,35 +271,28 @@
|
||||
// Example output: "1, 3, 5" where each number links to the term usage on that page
|
||||
//
|
||||
#let __create_backlinks(key, count) = {
|
||||
// Generate labels for each term usage
|
||||
let labels = for i in range(count) {
|
||||
(__term_label(key, i),)
|
||||
// Convert term (key + count) to labels with their displayed page numbers
|
||||
let page_labels = range(count).map(i => {
|
||||
let label = __term_label(key, i)
|
||||
let loc = locate(label)
|
||||
(
|
||||
label,
|
||||
numbering(__default(loc.page-numbering(), "1"), ..counter(page).at(loc))
|
||||
)
|
||||
})
|
||||
|
||||
// Filter out repeated page numbers using a regular loop
|
||||
let seen = (:)
|
||||
let singulated = ()
|
||||
for (label, page) in page_labels {
|
||||
if not seen.keys().contains(page) {
|
||||
seen.insert(page, true)
|
||||
singulated.push((label, page))
|
||||
}
|
||||
}
|
||||
|
||||
// Get page numbers for each usage
|
||||
let pages = labels
|
||||
.map(l => locate(l))
|
||||
.map(loc => numbering(
|
||||
__default(loc.page-numbering(), "1"),
|
||||
loc.page()
|
||||
))
|
||||
|
||||
// Create links, excluding duplicate page numbers
|
||||
let seen = ()
|
||||
let links = for i in range(labels.len()) {
|
||||
let label = labels.at(i)
|
||||
let page = pages.at(i)
|
||||
|
||||
if seen.contains(page) {
|
||||
(none,)
|
||||
} else {
|
||||
seen.push(page)
|
||||
(link(label, page),)
|
||||
}
|
||||
}.filter(l => l != none)
|
||||
|
||||
// Join links with commas
|
||||
links.join(", ")
|
||||
// Convert resulting set to array of links
|
||||
singulated.map(((label, page)) => link(label, page)).join(", ")
|
||||
}
|
||||
|
||||
// Initializes the glossary system and sets up term reference handling.
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
#import "themes/basic.typ": theme-basic
|
||||
#import "themes/chicago-index.typ": theme-chicago-index
|
||||
#import "themes/compact.typ": theme-compact
|
||||
#import "themes/table.typ": theme-table
|
||||
#import "themes/twocol.typ": theme-twocol
|
||||
@@ -0,0 +1,32 @@
|
||||
// A tabular theme courtesy of [@Fevol](https://github.com/Fevol)
|
||||
#let theme-table = (
|
||||
section: (title, body) => {
|
||||
heading(level: 1, title)
|
||||
body
|
||||
},
|
||||
|
||||
group: (name, index, total, body) => {
|
||||
if name != "" and total > 1 {
|
||||
heading(level: 2, name)
|
||||
}
|
||||
|
||||
table(columns: 4,
|
||||
stroke: none,
|
||||
inset: (x, y) => {
|
||||
if (x == 0) {
|
||||
(left: 0pt, rest: 5pt)
|
||||
} else if (x == 3) {
|
||||
(right: 0pt, rest: 5pt)
|
||||
} else {
|
||||
5pt
|
||||
}
|
||||
},
|
||||
table.header([*Abbreviation*], [*Full Name*], [*Description*], [*Pages*]),
|
||||
..body
|
||||
)
|
||||
},
|
||||
|
||||
entry: (entry, index, total) => {
|
||||
(entry.short, entry.long, entry.description, entry.pages)
|
||||
}
|
||||
)
|
||||
|
Before Width: | Height: | Size: 606 KiB After Width: | Height: | Size: 606 KiB |
@@ -22,6 +22,7 @@
|
||||
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)])
|
||||
|
||||
#set heading(numbering: "1.1")
|
||||
#set page(numbering: "1")
|
||||
|
||||
= Hello, `glossy`!
|
||||
In modern web development, languages like @html and @css are essential.
|
||||
|
||||
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 133 KiB |
@@ -0,0 +1,51 @@
|
||||
#import "/lib.typ": *
|
||||
|
||||
#let myGlossary = (
|
||||
html: (
|
||||
short: "HTML",
|
||||
long: "Hypertext Markup Language",
|
||||
description: "A standard language for creating web pages",
|
||||
),
|
||||
iphone: (
|
||||
short: "iPhone",
|
||||
),
|
||||
css: (
|
||||
short: "CSS",
|
||||
long: "Cascading Style Sheets",
|
||||
description: "A language used for describing the presentation of a document",
|
||||
),
|
||||
atom: (
|
||||
short: "atom",
|
||||
),
|
||||
tps: (
|
||||
short: "TPS",
|
||||
long: "test procedure specification",
|
||||
description: "A document on how to run all the test procedures"
|
||||
),
|
||||
)
|
||||
|
||||
#show: init-glossary.with(myGlossary)
|
||||
|
||||
#set page(numbering: "i")
|
||||
|
||||
@html, @iphone, @css
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#set page(numbering: "1")
|
||||
|
||||
@html, @iphone, @css, @atom
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#counter(page).update(1)
|
||||
#set page(numbering: "A")
|
||||
|
||||
@html, @iphone, @css, @tps
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#set page(numbering: "I")
|
||||
@css, @iphone, @tps
|
||||
|
||||
#glossary(theme: theme-chicago-index, ignore-case: true)
|
||||
|
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 259 KiB |
@@ -28,6 +28,8 @@
|
||||
|
||||
#show: init-glossary.with(myGlossary, show-term: (body) => [#emph(body)])
|
||||
|
||||
#set page(numbering: "1")
|
||||
|
||||
= Refer to our terms so they show up in the glossary
|
||||
@html, @iphone:long, @css, @css:cap:pl, @atom:pl, @tps:long
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 521 KiB After Width: | Height: | Size: 651 KiB |
@@ -30,6 +30,7 @@
|
||||
#set page(
|
||||
margin: 1cm,
|
||||
height: auto,
|
||||
numbering: "1",
|
||||
)
|
||||
|
||||
#text(size: 24pt, weight: "bold")[`glossy`: theme gallery]
|
||||
|
||||
|
Before Width: | Height: | Size: 521 KiB After Width: | Height: | Size: 651 KiB |
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "glossy"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
entrypoint = "lib.typ"
|
||||
authors = ["Stephen Waits <steve@waits.net>"]
|
||||
license = "MIT"
|
||||
|
||||