Permalink
Browse files

use <a name=...> instead of <h1 id=...> for heading anchors

  • Loading branch information...
1 parent dc9b1ce commit ea79c1231b6b3d8795477b5d41beea802aeb7032 @tmm1 tmm1 committed with rtomayko Jan 25, 2011
Showing with 5 additions and 6 deletions.
  1. +1 −1 discount
  2. +3 −4 ext/generate.c
  3. +1 −1 test/rdiscount_test.rb
View
@@ -1312,13 +1312,12 @@ text(MMIOT *f)
static void
printheader(Paragraph *pp, MMIOT *f)
{
- Qprintf(f, "<h%d", pp->hnumber);
if ( f->flags & MKD_TOC ) {
- Qprintf(f, " id=\"", pp->hnumber);
+ Qprintf(f, "<a name=\"", pp->hnumber);
mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Qchar, f, 1);
- Qchar('"', f);
+ Qprintf(f, "\"></a>\n");
}
- Qchar('>', f);
+ Qprintf(f, "<h%d>", pp->hnumber);
push(T(pp->text->text), S(pp->text->text), f);
text(f);
Qprintf(f, "</h%d>", pp->hnumber);
View
@@ -48,7 +48,7 @@ def test_that_smart_gives_d_suffix_a_rsquo
def test_that_generate_toc_sets_toc_ids
rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
assert rd.generate_toc
- assert_equal %(<h1 id="Level.1">Level 1</h1>\n\n<h2 id="Level.2">Level 2</h2>\n), rd.to_html
+ assert_equal %(<a name="Level.1"></a>\n<h1>Level 1</h1>\n\n<a name="Level.2"></a>\n<h2>Level 2</h2>\n), rd.to_html
end
def test_should_get_the_generated_toc

0 comments on commit ea79c12

Please sign in to comment.