Skip to content

Improve repr for SequenceElem - #3584

Merged
laurmaedje merged 6 commits into
typst:mainfrom
MDLC01:better-sequence-repr
Apr 2, 2024
Merged

laurmaedje merged 6 commits into
typst:mainfrom
MDLC01:better-sequence-repr

Conversation

@MDLC01

@MDLC01 MDLC01 commented Mar 8, 2024

Copy link
Copy Markdown
Collaborator

This small PR changes the repr for sequences so that it it valid Typst code and less confusing.

For comparison, the old repr looked like the following:

[(
  [A],
  h(10pt),
  bold(body: [B]),
)]

And here is the new one:

(
  [A]
    + h(10pt)
    + bold(body: [B])
)

Another solution was to use the join syntax:

{
  [A]
  h(10pt)
  bold(body: [B])
}

but I think the + syntax is more explicit.

@Leedehai

Copy link
Copy Markdown
Contributor

I have some reservations about the + symbol, because it adds "noise" that is not part of the sequence itself, and it may confuse people (especially if the elements contain + somewhere themselves..).

I think the original is fine, or the alternative one i.e. {...}.

@MDLC01

MDLC01 commented Mar 10, 2024

Copy link
Copy Markdown
Collaborator Author

I think the original is fine

I have to disagree on this specific point. The reason why I made this PR in the first place is because I saw the current repr while debugging a Typst template, and I was unable to determine what this was representing. I had to look at different Repr implementations in the compiler to understand what it was, because it is so far from any existing syntax.

I'm fine with using the join syntax ({..}) instead, though. But I prefer to wait for at least one other feedback before (we have time, it's not like this needs to be included in 0.11.0).

@PgBiel

PgBiel commented Mar 20, 2024

Copy link
Copy Markdown
Contributor

The original is indeed a bit confusing, in the sense that it seems to try to mimic markup and code mode at the same time. Perhaps a better (and more accurate) representation is sequence(a, b, c, ...).

@MDLC01

MDLC01 commented Mar 20, 2024

Copy link
Copy Markdown
Collaborator Author

I think this is how it used to be a while ago. I wanted to make it valid Typst here. Maybe sequence is better though...

@laurmaedje

laurmaedje commented Apr 1, 2024 •

Copy link
Copy Markdown
Member

The current one is indeed pretty weird, don't know where that came from. I'm not a big fan of the one with addition. From the ones in the PR description, I like the code block one best, but sequence(..) is probably the clearest one. I also intend to make sequence public alongside the rework from element functions into types, which would then make it valid Typst code.

@laurmaedje

Copy link
Copy Markdown
Member

There is a conflict now. There's also a problem with the checks apparently, but I think that would be fixed just by merging main into this PR.

@MDLC01

MDLC01 commented Apr 2, 2024

Copy link
Copy Markdown
Collaborator Author

I'm working on the conflict.

@MDLC01

MDLC01 commented Apr 2, 2024

Copy link
Copy Markdown
Collaborator Author

All good now!

Comment thread MDLC01/test.typ Resolved
@laurmaedje
laurmaedje enabled auto-merge April 2, 2024 12:46
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

@laurmaedje
laurmaedje added this pull request to the merge queue Apr 2, 2024
Merged via the queue into typst:main with commit c400166 Apr 2, 2024
@MDLC01
MDLC01 deleted the better-sequence-repr branch April 2, 2024 12:56
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants