New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PHP-Markdown style footnotes support #271
Conversation
I have a few questions:
Thanks! ❤️ |
I'll defer to @bdolman for the first and second points since it is his code. As for the third, I can add tests for when footnotes are enabled but either the marker or definitions are missing. Anything else? |
add additional footnote tests
I assumed this was already supported by redcarpet. Good job @brief, and thanks for the pull request. |
rndr_footnotes(struct buf *ob, const struct buf *text, void *opaque) | ||
{ | ||
if (ob->size) bufputc(ob, '\n'); | ||
BUFPUTSL(ob, "<div class=\"footnotes\">\n<hr>\n<ol>\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a detail but I would update this line like this:
if (ob->size) bufputc(ob, '\n');
BUFPUTSL(ob, "<div class=\"footnotes\">\n");
BUFPUTSL(ob, USE_XHTML(options) ? "<hr/>\n" : "<hr>\n");
BUFPUTSL(ob, "<ol>\n");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With that at the very top of the function (sorry forgot about that):
struct html_renderopt *options = opaque;
If it's almost good enough, I'd merge it into a separate branch, make any On Thu, Jul 11, 2013 at 6:43 AM, Robin Dupret notifications@github.comwrote:
|
Ready to merge? |
@robin850 would you mind merging this? I'm recovering from a conference and most likely won't have time to spend on this for another few days. Thanks! |
Apologies for the delay, here are some answers to earlier questions:
It matches the data structures being used for storing links, which are similar to footnotes. To be completely accurate, links are stored using a very basic hash table predefined to contain at most 8 buckets (I believe it's 8—it's been months since I've looked at the code, but that's my recollection). Footnotes are stored in a single linked list because I didn't feel like I needed something quite as optimized as links and since it was a hardcoded 8 buckets anyway, I just didn't think that 99.9% of the use cases of footnotes would benefit from the additional complexity I'd have to put in the footnotes code.
I did not, but I have run the Clang static analyzer and fixed any issues I found there. It's also been out in the wild for many, many months on apps with user bases in the millions and we haven't seen any issues. |
awesome! thanks for getting back to us! It's very much appreciated! 😃 |
@bdolman : Awesome! Thanks a lot! |
Add PHP-Markdown style footnotes support Conflicts: test/html_render_test.rb
Finally, merge this. Thanks everyone! 🤘 ❤️ |
@djui opened an identical pull request a month ago, but it has stalled. Thought I would submit my own with the requested changes.
This includes the great original work by @bdolman and @adamflorin, a fix to footnote parsing by @microjo, a test case in
test/html_render_test.rb
, and edits to the changelog and readme.