Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Revision of the Context documentation#6008

Open
ukoethe wants to merge20 commits intotypst:main
base:main
Choose a base branch
Loading
fromukoethe:context-documentation

Conversation

ukoethe
Copy link

@ukoetheukoethe commentedMar 4, 2025
edited
Loading

This is a pull request to discuss documentation improvements. I edited most of thecontext documentation to give an idea what I would find helpful. Please use the inline comment function for discussion.

Copy link
Collaborator

@MDLC01MDLC01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I prefer the old version of the last paragraph, but appart from that I like the changes.

Comment on lines 60 to 73
The output of a `#context ...` call is _read-only_ (in the form of `[content]`).
Allowing write access would likely result in invalid code, because the context
might have already changed in the meantime. Therefore, temporary changes of
settings must be done within the context, and they are only active until the
end of the context's scope:

```example
#context {
// the context allows you to retrieve the current text.size
set text(size: text.size * 200%)
[large text]
}
original size
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think this part could be improved. I'm not sure what you mean by "read-only". What would the user expect to be modifiable that is not?

I like the example, though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I hope the new version is an improvement.

@ukoethe
Copy link
Author

A remark to the documentation ofhttps://typst.app/docs/reference/math/equation/#parameters-numbering: the documentation says that the default isnone but does not explain what it means - no number or default numbering? This would become clear if there was also an option to passauto to request default numbering. Is there a good reason not to supportauto?

@ukoetheukoethe changed the titleFirst attempt at documentation rewordingRevision of the Context documentationMar 5, 2025
@PgBiel
Copy link
Contributor

PgBiel commentedMar 5, 2025
edited
Loading

Haven't taken a proper look at the changes yet, but I'll defend beforehand that we should make sure any changes to the context docs take this issue into account (and potentially close it):#5538

@ukoethe
Copy link
Author

ukoethe commentedMar 5, 2025
edited
Loading

#5538 stresses: "The context element always gets information from before the block started."

This PR has several places explaining this behavior with various examples, e.g.

  • text.lang is assigned upon entry in the context and remains constant until the end of its scope.
  • The functioncounter.display() is an example for this behavior. Below, call A will access the counter's value uponentry into the context, i.e. '1' - it cannot see the effect of{c.update(2)}.

Please check if your concerns have been fully resolved.

@ukoetheukoethe requested a review fromMDLC01March 6, 2025 17:11
@ukoethe
Copy link
Author

@PgBiel I think the PR properly explains the somewhat counter-intuitive behavior of contexts, including an example regarding counters. The very detailed example in#5538 would be a better fit for theCounter documentation itself, IMHO.

@laurmaedje
Copy link
Member

This would become clear if there was also an option to pass auto to request default numbering. Is there a good reason not to support auto?

None means no numbering, as usual. There is no need forauto since there is no default numbering.

Copy link
Member

@laurmaedjelaurmaedje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A left a few remarks. Reviewing docs is challenging as it's a lot more subjective than code. I kept it mostly to high-level conceptual remarks and Markdown style things and did not go into minor edits. That can be left for later or maybe I would just push some minor edits at the end once the higher level things are out of the way.

## Behavior of the context keyword
Style properties frequently change within a document, for example by applying set
rules. To retrieve such poperties in a consistent way, one must first specify
the context where the query is to be executed. This is the purpose of the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

the term "query" has a rather specific connotation in Typst and should be avoided here imo (also a bunch of times more below)

Copy link
Author

@ukoetheukoetheMar 7, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I deliberately usequery when I refer to the specific typst meaning, and plain text to just use the English term. IMHO, there is no confusion. Anyway, what synonym would not collide with anything in your opinion?

Copy link
Member

@laurmaedjelaurmaedjeMar 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think "retrieve" (as you suggested below) is good. The difference between "query" andquery is a bit too subtle imo.

Style properties frequently change within a document, for example by applying set
rules. To retrieve such poperties in a consistent way, one must first specify
the context where the query is to be executed. This is the purpose of the
`context` keyword. Once the context has been fixed, the property information
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Saying "This is the purpose of the context keyword" is a bit strong since it's not the only purpose of it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please enlighten me about other purposes (or give me a pointer).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Context also provides the current location viahere().

rules. To retrieve such poperties in a consistent way, one must first specify
the context where the query is to be executed. This is the purpose of the
`context` keyword. Once the context has been fixed, the property information
is available through a simple field access syntax. For example, `text.lang`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
is available througha simplefield access syntax. For example,`text.lang`
is available through field access syntax. For example,`text.lang`

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You should be proud of how simple it is (in comparison to the competition :-).

Copy link
Member

@laurmaedjelaurmaedjeMar 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

:D I'm trying to reduce the use of "simple" in my technical writing as things are differently simple/hard for different people and it's typically unnecessary fluff.

PgBiel reacted with thumbs up emoji
environments it is placed into. In the example below, we create a single context
expression, store it in the `value` variable and use it multiple times. Each use
properly reacts to the current surroundings.
Note that calling `#text.lang` directly would be an error, because the request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

