Permalink
Browse files

Use anchor instead of id for headers

Try to be consistent across the examples and the code and also try to be
a bit more descriptive ; anchor is more understandable than simply id.
  • Loading branch information...
robin850 committed Jan 12, 2014
1 parent 2f4cd5f commit ccbd6bf41d13f41b5d6327857e57b5e18f84839a
Showing with 7 additions and 7 deletions.
  1. +1 −1 CHANGELOG.md
  2. +1 −1 README.markdown
  3. +1 −1 ext/redcarpet/html.c
  4. +2 −2 ext/redcarpet/markdown.c
  5. +2 −2 test/html_toc_render_test.rb
View
@@ -1,6 +1,6 @@
# Changelog
-* Yield the humanized id of the headers
+* Yield the anchor of the headers
Using the `header` callback, it's now possible to get access to the
humanized generated id to easily keep tracking of the tree of headers
View
@@ -235,7 +235,7 @@ end
* block_html(raw_html)
* footnotes(content)
* footnote_def(content, number)
-* header(text, header_level, id)
+* header(text, header_level, anchor)
* hrule()
* list(contents, list_type)
* list_item(text, list_type)
View
@@ -265,7 +265,7 @@ rndr_linebreak(struct buf *ob, void *opaque)
return 1;
}
-char *header_id(const struct buf *text)
+char *header_anchor(const struct buf *text)
{
VALUE str = rb_str_new2(bufcstr(text));
VALUE space_regex = rb_reg_new(" +", 2 /* length */, 0);
View
@@ -1712,7 +1712,7 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
parse_inline(header_work, rndr, work.data, work.size);
if (rndr->cb.header)
- rndr->cb.header(ob, header_work, (int)level, header_id(header_work), rndr->opaque);
+ rndr->cb.header(ob, header_work, (int)level, header_anchor(header_work), rndr->opaque);
rndr_popbuf(rndr, BUFFER_SPAN);
}
@@ -1992,7 +1992,7 @@ parse_atxheader(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
parse_inline(work, rndr, data + i, end - i);
if (rndr->cb.header)
- rndr->cb.header(ob, work, (int)level, header_id(work), rndr->opaque);
+ rndr->cb.header(ob, work, (int)level, header_anchor(work), rndr->opaque);
rndr_popbuf(rndr, BUFFER_SPAN);
}
@@ -3,8 +3,8 @@
class HTMLTOCRenderTest < Test::Unit::TestCase
class CustomTocRender < Redcarpet::Render::HTML_TOC
- def header(text, level, id)
- "<h#{level} id=\"foo-bar-#{id}\">#{text}</h1>"
+ def header(text, level, anchor)
+ "<h#{level} id=\"foo-bar-#{anchor}\">#{text}</h1>"
end
end

0 comments on commit ccbd6bf

Please sign in to comment.