Replies: 3 comments 5 replies
-
If I understand correctly, a package for Syntax sugars? |
Beta Was this translation helpful? Give feedback.
-
I'd like to mention that overriding element functions has the big disadvantage that set/show-rules can no longer be applied properly, as the new functions then are not element functions anymore. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the long text, TLDR: idea is good, but that shouldn't be an std enhancement package, but probably a one for composing std functions. Considering the discussion above about the applicability of What you are doing there is not "enhancing" the standard library function. There are cases that would make it harder to work with What you are doing there is combining (composing) standard library functions into a new one, in your case: It could be even upgraded easily by including So what I want to say is that we shouldn't enhance the standard library functions. They are very good on their own, each one for a very wide usage range. If possible, they should be upgraded on compiler level (if the change makes sense). But the idea of having a package that combines these functions may be pretty good. That way we could have An alternative solution: you can write a package with a single function, a function that allows to easily combine functions into one with needed arguments. That way it could be like: // syntax is arguable
#fimage = compose(figure, "caption", image)
#fimage("path.png", "Caption", width: 70%)
// Let's use the same idea for coloring links
#clink = compose(text, "fill", link)
#clink("url.com", "Link text", green)
#clink("bad.com", "Link text", red) In case of links this function isn't really needed, but I'm sure there are lots of examples where this "argument management" is important. In the latter case this package could also include tools for other arguments management, like converting positional <-> named, arguments preprocessing, like mapping or changing the default (like |
Beta Was this translation helpful? Give feedback.
-
Based on my recent showcase on the Typst Discord Server of enhancing the standard
#image
element (see the example below), I'd like to open a discussion on whether there should be a unified "standard element enhancements" package maintained under this GitHub organization and overall governed by the community. While I'm not sure yet if that's a good idea, I have come to believe that it would be a terrible idea to have these kinds of enhancements be individual packages.Proposal
Considering that:
I propose:
typst-community
that combines a set of enhancements for Typst and can be imported from a single package.#image()
,#figure()
, etc.) which can be imported all at once or individually from the package.Example
The following non-breaking enhancement allows
#image
elements to quickly be converted to afigure
by providing an (optional) second argument containing a caption.Library / Package Code
Usage
Beta Was this translation helpful? Give feedback.
All reactions