"calling" isn't really the correct term I think, as it's not a function (this also appears various times more below)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm running out of words -- "query" is also forbidden :-) How about "retrieving"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Retrieving is good.

@@ -245,6 +259,10 @@ The value in question can be either:
[element function]($function/#element-functions) that were given when the
element was constructed.

**Important:** Many fields of element functions are only accessible in a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
**Important:**Many fields of element functions are only accessible in a
Many fields of element functions are only accessible in a

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Again: people read documentation selectively. "Important:" is meant to catch their attention. That these fields are not accessible outside of acontext was another big surprise to me -- remember that I even made a feature request because I coudn't deduce this from the documentation. I would rather add the explanation to more places to hammer it into every readers brain.

Copy link
Member

@laurmaedjelaurmaedjeMar 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It stuck out to me because in my opinion it's not clearly more important than the other information in this section.

Regardless of that, I think this section could be expanded to clarify when exactly fields are present on content. Essentially

  • fields for required arguments are always accessible
  • fields for optional arguments that were provided in the element's constructor are accessible on a constructed element
  • fields for optional arguments that weren't mentioned in the constructor are only available when the element is "materialized", this is the case when it's the shown element in a show rule or when the element is returned from a query
  • If an element is not materialized, it's fields are not available, also not within acontext expression

Meanwhile, fields onelement functions arenever available without an established context.

@ukoethe
Copy link
Author

ukoethe commentedMar 7, 2025
edited
Loading

None means no numbering, as usual.

When I first read the documentation, I had no idea about what none means "as usual", so I would have appreciated an explanation (instead, I figured it out by trial-and-error).

There is no need forauto since there is no default numbering.

I was not clear enough: "default numbering" is supposed to mean "do not change the numbering scheme". Not havingauto means that one must write a conditional when one wants to configure equations automatically (i.e. by calculating parameters as a function of other settings) and a possible outcome of the calculation is "keep the numbering setting as is". In the presence ofauto, one could always pass an argument tonumbering:, so the code might be simpler. The same can probably achieved by retrieving the present value and setting it again.

Copy link
Collaborator

@MDLC01MDLC01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I like the improvements, and I mostly agree with Laurenz's comments.

I still dislike the word "immutable", though. But I'm not sure what to replace it with, other than changing the phrasing. "Constant", like used line 263, is great.

#context text.lang
```

The output of a `#context ...` call is static in the form of opaque
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What does "static" mean here?

Comment on lines 76 to 77
In fact, context-dependent property fields are immutable constants even
within the context itself:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
In fact, context-dependent property fields are immutable constants even
within the context itself:
In fact, context-dependent property fields always refer to their value at the place where the context is displayed. This means changing a property within a context expression is not observable within the same context expression:

I think something like this would be more correct. Properties are not really immutable: you can still change them, it's just not observable within the same context expression. Maybe my second sentence is redundant with your next paragraph though.

Maybe the following example could even have a nested context expression, but that might be too much.

]
```

Both calls have the same output 'en', because `text.lang` is assigned
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would suggest`"en"`, because the output is technically code here.

bastienvoirin reacted with thumbs up emoji
Comment on lines 91 to 92
(the closing `]`). It does not "see" the `#set text(lang: "fr")` before
call 2. Compare this to the previous example: there we got two different
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This sentence feels weird to me. What's "it"?

