w3c / testtwf-website-src

Sources for http://testthewebforward.org/
10 stars 17 forks source link

Faithfully render braces in generated markup #40

Closed jugglinmike closed 7 years ago

jugglinmike commented 7 years ago

By interpreting partials as Liquid templates, the render_partial plugin strips content that happens to conform to that engine's syntax. Specifically, the referenced documentation describes a substitution syntax for Web Platform Test files which reserves the {{ and }} strings as delimiters for variable interpolation.

This plugin is only used to render content that is intended to stand alone (i.e. without variable expansion), making the use of a templating engine superfluous.

Remove the use of the rendering engine and emit the referenced text directly.

Here's a comparison of the generated output before and after application of the patch:

$ git diff --no-index _site _site-fixed
diff --git a/_site/docs/lint-tool.html b/_site-fixed/docs/lint-tool.html
index 2beefce..ffc99ed 100644
--- a/_site/docs/lint-tool.html
+++ b/_site-fixed/docs/lint-tool.html
@@ -118,7 +118,7 @@ that&#39;s missing a <code>content</code> attribute; <strong>fix</strong>: add a
 with an appropriate value to the <code>&lt;meta name=&#39;variant&#39;...&gt;</code> element.</p></li>
 <li><p><strong>W3C-TEST.ORG</strong>: Test-file line has the string <code>w3c-test.org</code>; <strong>fix</strong>:
 either replace the <code>w3c-test.org</code> string with the expression
-<code>:</code> or a generic hostname like <code>example.org</code>.</p></li>
+<code>{{host}}:{{ports[http][0]}}</code> or a generic hostname like <code>example.org</code>.</p></li>
 </ul>

 <h2>Updating the whitelist</h2>
diff --git a/_site/docs/test-format-guidelines.html b/_site-fixed/docs/test-format-guidelines.html
index 75fed40..d0030fd 100644
--- a/_site/docs/test-format-guidelines.html
+++ b/_site-fixed/docs/test-format-guidelines.html
@@ -301,24 +301,29 @@ information in one of two ways:</p>
 <p>In order for the latter to work, a file must either have a name of the
 form <code>{name}.sub.{ext}</code> e.g. <code>example-test.sub.html</code> or be referenced
 through a URL containing <code>pipe=sub</code> in the query string
-e.g. <code>example-test.html?pipe=sub</code>. The substitution syntax uses ``
+e.g. <code>example-test.html?pipe=sub</code>. The substitution syntax uses <code>{{ }}</code>
 to delimit items for substitution. For example to substitute in
 the host name on which the tests are running, one would write:</p>
-
+<div class="highlight"><pre><code class="language-text" data-lang="text">{{host}}
+</code></pre></div>
 <p>As well as the host, one can get full domains, including subdomains
 using the <code>domains</code> dictionary. For example:</p>
-
+<div class="highlight"><pre><code class="language-text" data-lang="text">{{domains[www]}}
+</code></pre></div>
 <p>would be replaced by the fully qualified domain name of the <code>www</code>
 subdomain. Ports are also available on a per-protocol basis e.g.</p>
-
+<div class="highlight"><pre><code class="language-text" data-lang="text">{{ports[ws][0]}}
+</code></pre></div>
 <p>is replaced with the first (and only) websockets port, whilst</p>
-
+<div class="highlight"><pre><code class="language-text" data-lang="text">{{ports[http][1]}}
+</code></pre></div>
 <p>is replaced with the second HTTP port.</p>

 <p>The request URL itself can be used as part of the substitution using
 the <code>location</code> dictionary, which has entries matching the
 <code>window.location</code> API. For example</p>
-
+<div class="highlight"><pre><code class="language-text" data-lang="text">{{location[host]}}
+</code></pre></div>
 <p>is replaced by <code>hostname:port</code> for the current request.</p>

 <h3>Tests Requiring Special Headers</h3>

This change is Reviewable

jugglinmike commented 7 years ago

We could simplify this still further by relocating the _resources directory to _includes/resources. This would allow us to use Jekyll's built-in {% include file } tag and remove the render_partial plugin altogether.

This is a more drastic change in that it involves renaming git submodules, so I'll hold off on that until I hear back from a maintainer.

jgraham commented 7 years ago

That sounds like a good idea to me, but I don't recall if there are any substantial disadvantages. @gsnedders should probably also comment since he is changing some infrastructure here.

gsnedders commented 7 years ago

@jugglinmike I'm happy to merge this, as it does solve this for now.

What @jgraham hinted at is that the docs are going to move to essentially using GitHub Pages straight out of /docs in the wpt repo, which means we're not going to have the includes in any way shape or form… it does somewhat sadly meant the only way around it is to escape the characters in the source which means they break when you view them on GitHub (as opposed to the rendered page). It doesn't seem worthwhile to move subresources for a short-term gain when they'll be gone entirely soon.