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

support for replacement algorithms and for xrefs to steps #217

Merged
merged 3 commits into from
Jun 17, 2020
Merged

Conversation

bakkot
Copy link
Contributor

@bakkot bakkot commented Jun 16, 2020

This adds the ability to reference steps, both with emu-xrefs and by marking algorithms as replacing steps (the latter so that they can have the appropriate numbering).

You can label steps using the 1. [label="foo"] Step. syntax introduced in tc39/ecmarkdown#74, and you can refer to them with <emu-xref href="#step-foo"></emu-xref> or <emu-alg replaces-step="foo">. The xref will automatically be populated with the appropriate step number (just the number itself, so you still need to write out "step", and possibly the name of the algorithm if it isn't clear). The labeled algorithm will automatically adopt the numbering of the labeled step, including for nested steps.

Now that we have support for replacement algorithms there is no longer a need to manually override the starting number for a list. I enforce that you do not, and that you do not write "step 1" or whatever, with the linter.

Fixes #192.

Marked as draft until a version of ecmarkdown with support for the [label=""] syntax is published.

Corresponding ecmarkdown PR at tc39/ecmarkdown#74. Corresponding ecma262 PR at tc39/ecma262#2052.

Since it's hard to review the CSS in the PR, here's a screenshot of the new algorithm-replacements baseline:

Screen Shot 2020-06-15 at 9 34 16 PM

src/Algorithm.ts Outdated Show resolved Hide resolved
css/elements.css Outdated Show resolved Hide resolved
css/elements.css Outdated Show resolved Hide resolved
src/Spec.ts Outdated Show resolved Hide resolved
src/Xref.ts Outdated Show resolved Hide resolved
node.innerHTML = html;

let labeledStepEntries: StepBiblioEntry[] = [];
let replaces = node.getAttribute('replaces-step');
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this attribute from the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ecmarkup doesn't really clean up after itself, as a rule - all the emu-whatever tags are in the output, etc.

Copy link
Member

Choose a reason for hiding this comment

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

Fine. We should reconsider that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #218 to track.

@bakkot bakkot marked this pull request as ready for review June 17, 2020 06:44
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.

Support referencing algorithm steps
2 participants