The next sentence is great though, it makes it really clear that multiple small context blocks can behave very differently compared to a single big one.

results because we created two different contexts.

However, immutability only applies to the property fields themselves.
Content creation instructions within a context _do_ see the effect of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Both "content creation instructions" and "content expressions" feel obscure to me

Comment on lines 126 to 142
All of the above applies to `show` rules analogously, for example:

```example
#let template(body) = {
set text(size: 25pt)
body
}

#set text(size: 50pt)
#context [
call 1: #text.size \

#show: template
call 2: #text.size \
call 3: #context text.size
]
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Depending on the target audience, this example might be a bit hard to follow (first, we define a function that won't be used for now, then, opencontext, then, do some stuff, then,show: template, then you need to look at whattemplate does, then...).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I copied this example from the original documentation. I think readers will easily figure out its meaning after the previous explanations. It will be good if it takes a moment of extra thinking, because this will make the rules stick in the brain.

MDLC01 reacted with thumbs up emoji
]
```

## Controlling content creation within a context
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The value oftext.fill.darken(20%) is not content, but the value ofcontext text.fill.darken(20%) is.

@laurmaedjelaurmaedje added the docsImprovements or additions to documentation labelMar 11, 2025
Comment on lines 95 to 96
Both reads have the same output `"en"`, because `text.lang` is assigned
upon entry in the context and remains constant until the end of its scope
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Both reads have the same output`"en"`, because`text.lang` isassigned
upon entry inthe context and remains constant until the end of its scope
Both reads have the same output`"en"`, because`text.lang` isdetermined by the outside
value, wherethe context block is placed, and remains constant until the end of its scope

I would say it's never really assigned per se. But maybe I'm just nitpicking too much.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

While your explanation may be technically more precise, I think it is harder to understand for newcomers. I don't see why "assigned upon entry into the context" is wrong and would rather like to keep it. May "entry into the context block", but I'm not sure of this is better.

@ukoethe
Copy link
Author

From my point if view, the PR is good to go.

Copy link
Contributor

@PgBielPgBiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In general, I like the idea of explaining these concepts in a more elementary way, potentially making this doc page more accessible to newcomers.

Here are some comments I had after an initial read at the current state.

I'll also note that@MDLC01's comments were generally spot on, thanks for considering them.

Comment on lines 35 to 41
`context` keyword refers to "right here":

