Skip to content

Commit

Permalink
The standard type link has a trailing slash (#1889)
Browse files Browse the repository at this point in the history
* The standard type link has a trailing slash

* update tests too
  • Loading branch information
deniak authored Nov 5, 2024
1 parent 6956562 commit 4805248
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/l10n-en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const messages = {
'headers.w3c-state.no-w3c-state-link':
'Cannot find the link of the W3C profile in id="w3c-state" element pointing to "https://www.w3.org/standards/types#xx".',
'headers.w3c-state.wrong-w3c-state-link':
'The link for text "${text}" should pointing to W3C profile "${expectedLink}", but the link found in the document is "${linkFound}".',
'The link for text "${text}" should pointing to W3C profile "https://www.w3.org/standards/types/#${hash}", but the link found in the document is "${linkFound}".',
// headers/h2-toc
'headers.h2-toc.not-found':
'There is no table of contents inside a navigation element (<code>&lt;nav id="toc"&gt; &hellip; &lt;h2&gt;Table of Contents&lt;/h2&gt; &hellip; &lt;/nav&gt;</code>).',
Expand Down
4 changes: 2 additions & 2 deletions lib/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@
],
"dateState": [
"Recommendation",
" <p>If this is a modified Recommendation that was modified in place or is a new edition, the document <span class=\"rfc2119\">must</span> include both the original publication date and the modification date. For example:</p> <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types#REC\">W3C Recommendation</a> 7 April 2004, edited in place 19 August2004&lt;/p&gt;</pre>"
" <p>If this is a modified Recommendation that was modified in place or is a new edition, the document <span class=\"rfc2119\">must</span> include both the original publication date and the modification date. For example:</p> <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types/#REC\">W3C Recommendation</a> 7 April 2004, edited in place 19 August2004&lt;/p&gt;</pre>"
],
"docIDFormat": true,
"docIDOrder": "Document identifier information <span class=\"rfc2119\">must</span> be present in this order: <ul><li>'This version' - URI to that version</li><li>'Latest version' - URI to the latest version. See also the (non-normative) <cite> <a href=\"https://www.w3.org/2005/05/tr-versions\">Version Management in W3C Technical Reports</a> </cite> for information about \"latest version\" URI and version management.</li><li class=\"historyuri\">'History' - URI to the history of the specification</li><li>Editor(s)</li><li>Feedback - GitHub repository issue links are required in the &lt;dl&gt;after &lt;dt&gt;Feedback:&lt;/dt&gt; in the headers (&lt;div class=\"head\"&gt;) of the document. Links are expected to be of the form <code>https://github.com/&lt;USER_OR_ORG&gt;/&lt;REPO_NAME&gt;/[issues|labels][/&hellip;]</code>.)</li><li>Errata - URI to an errata document for any errors or issues reported since publication. See also suggestions on <a href=\"https://www.w3.org/2001/06/manual/#Errata\">errata page structure</a> in the Manual of Style. <strong>Note:</strong><ul><li> Do not put the errata document in TR space as the expectation is that we will not modify document in TR space after publication; see the policy for <a href=\"https://www.w3.org/2003/01/republishing/\">in-place modification of W3C Technical Reports</a>.</li><li>Recommendations with candidate/proposed changes are treated as inline errata, and these documents don't require an errata link.</li></ul></li></ul>",
Expand Down Expand Up @@ -1577,7 +1577,7 @@
"logo": "The document <span class=\"rfc2119\">must</span> include a link to the W3C logo identified below. The URI used to identify the logo <span class=\"rfc2119\">must</span> be absolute. <div class=\"boilerplate\"> <a href=\"https://www.w3.org/\"> <img alt=\"W3C\" src=\"https://www.w3.org/StyleSheets/TR/2021/logos/W3C\" height=\"48\" width=\"72\"> </a> </div> <div class=\"source\"> <span style=\"font-style: italic\">Include this source code</span>:<br><code>&lt;a href=\"https://www.w3.org/\"&gt;&lt;img height=\"48\" width=\"72\" alt=\"W3C\" src=\"https://www.w3.org/StyleSheets/TR/2021/logos/W3C\"/&gt;&lt;/a&gt;</code></div>",
"title": "The document's title <span class=\"rfc2119\">must</span> be in the <code>title</code> element and in an <code>h1</code> element. When calculating text equation, special transformations made to <code>h1</code> are: <ol><li>Replace ':&lt;br&gt;' with ': '</li><li>Replace '&lt;br&gt;' with ' - '</li><li>Extract text from h1, and ignore HTML tags.</li></ol>",
"versionNumber": "Technical report version information, i.e., version and edition numbers. <ol> @{param1}<li>See the (non-normative) <cite> <a href=\"https://www.w3.org/2005/05/tr-versions\">Version Management in W3C Technical Reports</a> </cite> for more information.</li> </ol>",
"dateState": "The document's status and date <span class=\"rfc2119\">must</span> be in a <code>&lt;p id=\"w3c-state\"&gt;</code> element as follows (see also <a href=\"#datesFormat\">date syntax</a>): <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types#@@Profile\">W3C @{param1}</a> DD Month YYYY&lt;/p&gt;</pre>@{param2}",
"dateState": "The document's status and date <span class=\"rfc2119\">must</span> be in a <code>&lt;p id=\"w3c-state\"&gt;</code> element as follows (see also <a href=\"#datesFormat\">date syntax</a>): <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types/#@@Profile\">W3C @{param1}</a> DD Month YYYY&lt;/p&gt;</pre>@{param2}",
"docIDFormat": "Document identifier information <span class=\"rfc2119\">must</span> be presented in a <code>dl</code> list, where each <code>dt</code> element marks up an identifier role (\"This Version\", \"Latest Version\", \"History\", etc.) and each <code>dd</code> element includes a link whose link text is the identifier. That <code>dl</code> <span class=\"rfc2119\">must</span> itself be placed in a <code>details</code> element. <p><span style=\"font-style: italic\">Include this source code:</span><br/><code>&lt;details open&gt;&lt;summary&gt;More details about this document&lt;/summary&gt;&lt;dl&gt;...&lt;/dl&gt;&lt;/details&gt;</code></p>",
"docIDOrder": "Document identifier information <span class=\"rfc2119\">must</span> be present in this order: <ul><li>'This version' - URI to that version</li><li>'Latest version' - URI to the latest version. See also the (non-normative) <cite> <a href=\"https://www.w3.org/2005/05/tr-versions\">Version Management in W3C Technical Reports</a> </cite> for information about \"latest version\" URI and version management.</li><li class=\"historyuri\">'History' - URI to the history of the specification</li><li>Editor(s)</li><li>Feedback - GitHub repository issue links are required in the &lt;dl&gt;after &lt;dt&gt;Feedback:&lt;/dt&gt; in the headers (&lt;div class=\"head\"&gt;) of the document. Links are expected to be of the form <code>https://github.com/&lt;USER_OR_ORG&gt;/&lt;REPO_NAME&gt;/[issues|labels][/&hellip;]</code>.)</li></ul>",
"docIDThisVersion": "The syntax of a “this version” URI <span class=\"rfc2119\">must</span> be <code>https://www.w3.org/TR/YYYY/@{param1}-shortname-YYYYMMDD/</code>. If the document introduces a new shortname, it <span class=\"rfc2119\">must</span> use lowercase letters.",
Expand Down
8 changes: 5 additions & 3 deletions lib/rules/headers/w3c-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ export function check(sr, done) {
if (sr.config.longStatus === 'First Public Working Draft') {
hash = 'FPWD';
}
const expectedLink = `https://www.w3.org/standards/types#${hash}`;
const expectedLink = new RegExp(
`https://www.w3.org/standards/types/?#${hash}`
);
if (!standardLink) {
sr.error(self, 'no-w3c-state-link');
} else if (standardLink.href !== expectedLink) {
} else if (!expectedLink.test(standardLink.href)) {
sr.error(self, 'wrong-w3c-state-link', {
expectedLink,
hash,
linkFound: standardLink.href,
text: sr.norm(standardLink.textContent),
});
Expand Down
2 changes: 1 addition & 1 deletion test/doc-views/layout/spec.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{/if}}

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#{{#if config.isFPWD}}FPWD{{else}}{{config.status}}{{/if}}'>W3C <span class="handlebars-data">{{config.longStatus}} {{config.crType}} {{config.cryType}}</span></a>
<a href='https://www.w3.org/standards/types/#{{#if config.isFPWD}}FPWD{{else}}{{config.status}}{{/if}}'>W3C <span class="handlebars-data">{{config.longStatus}} {{config.crType}} {{config.cryType}}</span></a>
{{! if document is Echidna, use current date. else, use default date}}
<time class="dt-published" datetime="2021-11-04">
{{#if config.isEchidna}}
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-cr.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<h1 id="title" class="title p-name">High Resolution Time</h1>

<p id='w3c-state'>
<a href="https://www.w3.org/standards/types#CR">W3C Candidate Recommendation Snapshot</a>
<a href="https://www.w3.org/standards/types/#CR">W3C Candidate Recommendation Snapshot</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-crd.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">High Resolution Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#CRD'>W3C Candidate Recommendation Draft</a>
<a href='https://www.w3.org/standards/types/#CRD'>W3C Candidate Recommendation Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-cry.html
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#CRY'>W3C Candidate Registry Snapshot</a> <time class="dt-published" datetime="2021-11-04">04 November 2021</time>
<a href='https://www.w3.org/standards/types/#CRY'>W3C Candidate Registry Snapshot</a> <time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
<summary>More details about this document</summary>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-cryd.html
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#CRYD'>W3C Candidate Registry Draft</a>
<a href='https://www.w3.org/standards/types/#CRYD'>W3C Candidate Registry Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-disc.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">Foo Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#DISC'>W3C Discontinued Draft</a>
<a href='https://www.w3.org/standards/types/#DISC'>W3C Discontinued Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-dnote.html
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#DNOTE'>W3C Group Draft Note</a>
<a href='https://www.w3.org/standards/types/#DNOTE'>W3C Group Draft Note</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-dry.html
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#DRY'>W3C Draft Registry</a>
<a href='https://www.w3.org/standards/types/#DRY'>W3C Draft Registry</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-fpwd.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">Foo Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#FPWD'>W3C First Public Working Draft</a>
<a href='https://www.w3.org/standards/types/#FPWD'>W3C First Public Working Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-note.html
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#NOTE'>W3C Group Note</a>
<a href='https://www.w3.org/standards/types/#NOTE'>W3C Group Note</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-pr.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">High Resolution Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#PR'>W3C Proposed Recommendation</a>
<a href='https://www.w3.org/standards/types/#PR'>W3C Proposed Recommendation</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-rec.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<h1 class="p-name" id="title">CSS Color Module Level 3</h1>

<p id="w3c-state" class="no-num no-toc"><a href="https://www.w3.org/standards/types#REC">W3C Recommendation</a>
<p id="w3c-state" class="no-num no-toc"><a href="https://www.w3.org/standards/types/#REC">W3C Recommendation</a>
<time class="dt-updated" datetime="2022-01-18">18 January 2022</time>
</p>

Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-ry.html
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#RY'>W3C Registry</a>
<a href='https://www.w3.org/standards/types/#RY'>W3C Registry</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-stmt.html
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
<h1 id="title" class="title">Ready-made Counter Styles</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#STMT'>W3C Statement</a>
<a href='https://www.w3.org/standards/types/#STMT'>W3C Statement</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-wd-shortname-change.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">Foo Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#WD'>W3C Working Draft</a>
<a href='https://www.w3.org/standards/types/#WD'>W3C Working Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-wd.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h1 id="title" class="title p-name">Foo Time</h1>

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types#WD'>W3C Working Draft</a>
<a href='https://www.w3.org/standards/types/#WD'>W3C Working Draft</a>
<time class="dt-published" datetime="2021-11-04">04 November 2021</time>
</p>
<details open>
Expand Down

0 comments on commit 4805248

Please sign in to comment.