Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for adding labels (ids) to steps #56

Closed
ExE-Boss opened this issue Jan 10, 2020 · 4 comments · Fixed by #74
Closed

Add support for adding labels (ids) to steps #56

ExE-Boss opened this issue Jan 10, 2020 · 4 comments · Fixed by #74

Comments

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Jan 10, 2020

Needed to avoid tc39/ecma262#1835 from happening again.

Proposed syntax:

Allow <label_name>: in ordered lists, where <label_name> matches the regular expression:

^[a-zA-Z_$][a-zA-Z0-9_$]*$

Example:

<emu-clause id="sec-assertfoo" aoid="AssertFoo">
	<h1>AssertFoo( _val_ )</h1>

	<p>The AssertFoo algorithm ensures that _val_ is an object with an [[IsFoo]] internal slot, by only returning in <emu-xref aoid="AssertFoo" step="Is_Foo_$1"></emu-xref>.</p>

	<emu-alg>
		1. Assert: Type(_val_) is Object.
		1. If ? _val_.[[IsFoo]] is *true*
			Is_Foo_$1:
			1. Return _val_
		1. Throw a *TypeError* exception.
	</emu-alg>
</emu-clause>

[step Is_Foo_$1] would be replaced with an anchor link linking to the labeled step with the HTML step&nbsp;${num}, where ${num} is the number of the step.

See also:

@ljharb
Copy link
Member

ljharb commented Jan 10, 2020

Would this work with a step used anywhere in the entire document? if so, perhaps it should be namespaced under the name of the abstract operation?

@bakkot
Copy link
Contributor

bakkot commented Jun 16, 2020

I went with a slightly different syntax in #74: 1. [label="foo"] Step. I didn't namespace them because emcarkup doesn't really have a notion of the abstract operation associated with an algorithm; algorithm steps can appear wherever.

@ljharb
Copy link
Member

ljharb commented Jun 16, 2020

Does that mean the label must be unique across the whole document?

@bakkot
Copy link
Contributor

bakkot commented Jun 16, 2020

Yup.

That's not such a constraint, though; you don't really end up referring to individual steps that often. Ecma262, which is not a small document, currently has 59 steps which are referred to.

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 a pull request may close this issue.

3 participants