```example
#set text(lang: "de")
// read the language setting "here"
#context text.lang
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Personally, I'd consider getting rid of this example, since it is the first one in the page and we should avoid accidentally encouraging the common mistake of trying to use the value returned incontext directly, e.g. in2 * context text.size or"en" == context text.lang.

It could be improved by adding some logic within the context block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In fact, we could consider mentioning this issue very early on below, when saying that context returns content, if possible. (Needs further discussion.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actually, this is alreadybriefly mentioned at the top, but either way people generally skim the docs for examples they may paste elsewhere (for good reason), so I'd argue this is still a concern, and an explicit (counter-)example would be nice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This example is the "Hello world" of contexts. Everyone knows that "Hello world" is not very useful, but it gets across a few very basic things (such as how the context keywords looks like, that properties are accessed by field syntax, and that they can be displayed). Of course, a different example (instead oflang) might be more instructive.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

BTW, the example is not completely pointless -- it is useful as a quick-and-dirty way of inspecting what the current value of some property is.

Copy link
Author

@ukoetheukoetheMar 19, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A remark about the error message when a field is accessed outside of a context:

#text.lang// => "Can only be used when context is known."

This message is a mystery for beginners -- when you haven't heard about thecontext concept (and associated keyword) and read "context is known" with its generic, everyday-language meaning, you have no idea what to do (and this unfortunately applies to many other error messages as well). Worse, when I first opened the context documentation, I got the feeling that this is meant for advanced users and wouldn't be needed right now. In reality, contexts are absolutely fundamental, and an improved documentation should get this across.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This example is the "Hello world" of contexts. Everyone knows that "Hello world" is not very useful, but it gets across a few very basic things (such as how the context keywords looks like, that properties are accessed by field syntax, and that they can be displayed)

Yeah of course, but as someone who is often active in the typst support channels, i find the problem I mentioned to be rather common across beginners. See alsohttps://forum.typst.app/t/why-is-the-value-i-receive-from-context-always-content/164/

It is possible to keep the example in some way, but maybe it just shouldn't be thefirst.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's true that it's a very common problem with beginners, but I'm not sure that this specific example is the problem. No matter what you put there, people will think that's the way it works. So I think we can keep that. But I agree that we should have more explanation specific to that problem somewhere relatively early in the docs. Doesn't necessarily have to be part of this PR though.

Comment on lines 74 to 83
As you see, the result of a `#context ...` expression can
be inserted into the document as `content`. Context blocks can
contain arbitrary code beyond the field access. However,
and this is often surprisingly for newcomers, context-dependent
property fields remain _constant_ throughout the context's scope.
This has two important consequences: First, direct property
assignments like `text.lang = "de"` are _not_ allowed –
use `set` or `show` rules for this purpose. Second, changes to a
property value within a context (e.g. by a `set` rule) are not
observable by field access within that same context:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This mention to property assignment (at least here) is confusing, since that was never suggested to be possible in the first place, and doesn't seem like something that needs to be mentioned anyway as the error should be straightforward. Set rules, OTOH, don't produce errors, so they are definitely tricky and should be the main focus of this paragraph.

Copy link
Author

@ukoetheukoetheMar 19, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This mention to property assignment (at least here) is confusing, since that was never suggested to be possible in the first place

The problem with your argument is that anyone with only the least programming experience assumes by default that properties can be assigned -- it is just how it works in most languages. That typst never suggested the possibility is irrelevant, the brain automatically relates new stuff to what it already knows.

In fact, a major reason why I struggled with the typst documentation (and take the time to propose improvements) is that one has to unlearn various things that other programming languages take for granted. You absolutely must mention and explain when typst deviates from the mainstream.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, I agree this should be mentioned, but my main point is that this isn't related tocontext itself and feels out of place. This is rather related toset rules themselves - that's how you set properties on elements, not through assignment.

In other words, sinceset rules from outside are what define the value oftext.lang in the first place, one could naturally expect that aset rule insidecontext { ... } would also change it within. That is not the case.

As a compromise, the suggestion of not being able to assign totext.lang could be moved to a note after the phrase or paragraph, e.g. "set rules cannot changetext.lang within the context (nor can you assign to them, as only set rules can influence the default values of element properties)."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In other words, since set rules from outside are what define the value of text.lang in the first place, one could naturally expect that a set rule inside context { ... } would also change it within. That is not the case.

Isn't this exactly what my proposed documentation says?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Isn't this exactly what my proposed documentation says?

I'm effectively proposing for that to be theonly thing it says, and mention the assignment thing elsewhere, or as a sidenote.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree that thetext.lang = "de" is too front-and-center here. In particular, it also sounds like the fact that assignments are not allowed is related to the constants-ness and set rules can somehow ignore the constantness --- which they don't. I think it would be good to decouple the talk about constantness from the fact that you should use set rules and not assignment.

]
```

All of the above applies to `show` rules analogously. To demonstrate this,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe a bit more elementary:

Suggested change
All of the above applies to`show` rules analogously. To demonstrate this,
All of the above applies to`show` rules analogously, as they can be used to apply set rules defined elsewhere. To demonstrate this,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I do not find this formulation helpful. Why restrict the statement to set rules applied in show rules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Otherwise they don't affect context at all. That's the only way they could potentially change a property (and, indeed, they affect nested contexts). But a show rule transforming element A into B wouldn't have any impact whatsoever.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is mostly due to how theshow syntax is a bit overloaded. Only "everything show rules" - equivalent to passing the rest of a scope to a function - can also apply show rules on the current scope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I like@PgBiel's proposed addition.

Comment on lines 203 to 222
The advantage of this technique is that the user does not have to know the
original spacing in order to double it. To double the spacing of all
equations, you can put the same calculations in a show rule. Note that
it is not necessary to add the `context` keyword on the right-hand side
of a `show` rule, because show rules establish a context automatically:

```example
Normal spacing:
$ x \ x $

