Skip to content

Commit a8f0ed8

Browse files
authored
Merge pull request alphagov#296 from timja/fix-deprecation-warning
Fix Nokogiri `Node.new` deprecation warnings
2 parents b539e92 + cae2eee commit a8f0ed8

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
Deprecation warnings from Nokogiri addressed when rendering markdown tables
8+
59
## 3.2.0
610

711
### New features

example/source/code.html.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,9 @@ A paragraph with a `code` element within it.
1010

1111
An example of a table with a `code` element within it.
1212

13-
<div class="table-container">
14-
<table>
15-
<thead>
16-
<tr>
17-
<th style="text-align:left">httpResult</th>
18-
<th style="text-align:left">Message</th>
19-
<th style="text-align:left">How to fix</th>
20-
</tr>
21-
</thead>
22-
<tbody>
23-
<tr>
24-
<td style="text-align:left"><code>400</code></td>
25-
<td style="text-align:left">
26-
<code>[{</code>
27-
<br />
28-
<code>"error": "BadRequestError",</code>
29-
<br />
30-
<code>"message": "Can't send to this recipient using a team-only API key"</code>
31-
<br />
32-
<code>]}</code>
33-
</td>
34-
<td style="text-align:left">Use the correct type of API key</td>
35-
</tr>
36-
</tbody>
37-
</table>
38-
</div>
13+
| httpResult | Message | How to fix |
14+
| - | - | - |
15+
| `400` | `[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}` | Use the correct type of API key |
3916

4017
An example of a code block with a long line length
4118

lib/govuk_tech_docs/tech_docs_html_renderer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def table_row(body)
6969
first_child.content = leading_text.sub(/# */, "")
7070
end
7171

72-
tr = Nokogiri::XML::Node.new "tr", fragment
72+
tr = Nokogiri::XML::Node.new "tr", fragment.document
7373
tr.children = fragment.children
7474

7575
tr.to_html
@@ -95,9 +95,9 @@ def block_code(text, lang)
9595
# be `defined?`, so we can jump straight to rendering HTML ourselves.
9696

9797
fragment = Nokogiri::HTML::DocumentFragment.parse("")
98-
pre = Nokogiri::XML::Node.new "pre", fragment
98+
pre = Nokogiri::XML::Node.new "pre", fragment.document
9999
pre["tabindex"] = "0"
100-
code = Nokogiri::XML::Node.new "code", fragment
100+
code = Nokogiri::XML::Node.new "code", fragment.document
101101
code["class"] = lang
102102
code.content = text
103103
pre.add_child code

0 commit comments

Comments
 (0)