Skip to content

Commit

Permalink
Fix generated HTML (#1880)
Browse files Browse the repository at this point in the history
* Add tr as child of thead in HTML tables

It is invalid HTML for th to be the direct children of thead

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Remove unnecessary HTML code end tag

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Avoid nesting p HTML elements

A p HTML element cannot contain other block elements,
so the "parent" element is closed when the first "child" one is opened.

We need to use Page.RenderString with options
to force Hugo to keep the wrapping p elements
even if the content contains a single paragraph.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add missing HTML details end tags

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Replace HTML a self-closing tag with start and end tags

The a element start and end tags are mandatory.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Replace obsolete HTML name attribute with id

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add changelog

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh authored Jun 20, 2024
1 parent 560f29c commit 5fbfdd6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/1880.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix validation errors in generated HTML.
14 changes: 7 additions & 7 deletions content/client-server-api/modules/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ Definition:
}
```

<a id="_m_rule_is_user_mention"/> **`.m.rule.is_user_mention`**
<a id="_m_rule_is_user_mention"></a> **`.m.rule.is_user_mention`**

{{< added-in v="1.7" >}}

Expand Down Expand Up @@ -555,7 +555,7 @@ Definition:
}
```

<a id="_m_rule_contains_display_name"/> **`.m.rule.contains_display_name`**
<a id="_m_rule_contains_display_name"></a> **`.m.rule.contains_display_name`**

{{% changed-in v="1.7" %}}

Expand Down Expand Up @@ -590,7 +590,7 @@ Definition:
}
```

<a id="_m_rule_is_room_mention"/> **`.m.rule.is_room_mention`**
<a id="_m_rule_is_room_mention"></a> **`.m.rule.is_room_mention`**

{{< added-in v="1.7" >}}

Expand Down Expand Up @@ -624,7 +624,7 @@ Definition:
}
```

<a id="_m_rule_roomnotif"/> **`.m.rule.roomnotif`**
<a id="_m_rule_roomnotif"></a> **`.m.rule.roomnotif`**

{{% changed-in v="1.7" %}}

Expand Down Expand Up @@ -662,7 +662,7 @@ Definition:
}
```

**<a name="mruletombstone"></a>`.m.rule.tombstone`**
**<a id="mruletombstone"></a>`.m.rule.tombstone`**

Matches any state event whose type is `m.room.tombstone`. This is
intended to notify users of a room when it is upgraded, similar to what
Expand Down Expand Up @@ -696,7 +696,7 @@ Definition:
}
```

**<a name="mrulereaction"></a>`.m.rule.reaction`**
**<a id="mrulereaction"></a>`.m.rule.reaction`**

{{% added-in v="1.7" %}}

Expand Down Expand Up @@ -776,7 +776,7 @@ Definition:

##### Default Content Rules

<a id="_m_rule_contains_user_name"/> **`.m.rule.contains_user_name`**
<a id="_m_rule_contains_user_name"></a> **`.m.rule.contains_user_name`**

{{% changed-in v="1.7" %}}

Expand Down
2 changes: 2 additions & 0 deletions layouts/partials/events/render-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ <h2>Examples</h2>
{{ end }}
{{ end }}

</details>

</section>
6 changes: 4 additions & 2 deletions layouts/partials/openapi/render-content-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

<table class="content-type-table">
<thead>
<th class="col-name">Content-Type</th>
<th class="col-description">Description</th>
<tr>
<th class="col-name">Content-Type</th>
<th class="col-description">Description</th>
</tr>
</thead>
{{ range $idx, $content_type := $content_types }}
<tr>
Expand Down
16 changes: 10 additions & 6 deletions layouts/partials/openapi/render-object-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
<caption>{{ . }}</caption>
{{ end }}
<thead>
<th class="col-name">Name</th>
<th class="col-type">Type</th>
<th class="col-description">Description</th>
<tr>
<th class="col-name">Name</th>
<th class="col-type">Type</th>
<th class="col-description">Description</th>
</tr>
</thead>

{{ range $property_name, $property := $properties }}
Expand Down Expand Up @@ -68,7 +70,7 @@
{{ if reflect.IsMap .additionalProperties }}

<tr>
<td>&lt;Other properties&gt;</code></td>
<td>&lt;Other properties&gt;</td>
<td><code>{{ partial "partials/property-type" .additionalProperties | safeHTML }}</code></td>
<td>{{ partial "partials/property-description" (dict "property" .additionalProperties) }}</td>
</tr>
Expand All @@ -90,8 +92,10 @@
<caption>{{ . }}</caption>
{{ end }}
<thead>
<th class="col-type">Type</th>
<th class="col-description">Description</th>
<tr>
<th class="col-type">Type</th>
<th class="col-description">Description</th>
</tr>
</thead>

{{ $property := . }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/openapi/render-operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1 id="{{ lower $method }}{{ $anchor }}">
{{ partial "changed-in" (dict "changes_dict" (index $operation_data "x-changedInMatrixVersion")) }}
{{ end -}}

<p>{{ $operation_data.description | markdownify }}</p>
{{ $operation_data.description | page.RenderString (dict "display" "block") }}


<table class="basic-info">
Expand Down
6 changes: 4 additions & 2 deletions layouts/partials/openapi/render-responses.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ <h2>Responses</h2>

<table class="response-table">
<thead>
<th class="col-status">Status</th>
<th class="col-status-description">Description</th>
<tr>
<th class="col-status">Status</th>
<th class="col-status-description">Description</th>
</tr>
</thead>

{{ range $code, $response := $responses }}
Expand Down
2 changes: 2 additions & 0 deletions layouts/shortcodes/definition.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ <h2>Examples</h2>
{{ jsonify (dict "indent" " ") $example }}
```

</details>

</section>

0 comments on commit 5fbfdd6

Please sign in to comment.