#show math.equation.where(block: true): it => {
// access current par.leading in a context,
// established automatically by the show rule
set par(leading: par.leading * 200%)
it
}

Doubled spacing:
$ z \ z $
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This has the unfortunate pitfall of not being overridable by a later set rule, since an earlier show rule executes last... it's also whyshow: set rules are usually recommended instead.

Of course, that's not a problem if you never try to override it, but wanted to highlight this for discussion.

Copy link
Author

@ukoetheukoetheMar 19, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You mean the example should be written like this?

#showmath.equation.where(block:true):setpar(leading:par.leading*200%)

This is a typical example of a problem I noticed with the current documentation: After reading it, one tends to overcomplicate solutions (and I mean by alot).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

BTW, the precedence of the rules would deserve its own documentation section.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You mean the example should be written like this?

#showmath.equation.where(block:true):setpar(leading:par.leading*200%)

Unfortunately, this doesn't work becausepar.leading * 200% is evaluated when the show rule is first processed (without context), not when the equation is visited.

@@ -7,6 +7,16 @@ Typst embeds a powerful scripting language. You can automate your documents and
create more sophisticated styles with code. Below is an overview over the
scripting concepts.

## Identifiers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure if this change belongs in this PR, but I'll let@laurmaedje have the final word on this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not sure if it is worth moving this to a PR of its own. In any case, this is another place where it is necessary to unlearn experience from other programming languages, and therefore important to mention.

Copy link
Member

@laurmaedjelaurmaedjeMar 24, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it would be good to move this into its own PR.

ukoetheand others added2 commitsMarch 19, 2025 16:50
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: Bastien Voirin <bastien.voirin.pro@gmail.com>
Copy link
Member

@laurmaedjelaurmaedje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I left a bunch more comments. It may seem a lot (and perhaps nit-picky) but I think we're on a good path and nearing consensus on how this should look!

function.
## Behavior of the context keyword
Style properties frequently change within a document, for example by applying set
rules. To retrieve such properties in a consistent way, one must first specify
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not sure whether "consistent" is quite on point. Maybe "well-defined"?

bastienvoirin and bluebear94 reacted with thumbs up emoji
rules. To retrieve such properties in a consistent way, one must first specify
the precise context where the property should be retrieved. This can be achieved
with the `context` keyword. Once the context has been fixed, the property
information is available through standard field access syntax. For example,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it's in principle important to mentionwhat we are accessing fields on. But the correct thing would be "element functions" and these are just a concept that's cursed to explain. All this will become easier to explain once element functions become types.

original spacing in order to double it. To double the spacing of all
equations, you can put the same calculations in a show rule. Note that
it is not necessary to add the `context` keyword on the right-hand side
of a `show` rule, because show rules establish a context automatically:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The fact that show rules establish context automatically is maybe a bit too buried. It's quite important I think.

Normal spacing:
$ x \ x $

#show math.equation.where(block: true): it => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The rendered version is fairly long and noisy now because both examples don't fit side-by-side and they show the exact same output. Maybe we can somehow shorten this? Maybe the second version could be dropped in favor of a new section that explains that show rules establish context and then have a different example there?

image

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@PgBielPgBielPgBiel left review comments

@bastienvoirinbastienvoirinbastienvoirin left review comments

@laurmaedjelaurmaedjelaurmaedje left review comments

@MDLC01MDLC01MDLC01 left review comments

Assignees
No one assigned
Labels
docsImprovements or additions to documentation
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@ukoethe@PgBiel@laurmaedje@bastienvoirin@MDLC01

[8]ページ先頭

©2009-2025 Movatter.jp