Allow somewhat arbitrary characters as mat, vec and cases delim#4211
Allow somewhat arbitrary characters as mat, vec and cases delim#4211laurmaedje merged 10 commits intotypst:mainfrom
mat, vec and cases delim#4211Conversation
|
Is there a specific reason why there is so much duplication when it comes to delimiters? To me, it seems like typst should "know" what all the scalable delimiters are, and allow them where appropriate (matrices, vectors, cases, possibly more?) |
|
I'm not sure exactly, but I figured we needed an enum like Also, matrices, vectors and cases already share the same |
Does that mean cases automatically gets these as well? |
Yes, it does! |
|
While you're at it, you may as well add triple bars as well. (There are plenty of other delimiters too, but most are very obscure) |
|
I'm also opening to discussing a design where we can directly use all Unicode opening/closing delimiters. Maybe something where the delimiter is directly passed as math content instead of a string? (We can also support both for a while.) |
|
This PR is quickly becoming a mess, mainly due to me trying to do too many things at once. Maybe we should close it and discuss a design that would allow specifying any pair of delimiters? |
|
I didn't mean to derail this PR. The other changes could be a future one? |
|
If we opt for a design similar to |
mat, vec and cases delim
|
I implemented the ability to use any Unicode "opening", "closing" or "fence" character. See the updated PR description for more information. |
laurmaedje
left a comment
There was a problem hiding this comment.
I like this.
|| is not supported anymore, correct? I think that's fine, but it is a breaking change, so notable.
Indeed. Moreover, |
Not a big deal I think. Thank you! |
Refactor frame metadata into tags (typst#4212) Require `Send` and `Sync` for worlds (typst#4219) Optimize counters and state (typst#4223) Add `windows` method to array (typst#4136) Improve `CITATION.cff` file (typst#4201) Fix equation resizing when adding the equation number (typst#4179) `layout` documentation improvements (typst#4196) Allow somewhat arbitrary characters as `mat`, `vec` and `cases` `delim` (typst#4211) Do layout short-circuit in flow instead of realization (typst#4231) Split `BitSet` into two types and make it a bit nicer (typst#4249) Set default value of `raw.theme` to `auto`, and allow setting `raw.theme` to `auto` (typst#4186) Extended cargo installation instructions (typst#4168) Hint for language-region pair on `text.lang` (typst#4183) Improve macro docs (+ Native*Data docs) (typst#4240) Rephrase the sentence on variable scope in Scripting documentation (typst#4250) Refactor `Capable::vtable` to return `Option<NonNull<()>>` (typst#4252) Nicer test helper CSS (typst#4269) Trim weak spacing at line start/end in paragraph layout (typst#4087) Add ability to choose between minified and pretty-printed JSON (typst#4161) Refactor PDF export (typst#4154) Reorder syntax kinds (typst#4287) Fix figure centering (typst#4276) Fix `Default` impls for AST nodes (typst#4288) Bump libc to v0.2.155 (typst#4268) Bump time dependency (typst#4294)
This PR implement the design that was briefly discussed on Discord.
delimcan now be specified in one of the following form.none, for no delimiters.A delimiter to use as the opening delimiter. The closing delimiter is inferred automatically.
delim: ")"results in inverted parentheses.An array of two delimiters to use respectively as the opening delimiter and as the closing delimiter.
In the definition above, the term "delimiter" refers to a value of one of th following forms.
none, for no delimiter.A
symbol, or a single-characterstr."somewhat arbitrary" in the PR title refers to the fact that only "opening", "closing" and "fence" characters are allowed.
Original description.
This PR adds double brackets, triple bars, and angles as valid
mat,vec, andcasesdelims.I also made it possible to use Unicode characters to specify the delimiters (specifically,
"⟦"for double brackets,"‖"for double bars,"⦀"for triple bars, and"⟨"for angles).Regarding other potential delimiters, I tried double angles, but they did not seem to work in the tests (instead resulting in a box glyph), and fences and double fences, which do not scale.
For reference, below are all the possible delimiters:
