Skip to content

Commit 0054857

Browse files
Fix response headers table rendering inside pymdownx tabs
The HTML <table> block for response headers was indented at 4 spaces inside the tab content, but Python-Markdown only treats raw HTML as a block element when it starts at column 0. Indented HTML was treated as inline content and rendered as escaped code by pymdownx. Replace the HTML table with a GFM-style pipe table (| col | col |) which is correctly parsed at any indentation level inside tab content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 48179a0 commit 0054857

File tree

4 files changed

+31
-95
lines changed

4 files changed

+31
-95
lines changed

openapidocs/mk/v3/views_mkdocs/partial/request-responses.html

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,14 @@
2727
{% endwith -%}
2828
{% endif -%}
2929
{%- if definition.headers %}
30-
<div class="response-section">
31-
<p class="response-headers sub-section-title">{{texts.response_headers}}</p>
3230

33-
<table>
34-
<thead>
35-
<tr>
36-
<th>{{texts.name}}</th>
37-
<th>{{texts.description}}</th>
38-
<th>{{texts.schema}}</th>
39-
</tr>
40-
</thead>
41-
<tbody>
42-
{%- for header_name, header_definition in handler.get_response_headers(definition).items() %}
43-
<tr>
44-
<td><code>{{header_name}}</code></td>
45-
<td>{{header_definition.description}}</td>
46-
<td>
47-
{%- with schema = header_definition.schema %}
48-
{%- include "partial/schema-repr.html" -%}
49-
{% endwith -%}
50-
</td>
51-
</tr>
52-
{%- endfor %}
53-
</tbody>
54-
</table>
55-
</div>
31+
**{{texts.response_headers}}**
32+
33+
| {{texts.name}} | {{texts.description}} | {{texts.schema}} |
34+
| --- | --- | --- |
35+
{%- for header_name, header_definition in handler.get_response_headers(definition).items() %}
36+
| `{{header_name}}` | {{header_definition.description or ""}} | {%- with schema = header_definition.schema %}{%- include "partial/schema-repr.html" -%}{%- endwith %} |
37+
{%- endfor %}
38+
5639
{% endif -%}
5740
{%- endfor -%}

tests/res/example1-output.md

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -166,36 +166,15 @@ Initializes a file upload operation.
166166
```
167167

168168

169-
<div class="response-section">
170-
<p class="response-headers sub-section-title">Response headers</p>
171-
172-
<table>
173-
<thead>
174-
<tr>
175-
<th>Name</th>
176-
<th>Description</th>
177-
<th>Schema</th>
178-
</tr>
179-
</thead>
180-
<tbody>
181-
<tr>
182-
<td><code>X-Rate-Limit-Limit</code></td>
183-
<td>The number of allowed requests in the current period</td>
184-
<td><span class="integer-type">integer</span></td>
185-
</tr>
186-
<tr>
187-
<td><code>X-Rate-Limit-Remaining</code></td>
188-
<td>The number of remaining requests in the current period</td>
189-
<td><span class="integer-type">integer</span></td>
190-
</tr>
191-
<tr>
192-
<td><code>X-Rate-Limit-Reset</code></td>
193-
<td>The number of seconds left in the current period</td>
194-
<td><span class="integer-type">integer</span></td>
195-
</tr>
196-
</tbody>
197-
</table>
198-
</div>
169+
170+
**Response headers**
171+
172+
| Name | Description | Schema |
173+
| --- | --- | --- |
174+
| `X-Rate-Limit-Limit` | The number of allowed requests in the current period |<span class="integer-type">integer</span> |
175+
| `X-Rate-Limit-Remaining` | The number of remaining requests in the current period |<span class="integer-type">integer</span> |
176+
| `X-Rate-Limit-Reset` | The number of seconds left in the current period |<span class="integer-type">integer</span> |
177+
199178

200179
=== "400 Bad Request"
201180
<div class="common-response"><p>Refer to the common response description: <a href="#illegalinput" class="ref-link">IllegalInput</a>.</p></div>

tests/res/example2-output.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,13 @@ List all pets
109109
```
110110

111111

112-
<div class="response-section">
113-
<p class="response-headers sub-section-title">Response headers</p>
114-
115-
<table>
116-
<thead>
117-
<tr>
118-
<th>Name</th>
119-
<th>Description</th>
120-
<th>Schema</th>
121-
</tr>
122-
</thead>
123-
<tbody>
124-
<tr>
125-
<td><code>x-next</code></td>
126-
<td>A link to the next page of responses</td>
127-
<td><span class="string-type">string</span></td>
128-
</tr>
129-
</tbody>
130-
</table>
131-
</div>
112+
113+
**Response headers**
114+
115+
| Name | Description | Schema |
116+
| --- | --- | --- |
117+
| `x-next` | A link to the next page of responses |<span class="string-type">string</span> |
118+
132119

133120
=== "Other responses"
134121

tests/res/example3-output.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,13 @@ List all pets
9393
```
9494

9595

96-
<div class="response-section">
97-
<p class="response-headers sub-section-title">Response headers</p>
98-
99-
<table>
100-
<thead>
101-
<tr>
102-
<th>Name</th>
103-
<th>Description</th>
104-
<th>Schema</th>
105-
</tr>
106-
</thead>
107-
<tbody>
108-
<tr>
109-
<td><code>x-next</code></td>
110-
<td>A link to the next page of responses</td>
111-
<td><span class="string-type">string</span></td>
112-
</tr>
113-
</tbody>
114-
</table>
115-
</div>
96+
97+
**Response headers**
98+
99+
| Name | Description | Schema |
100+
| --- | --- | --- |
101+
| `x-next` | A link to the next page of responses |<span class="string-type">string</span> |
102+
116103

117104
=== "Other responses"
118105

0 commit comments

Comments
 (0)