Skip to content

Commit

Permalink
Remove the rel and rev attributes from footnotes
Browse files Browse the repository at this point in the history
Since the `rev` attribute has been removed from the HTML 5 spec and
the `rel` attribute doesn't accept `"footnote"` as a value anymore,
let's remove them from the generated output for footnotes.

It's still possible to have the previous behaviour with a custom
render object.

Fixes #536.
  • Loading branch information
robin850 committed Jan 28, 2017
1 parent f22a17a commit 5e21e92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

* Remove the `rel` and `rev` attributes from the output generated
for footnotes as they don't pass the HTML 5 validation.

Fixes #536.

* Automatically enable the `fenced_code_blocks` option passing a
`HTML_TOC` object to the `Markdown` object's constructor since
some languages rely on the sharp to comment code.
Expand Down
4 changes: 2 additions & 2 deletions ext/redcarpet/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ rndr_footnote_def(struct buf *ob, const struct buf *text, unsigned int num, void
bufprintf(ob, "\n<li id=\"fn%d\">\n", num);
if (pfound) {
bufput(ob, text->data, i);
bufprintf(ob, "&nbsp;<a href=\"#fnref%d\" rev=\"footnote\">&#8617;</a>", num);
bufprintf(ob, "&nbsp;<a href=\"#fnref%d\">&#8617;</a>", num);
bufput(ob, text->data + i, text->size - i);
} else if (text) {
bufput(ob, text->data, text->size);
Expand All @@ -667,7 +667,7 @@ rndr_footnote_def(struct buf *ob, const struct buf *text, unsigned int num, void
static int
rndr_footnote_ref(struct buf *ob, unsigned int num, void *opaque)
{
bufprintf(ob, "<sup id=\"fnref%d\"><a href=\"#fn%d\" rel=\"footnote\">%d</a></sup>", num, num, num);
bufprintf(ob, "<sup id=\"fnref%d\"><a href=\"#fn%d\">%d</a></sup>", num, num, num);
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions test/html_render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ def test_that_footnotes_work
Markdown

html = <<-HTML.chomp.strip_heredoc
<p>This is a footnote.<sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup></p>
<p>This is a footnote.<sup id="fnref1"><a href="#fn1">1</a></sup></p>
<div class="footnotes">
<hr>
<ol>
<li id="fn1">
<p>It provides additional information.&nbsp;<a href="#fnref1" rev="footnote">&#8617;</a></p>
<p>It provides additional information.&nbsp;<a href="#fnref1">&#8617;</a></p>
</li>
</ol>
Expand Down

0 comments on commit 5e21e92

Please sign in to comment.