-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a43488b
commit b787229
Showing
12 changed files
with
243 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#let theorem-kind = (link-to: 0, numbering: 0) | ||
|
||
/// TODO | ||
/// | ||
/// - name (content, str): The name of the #ref-type("theorem"). | ||
/// - link-to (label, selector, selector-function, none): Link the #ref-type("theorem") | ||
/// to some other content. For #ref-type("label")s and #ref-type("selector")s the last | ||
/// match before the #ref-type("theorem") is used. | ||
/// - numbering (theorem-numbering-function, none): See #ref-type("theorem-numbering-function") | ||
/// for more information. Can be set to #ref-type("none") for unnumbered #ref-type("theorem")s. | ||
/// - body (content): | ||
/// -> theorem | ||
#let theorem-function(name: none, link-to: theorem-kind.link-to, numbering: theorem-kind.numbering, body) = 0 | ||
|
||
/// Create combined numberings from `theorem` and the content linked to it. | ||
/// | ||
/// There are two pre-defined #ref-type("theorem-numbering-function")s: @@numbering-concat() and @@numbering-proof(). | ||
/// | ||
/// - thm (theorem): The `theorem` for which the numbering should be generated. | ||
/// See also @@get-theorem-parameters(). | ||
/// - referenced (bool): This is false if | ||
/// the numbering was requested from the `theorem` it belongs to. | ||
/// Otherwise it is false. See @@numbering-proof() as an example. | ||
/// -> content | ||
#let theorem-numbering-function(thm, referenced) = 0 | ||
|
||
/// Defines how the #ref-type("theorem") will look. Use @@get-theorem-parameters() to get | ||
/// all information stored in the #ref-type("theorem"). | ||
/// | ||
/// There are two pre-defined #ref-type("style-function")s: @@style-simple() and @@style-reversed(). | ||
/// | ||
/// - thm (theorem): | ||
/// -> content | ||
#let style-function(thm) = 0 | ||
|
||
/// Useful for more advanced queries. See @@last-heading() for an example. | ||
/// | ||
/// - loc (location): When used in `link-to` parameter | ||
/// of some #ref-type("theorem") its #ref-type("location") | ||
/// will be passed when resolving the link with @@resolve-link(). | ||
/// -> content, none | ||
#let selector-function(loc) = 0 | ||
|
||
/// A normal numbering function as described | ||
/// in the #show-link("https://typst.app/docs/reference/meta/numbering/#parameters-numbering")[typst documentation]. | ||
/// | ||
/// - ..state (int): | ||
/// -> content | ||
#let numbering-function(..state) = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,130 @@ | ||
#import "@preview/tidy:0.1.0": parse-module, show-module | ||
|
||
#let lib-parsed = parse-module(read("../src/lib.typ")) | ||
#let reset-counter-parsed = parse-module(read("../src/reset-counter.typ")) | ||
#let selectors-parsed = parse-module(read("../src/selectors.typ")) | ||
#let styles-parsed = parse-module(read("../src/styles.typ")) | ||
#let numbered-parsed = parse-module(read("../src/numbered.typ")) | ||
#let theorem-parsed = parse-module(read("../src/theorem.typ")) | ||
#import "@preview/tidy:0.1.0": parse-module, show-module, styles | ||
|
||
#let custom-type-colors = ( | ||
"theorem-function": rgb("#f9dfff"), | ||
"theorem-numbering-function": rgb("#f9dfff"), | ||
"numbering-function": rgb("#f9dfff"), | ||
"style-function": rgb("#f9dfff"), | ||
"selector-function": rgb("#f9dfff"), | ||
"theorem": rgb("#fff173"), | ||
"numbered": rgb("#bfb3ff") | ||
) | ||
|
||
#let type-colors = ( | ||
"content": rgb("#a6ebe6"), | ||
"color": rgb("#a6ebe6"), | ||
"str": rgb("#d1ffe2"), | ||
"none": rgb("#ffcbc4"), | ||
"auto": rgb("#ffcbc4"), | ||
"bool": rgb("#ffedc1"), | ||
"int": rgb("#e7d9ff"), | ||
"float": rgb("#e7d9ff"), | ||
"ratio": rgb("#e7d9ff"), | ||
"length": rgb("#e7d9ff"), | ||
"angle": rgb("#e7d9ff"), | ||
"relative-length": rgb("#e7d9ff"), | ||
"fraction": rgb("#e7d9ff"), | ||
"symbol": rgb("#eff0f3"), | ||
"array": rgb("#eff0f3"), | ||
"dictionary": rgb("#eff0f3"), | ||
"arguments": rgb("#eff0f3"), | ||
"selector": rgb("#eff0f3"), | ||
"module": rgb("#eff0f3"), | ||
"stroke": rgb("#eff0f3"), | ||
"function": rgb("#f9dfff"), | ||
..custom-type-colors | ||
) | ||
|
||
#let get-type-color(type) = type-colors.at(type, default: rgb("#eff0f3")) | ||
|
||
#let link-color = blue.darken(50%) | ||
|
||
#let ref-type(type, text-color: link-color) = { | ||
if type in custom-type-colors { | ||
link(label(type + "()"), text(text-color, raw(type))) | ||
} else { | ||
text(text-color, raw(type)) | ||
} | ||
} | ||
|
||
#let show-link(url, txt) = { | ||
link(url)[#text(link-color, txt)] | ||
} | ||
|
||
#let show-type(type) = { | ||
h(2pt) | ||
box(outset: 2pt, fill: get-type-color(type), radius: 2pt, ref-type(type, text-color: black)) | ||
h(2pt) | ||
} | ||
|
||
#let style = ( | ||
show-type: show-type, | ||
show-outline: styles.default.show-outline, | ||
show-function: styles.default.show-function, | ||
show-parameter-list: styles.default.show-parameter-list, | ||
show-parameter-block: styles.default.show-parameter-block | ||
) | ||
|
||
#let parse-module-params = ( | ||
scope: ( | ||
ref-type: ref-type, | ||
show-link: show-link | ||
) | ||
) | ||
|
||
#let show-module-params = ( | ||
style: style, | ||
show-module-name: false, | ||
show-outline: false, | ||
sort-functions: none, | ||
) | ||
|
||
#let lib-parsed = parse-module(read("../src/lib.typ"), ..parse-module-params) | ||
#let reset-counter-parsed = parse-module(read("../src/reset-counter.typ"), ..parse-module-params) | ||
#let selectors-parsed = parse-module(read("../src/selectors.typ"), ..parse-module-params) | ||
#let styles-parsed = parse-module(read("../src/styles.typ"), ..parse-module-params) | ||
#let numbered-parsed = parse-module(read("../src/numbered.typ"), ..parse-module-params) | ||
#let theorem-parsed = parse-module(read("../src/theorem.typ"), ..parse-module-params) | ||
#let function-types-parsed = parse-module(read("function-types.typ"), ..parse-module-params) | ||
|
||
= Documentation | ||
|
||
#show-module(lib-parsed) | ||
#show-module(lib-parsed, ..show-module-params) | ||
|
||
== Styles | ||
== Function types | ||
|
||
There are a few pre-defined `style-function`s and `theorem-numbering-function`s. | ||
#show-module(function-types-parsed, ..show-module-params) | ||
|
||
#show-module(styles-parsed) | ||
== theorem | ||
#label("theorem()") | ||
|
||
== Selectors | ||
A #ref-type("theorem") is a #ref-type("figure") with some additional | ||
information stored in one of its parameters. | ||
|
||
The selectors can be used in show-rules to | ||
customize the `theorem`s styling as well as | ||
with the `link-to` parameter. | ||
#show-module(theorem-parsed, ..show-module-params) | ||
|
||
#show-module(selectors-parsed) | ||
== numbered | ||
#label("numbered()") | ||
|
||
== Resetting counters | ||
A #ref-type("numbered") is a #ref-type("heading"), #ref-type("page"), | ||
#ref-type("math.equation") or #ref-type("figure") that is already embedded | ||
in the document (that means it was obtained by a query). The `numbering` | ||
also has to be different from #ref-type("none"). | ||
|
||
#show-module(reset-counter-parsed) | ||
#show-module(numbered-parsed, ..show-module-params) | ||
|
||
== Theorem utilities | ||
== Styles | ||
|
||
The functions in the remaining two sections are only needed when defining custom style or | ||
theorem-numbering-functions. | ||
#show-module(styles-parsed, ..show-module-params) | ||
|
||
#show-module(theorem-parsed) | ||
== Selectors | ||
|
||
The selectors can be used in show-rules to | ||
customize the #ref-type("theorem")s styling as well as | ||
with the `link-to` parameter. | ||
|
||
#show-module(selectors-parsed, ..show-module-params) | ||
|
||
== Numbered utilities | ||
== Resetting counters | ||
|
||
#show-module(numbered-parsed) | ||
#show-module(reset-counter-parsed, ..show-module-params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.