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

link non-wordchars AOs #466

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/autolinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ function isCommonAbstractOp(op: string) {
function lookAheadBeyond(key: string, entry: BiblioEntry) {
if (isCommonAbstractOp(key)) {
// must be followed by parentheses
return '\\b(?=\\()';
return '(?=\\()';
}
if (entry.type !== 'term' || /^\w/.test(key)) {
// must not be followed by `.word` or `%%` or `]]`
return '\\b(?!\\.\\w|%%|\\]\\])';
// must not be followed by a letter, `.word`, `%%`, `]]`
return '(?!\\w|\\.\\w|%%|\\]\\])';
}
return '';
}
Expand Down
2 changes: 2 additions & 0 deletions test/baselines/generated-reference/autolinking.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h1><span class="secnum">1</span> Autolinking</h1>
<p><dfn>extra spaces</dfn></p>
<p><dfn>Await</dfn></p>
<p><dfn id="variants" variants="vOne, vTwo">Variants</dfn></p>
<p><emu-eqn id="𝔽" aoid="𝔽" class="inline">𝔽(<var>x</var>)</emu-eqn></p>
</emu-clause>
<emu-clause id="sec-bar">
<h1><span class="secnum">2</span> Autolinking 2</h1>
Expand All @@ -29,6 +30,7 @@ <h1><span class="secnum">2</span> Autolinking 2</h1>
<p>Also, no autolinks in <a href="#">anchors: Lowercase</a>.</p>
<p>Similarly, no autolinks for <sub>[Await]</sub>.</p>
<p><emu-xref href="#variants" id="_ref_5"><a href="#variants">Variants</a></emu-xref> like <emu-xref href="#variants" id="_ref_6"><a href="#variants">vOne</a></emu-xref> and <emu-xref href="#variants" id="_ref_7"><a href="#variants">vTwo</a></emu-xref> should autolink, including when capitalized as in <emu-xref href="#variants" id="_ref_8"><a href="#variants">VOne</a></emu-xref>.</p>
<emu-alg><ol><li>Non-word-chars AOs still link when invoked, like <emu-xref aoid="𝔽" id="_ref_9"><a href="#𝔽">𝔽</a></emu-xref>(<var>x</var>).</li></ol></emu-alg>
</emu-clause>
<p><emu-xref href="#sec-array-constructor"><a href="https://tc39.es/ecma262/#sec-array-constructor">%Array%</a></emu-xref> and %ArrayPrototype% outside of clauses is ok.</p>
</div></body>
4 changes: 4 additions & 0 deletions test/baselines/sources/autolinking.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h1>Autolinking</h1>
<p><dfn>extra spaces</dfn></p>
<p><dfn>Await</dfn></p>
<p><dfn id="variants" variants="vOne, vTwo">Variants</dfn></p>
<p><emu-eqn id="𝔽" aoid="𝔽">𝔽(_x_)</emu-eqn></p>
</emu-clause>
<emu-clause id="sec-bar">
<h1>Autolinking 2</h1>
Expand All @@ -26,5 +27,8 @@ <h1>Autolinking 2</h1>
<p>Also, no autolinks in <a href="#">anchors: Lowercase</a>.</p>
<p>Similarly, no autolinks for <sub>[Await]</sub>.</p>
<p>Variants like vOne and vTwo should autolink, including when capitalized as in VOne.</p>
<emu-alg>
1. Non-word-chars AOs still link when invoked, like 𝔽(_x_).
</emu-alg>
</emu-clause>
<p>%Array% and %ArrayPrototype% outside of clauses is ok.</p>