Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71b91b429c
|
||
|
|
f9dc4de8d0
|
||
|
|
2f257b0b7a
|
||
|
|
3c7ecca2d0 | ||
|
|
afa41697b7 | ||
|
|
127c2c2cc0 | ||
|
|
8f3ef0d1d0
|
||
|
|
4e4e93e096
|
||
|
|
5b0bdf333f
|
||
|
|
a903bf0fc8
|
||
|
|
ee570f7487
|
||
|
|
ef03fdfbc4
|
No files matched your search
@@ -10,10 +10,10 @@ Pretty simple. Import `codly`. Initialize it. Import `codly-languages`.
|
||||
Configure `codly` with the languages. Like this:
|
||||
|
||||
```typst
|
||||
#import "@preview/codly:1.1.1": *
|
||||
#import "@preview/codly:1.2.0": *
|
||||
#show: codly-init
|
||||
|
||||
#import "@preview/codly-languages:0.1.6": *
|
||||
#import "@preview/codly-languages:0.1.7": *
|
||||
#codly(languages: codly-languages)
|
||||
```
|
||||
|
||||
@@ -30,6 +30,7 @@ Some languages are still missing. All contributions welcome.
|
||||
|
||||
| **Icon** | **Source** | **License** |
|
||||
| ----------------- | --------------------------------------------- | -------------------------------- |
|
||||
| `agda.svg` | [Agda][agda-source] | [BSD][agda-license] |
|
||||
| `css3.svg` | [CSS-Next/logo.css][css3-source] | [CC0][css3-license] |
|
||||
| `cuda.svg` | [vscode-icons/vscode-icons][cuda-source] | [MIT][cuda-license] |
|
||||
| `lisp.svg` | [Wikipedia (User:Jooja)][lisp-source] | [CC BY-SA 4.0][lisp-license] |
|
||||
@@ -37,6 +38,8 @@ Some languages are still missing. All contributions welcome.
|
||||
| `splunk.svg` | [denali-design/denali-icons][splunk-source] | [MIT][splunk-license] |
|
||||
| `typst-small.png` | [Dherse/codly][typst-source] | [MIT][typst-license] |
|
||||
|
||||
[agda-source]: https://github.com/agda/agda/blob/master/doc/user-manual/agda.svg
|
||||
[agda-license]: https://github.com/agda/agda/blob/master/LICENSE
|
||||
[css3-source]: https://github.com/CSS-Next/logo.css/blob/main/css.svg?short_path=c59d4da
|
||||
[css3-license]: https://github.com/CSS-Next/logo.css/blob/main/LICENSE
|
||||
[cuda-source]: https://github.com/vscode-icons/vscode-icons/tree/master
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg height="512" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m426.9336548 54.1900978-165.6933289 165.6933098c-7.4750061 6.7402649-17.1710968-3.3855591-10.544754-10.544754l165.6937103-165.6933022c7.0473938-6.7397957 17.3277588 3.0859947 10.5443726 10.5447464zm72.3023071 30.878582-82.8466797 82.8466644c-6.7429504 7.412735 3.4461975 17.2576599 10.5443726 10.5447388l82.8466187-82.8466568c6.6430053-7.568306-3.5616151-17.2775421-10.5443116-10.5447464zm0-41.4233284-82.8466797 82.8466492c-6.7814026 7.4044495 3.1001587 17.2036591 10.5443726 10.544754l82.8466187-82.8466644c6.718811-7.5335541-3.280304-17.0401001-10.5443116-10.5447388zm-289.9637146 0-82.8466568 82.8466492c-6.7649841 7.2203064 3.0957718 17.2232819 10.5447464 10.544754l82.8466644-82.8466644c6.63237-7.2609635-3.0897979-17.2683792-10.544754-10.5447388zm-30.8785858 93.391407 82.8466644-82.8466644c6.6011353-7.0034637-2.9941711-17.398365-10.544754-10.5447464l-82.8466492 82.8466492c-6.6498413 7.3167038 3.1678925 17.1344223 10.5447388 10.5447616zm77.5742798 333.570633c84.3307648.012085 169.9110565-64.1964722 173.1497345-173.1495056l-.0000305-79.7583008 80.6626282-80.6628265c6.6898804-7.4606781-3.3494263-17.2643051-10.5443115-10.544754l-82.8466797 82.8466644c-1.3984375 1.3982391-2.184021 3.2948456-2.184021 5.2723694v82.8468475c-2.4832458 101.8160095-82.3485718 158.2371216-158.2373199 158.2371216-69.5493317 0-155.3547363-52.1512756-158.2371216-158.2371216l.0000076-82.8468475c0-4.1180573-3.3383408-7.4562073-7.4561996-7.4562073h-64.8457071l152.9647408-152.9647332c6.6220093-7.0034561-2.9238739-17.2984962-10.5447388-10.5447464l-165.6933179 165.6933022c-4.5056467 4.6415405-1.5654514 12.7285919 5.2723722 12.7285919l75.3904572-.0000153-.0000076 75.3906555c4.5695434 114.6367493 93.0180297 173.1380616 173.1495147 173.1495057zm-137.93956-309.8466034c0-8.5777893-9.3497391-13.9680176-16.7891388-9.6791229s-7.4393997 15.0693512 0 19.3582458 16.7891388-1.1013336 16.7891388-9.6791229zm41.4234314 0c0-8.5777893-9.3497467-13.9680176-16.7891388-9.6791229-7.4394073 4.2888947-7.4394073 15.0693512 0 19.3582458 7.4393921 4.2888946 16.7891388-1.1013336 16.7891388-9.6791229z"/></svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -4,10 +4,10 @@
|
||||
// To use:
|
||||
//
|
||||
// ```typst
|
||||
// #import "@preview/codly:1.1.1": *
|
||||
// #import "@preview/codly:1.2.0": *
|
||||
// #show: codly-init
|
||||
//
|
||||
// #import "codly-languages.typ": *
|
||||
// #import "codly-languages.typ:0.1.7": *
|
||||
// #codly(languages: codly-languages)
|
||||
// ```
|
||||
#let codly-languages = {
|
||||
@@ -25,6 +25,7 @@
|
||||
(
|
||||
aarch64: (name: "Assembly (ARM)", color: rgb("#1b3888"), icon: __icon("aarch64.svg")),
|
||||
arm: (name: "Assembly (ARM)", color: rgb("#1b3888"), icon: __icon("aarch64.svg")),
|
||||
agda: (name: "Agda", color: rgb("#ffffff"), icon: __icon("agda.svg")),
|
||||
angular: (name: "Angular", color: rgb("#dd0031"), icon: __icon("angular.svg")),
|
||||
ansible: (name: "Ansible", color: rgb("#1a1918"), icon: __icon("ansible.svg")),
|
||||
apache: (name: "Apache", color: rgb("#b7342a"), icon: __icon("apache.svg")),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#import "/lib.typ": *
|
||||
#import "@preview/codly:1.1.1": *
|
||||
#import "@preview/codly:1.2.0": *
|
||||
#show: codly-init
|
||||
#codly(languages: codly-languages)
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 75 KiB |
@@ -2,6 +2,7 @@
|
||||
|
||||
#let base-languages = (
|
||||
"aarch64",
|
||||
"agda",
|
||||
"angular",
|
||||
"ansible",
|
||||
"apache",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "codly-languages"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
entrypoint = "lib.typ"
|
||||
authors = ["Stephen Waits <steve@waits.net>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -41,7 +41,7 @@ different goals:
|
||||
### Import the package
|
||||
|
||||
```typst
|
||||
#import "@preview/glossy:0.5.2": *
|
||||
#import "@preview/glossy:0.6.0": *
|
||||
```
|
||||
|
||||
### Defining Glossary Terms
|
||||
@@ -143,6 +143,7 @@ Available modifiers:
|
||||
- **short**: Shows only short form
|
||||
- **long**: Shows only long form
|
||||
- **def** or **desc**: Shows the description
|
||||
- **noref** or **noindex**: Don't show the term in the glossary.
|
||||
- **a** or **an**: Include the article (`an` is just an alias of `a`, they're
|
||||
equivalent)
|
||||
|
||||
@@ -160,6 +161,9 @@ Modifiers can be combined with colons:
|
||||
| `@tps:short:pl` | "TPSes" |
|
||||
| `@tps:both:pl:cap` | "Technical procedure specifications (TPSes)" |
|
||||
| `@tps:def` | "A formal document describing test steps and expected results" |
|
||||
| `@tps:desc` | _same as above, `desc` is an alias for `def`_ |
|
||||
| `@tps:noref` | _works as normal, just won't show up in glossary_ |
|
||||
| `@tps:noindex` | _same as above, `noindex` is an alias for `noref`_ |
|
||||
|
||||
The `a`/`an` modifier is special because it can either precede or follow the
|
||||
term's key.
|
||||
@@ -180,6 +184,18 @@ For example:
|
||||
Note that the `a`/`an` (article) modifier cannot be combined with the `pl`
|
||||
(plural) modifier.
|
||||
|
||||
### First use logic
|
||||
|
||||
Any use of the `short`, `long`, or `both` modifier will not count against the
|
||||
term's first use.
|
||||
|
||||
This is useful, for example, when you want to use a term in a heading or a
|
||||
caption. In that case, your term might end up in an `outline()` at the top of
|
||||
your document. Normally you don't want that to count as a term's first real use.
|
||||
Normally you want that to happen in the body of your document. So, by using
|
||||
these modifiers in such situations, you can not only specify exactly how you
|
||||
want your term to appear, but also control whether it counts as a "first use".
|
||||
|
||||
### Generating the Glossary
|
||||
|
||||
Display the glossary using the `glossary()` function:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#let __gloss_entries = state("__gloss_entries", (:))
|
||||
|
||||
#let __gloss_label_prefix = "__gloss:"
|
||||
#let __gloss_first_use_counter_postfix = ":first-use-count"
|
||||
|
||||
// Normalizes a dictionary entry by ensuring all required and optional keys exist
|
||||
// with appropriate default values.
|
||||
@@ -129,11 +130,14 @@
|
||||
// Returns:
|
||||
// none: Updates state as a side effect
|
||||
//
|
||||
#let __mark_term_used(key) = {
|
||||
#let __mark_term_used(key, count-as-first-use) = {
|
||||
counter(__gloss_label_prefix + key).step()
|
||||
if count-as-first-use {
|
||||
counter(__gloss_label_prefix + key + __gloss_first_use_counter_postfix).step()
|
||||
}
|
||||
}
|
||||
|
||||
// Queries the term usage
|
||||
// Queries whether the term is used ANYWHERE
|
||||
//
|
||||
// Parameters:
|
||||
// key (string): The glossary entry key
|
||||
@@ -142,12 +146,29 @@
|
||||
// Returns:
|
||||
// boolean: If the entry is used above the location in the document
|
||||
//
|
||||
#let __is_term_used(key, location: none) = {
|
||||
#let __is_term_ever_used(key, location: none) = {
|
||||
let c = counter(__gloss_label_prefix + key)
|
||||
c = if location == none {c.final()} else {c.at(location)}
|
||||
c.at(0) > 0
|
||||
}
|
||||
|
||||
// Queries whether the term has been "first used"
|
||||
//
|
||||
// "First used" is used to determine how to display the term, either "long
|
||||
// (short)" or just "(short)"
|
||||
//
|
||||
// Parameters:
|
||||
// key (string): The glossary entry key
|
||||
// location (location): The location in the document. Use none for end of document
|
||||
//
|
||||
// Returns:
|
||||
// boolean: If the entry is used above the location in the document
|
||||
//
|
||||
#let __is_term_first_used(key, location: none) = {
|
||||
let c = counter(__gloss_label_prefix + key + __gloss_first_use_counter_postfix)
|
||||
c = if location == none {c.final()} else {c.at(location)}
|
||||
c.at(0) > 0
|
||||
}
|
||||
|
||||
// Determine if the glossary contains a visible entry
|
||||
//
|
||||
@@ -216,8 +237,12 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Manage term usage counting and determine if it's the first reference
|
||||
// ---------------------------------------------------------------------------
|
||||
let is_first_use = not __is_term_used(key, location: here())
|
||||
__mark_term_used(key)
|
||||
let is_first_use = not __is_term_first_used(key, location: here())
|
||||
let count-as-first-use = ("short" not in modifiers and "long" not in modifiers and "both" not in modifiers)
|
||||
let wants_reference = ("noref" not in modifiers and "noindex" not in modifiers)
|
||||
if wants_reference {
|
||||
__mark_term_used(key, count-as-first-use)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
@@ -342,12 +367,17 @@
|
||||
} else {
|
||||
term
|
||||
}
|
||||
[#article#show-term(linked-term)#metadata(term)#__term_label(key)]
|
||||
let term-label = if wants_reference {
|
||||
__term_label(key)
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
[#article#show-term(linked-term)#metadata(term)#term-label]
|
||||
// |^^^^^^^|^^^^^^^^^ |^^^^^^^^ |^^^^^^^^^^^^
|
||||
// \_art. | | |
|
||||
// \_ apply user formatting function to the term
|
||||
// | |
|
||||
// \_ metadata lets us label (ie it's "labelable")
|
||||
// \_ metadata lets us label (ie makes it "labelable")
|
||||
// |
|
||||
// \_ i.e. <__gloss:key>, etc.
|
||||
// for backlink from glossary
|
||||
@@ -554,7 +584,7 @@
|
||||
// Collect and organize entries by group
|
||||
let output = (:)
|
||||
let all_entries = __gloss_entries.final()
|
||||
let all_used = all_entries.keys().filter(key => __is_term_used(key))
|
||||
let all_used = all_entries.keys().filter(key => __is_term_ever_used(key))
|
||||
|
||||
// Determine which groups to process
|
||||
let all_groups = all_entries
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Inspired by academic textbook glossaries
|
||||
#let theme-academic = (
|
||||
section: (title, body) => {
|
||||
set text(font: "New Computer Modern")
|
||||
heading(level: 1, title)
|
||||
v(1em)
|
||||
body
|
||||
|
||||
|
Before Width: | Height: | Size: 479 KiB After Width: | Height: | Size: 489 KiB |
|
Before Width: | Height: | Size: 844 KiB After Width: | Height: | Size: 884 KiB |
@@ -47,6 +47,8 @@ Now make sure I get @tps:a:SHORT report by 2pm! @an:tps:cap is very important!!!
|
||||
[`@tps:both:pl:cap`], [@tps:both:pl:cap],
|
||||
[`@tps:def` ], [@tps:def],
|
||||
[`@tps:desc` ], [@tps:desc],
|
||||
[`@tps:noref` ], [@tps:noref *(not listed in glossary)*],
|
||||
[`@tps:noindex` ], [@tps:noindex *(not listed in glossary)*],
|
||||
)
|
||||
|
||||
== Adding articles via `a`/`an` modifiers
|
||||
|
||||
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 195 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 139 KiB |
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 179 KiB |
|
After Width: | Height: | Size: 55 KiB |
@@ -0,0 +1,26 @@
|
||||
#import "/lib.typ": *
|
||||
|
||||
// Our test glossary
|
||||
#show: init-glossary.with((
|
||||
Normal: "this is a normal term",
|
||||
NoRef: "this term is noref'd",
|
||||
NoIndex: "this term is noindex'd",
|
||||
NoRefNoIndex: "this term is noref'd and noindex'd",
|
||||
))
|
||||
|
||||
// Configure styling
|
||||
|
||||
#set page(margin: 1em)
|
||||
#set page(width: 3.5in)
|
||||
#set page(height: auto)
|
||||
#set text(size: 10pt)
|
||||
|
||||
@Normal
|
||||
|
||||
@NoRef:noref
|
||||
|
||||
@NoIndex:noindex
|
||||
|
||||
@NoRefNoIndex:noref:noindex
|
||||
|
||||
#glossary()
|
||||
|
After Width: | Height: | Size: 674 KiB |
@@ -0,0 +1,82 @@
|
||||
#import "/lib.typ": *
|
||||
|
||||
// Our test glossary
|
||||
#show: init-glossary.with((
|
||||
ShortInHeader: "short used in header",
|
||||
ShortInCaption: "short used in caption",
|
||||
LongInHeader: "long used in header",
|
||||
LongInCaption: "long used in caption",
|
||||
BothInHeader: "both used in header",
|
||||
BothInCaption: "both used in caption",
|
||||
NormalInHeader: "unmodified use in header",
|
||||
NormalInCaption: "unmodified use in caption",
|
||||
))
|
||||
|
||||
// Configure styling
|
||||
|
||||
#set page(numbering: "1")
|
||||
#set page(margin: 0.5in)
|
||||
#set page(height: auto)
|
||||
#set text(size: 10pt)
|
||||
|
||||
// Outlines
|
||||
|
||||
#outline(title:"Table of Contents", indent: auto)
|
||||
#outline(title: "List of Figures", target: figure.where(kind: image))
|
||||
#block(
|
||||
height:7em,
|
||||
glossary(title: "List of Abbreviations", theme: theme-twocol)
|
||||
)
|
||||
|
||||
#line(length: 100%)
|
||||
|
||||
// Doc Body
|
||||
|
||||
// Use all the terms in headings
|
||||
#heading(level: 1, outlined: false, [Use terms in HEADERS])
|
||||
|
||||
=== `@ShortInHeader:short` = "@ShortInHeader:short"
|
||||
=== `@LongInHeader:long` = "@LongInHeader:long"
|
||||
=== `@BothInHeader:both` = "@BothInHeader:both"
|
||||
=== `@NormalInHeader` = "@NormalInHeader"
|
||||
|
||||
#line(length: 100%)
|
||||
|
||||
// Use all the terms in captions
|
||||
#heading(level: 1, outlined: false, [Use terms in CAPTIONS])
|
||||
|
||||
#figure([], caption: [`@ShortInCaption:short` = "@ShortInCaption:short"])
|
||||
#figure([], caption: [`@LongInCaption:long` = "@LongInCaption:long"])
|
||||
#figure([], caption: [`@BothInCaption:both` = "@BothInCaption:both"])
|
||||
#figure([], caption: [`@NormalInCaption` = "@NormalInCaption"])
|
||||
|
||||
#line(length: 100%)
|
||||
|
||||
// Now use the terms in the body to see if they handle "first use" correctly
|
||||
#heading(level: 1, outlined: false, [Use terms in BODY])
|
||||
|
||||
First `@ShortInHeader` = "@ShortInHeader".
|
||||
Second `@ShortInHeader` = "@ShortInHeader"
|
||||
|
||||
First `@LongInHeader` = "@LongInHeader".
|
||||
Second `@LongInHeader` = "@LongInHeader".
|
||||
|
||||
First `@BothInHeader` = "@BothInHeader".
|
||||
Second `@BothInHeader` = "@BothInHeader".
|
||||
|
||||
First `@NormalInHeader` = "@NormalInHeader".
|
||||
Second `@NormalInHeader` = "@NormalInHeader".
|
||||
|
||||
#v(0.5em)
|
||||
|
||||
First `@ShortInCaption` = "@ShortInCaption".
|
||||
Second `@ShortInCaption` = "@ShortInCaption"
|
||||
|
||||
First `@LongInCaption` = "@LongInCaption".
|
||||
Second `@LongInCaption` = "@LongInCaption".
|
||||
|
||||
First `@BothInCaption` = "@BothInCaption".
|
||||
Second `@BothInCaption` = "@BothInCaption".
|
||||
|
||||
First `@NormalInCaption` = "@NormalInCaption".
|
||||
Second `@NormalInCaption` = "@NormalInCaption".
|
||||
|
Before Width: | Height: | Size: 651 KiB After Width: | Height: | Size: 651 KiB |
|
Before Width: | Height: | Size: 651 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 117 KiB |
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "glossy"
|
||||
version = "0.5.2"
|
||||
version = "0.6.0"
|
||||
entrypoint = "lib.typ"
|
||||
authors = ["Stephen Waits <steve@waits.net>"]
|
||||
license = "MIT"
|
||||
|
||||