Fix Maruku Footnote Backlink

Problem reported by Shamaoke.
This commit is contained in:
Jacques Distler 2011-06-18 15:54:32 -05:00
parent 9e909d5be3
commit 8b008f8418
2 changed files with 30 additions and 1 deletions

View file

@ -216,6 +216,21 @@ END_THM
end end
def test_footnotes
assert_markup_parsed_as("<p>Ruby on Rails is a web-framework<sup id='fnref:1'><a href='#fn" +
":1' rel='footnote'>1</a></sup>. It uses the MVC<sup id='fnref:2'><a href='#fn:2' rel='foo" +
"tnote'>2</a></sup> architecture pattern. It has its good points<sup id='fnref:3'><a href=" +
"'#fn:3' rel='footnote'>3</a></sup>.</p>\n<div class='footnotes'><hr/><ol><li id='fn:1'>\n" +
"<p>a reusable set of libraries <a href='#fnref:1' rev='footnote'>\342\206\251</a></p>\n</li><li" +
" id='fn:2'>\n<p>Model View Controller <a href='#fnref:2' rev='footnote'>\342\206\251</a></p>\n<" +
"/li><li id='fn:3'>\n<p>Here are its good points</p>\n\n<ol>\n<li>Ease of use</li>\n\n<li>" +
"Rapid development</li>\n</ol>\n<a href='#fnref:3' rev='footnote'>\342\206\251</a></li></ol></div>",
"Ruby on Rails is a web-framework[^framework]. It uses the MVC[^MVC] architecture pattern." +
" It has its good points[^points].\n\n[^framework]: a reusable set of libraries\n\n[^MVC]:" +
" Model View Controller\n\n[^points]: Here are its good points\n1. Ease of use\n2. Rapid d" +
"evelopment")
end
def test_ial_in_lists def test_ial_in_lists
assert_markup_parsed_as( assert_markup_parsed_as(

View file

@ -326,7 +326,21 @@ Example:
a.attributes['href'] = "\##{get_setting(:doc_prefix)}fnref:#{num}" a.attributes['href'] = "\##{get_setting(:doc_prefix)}fnref:#{num}"
a.attributes['rev'] = 'footnote' a.attributes['rev'] = 'footnote'
a<< Text.new('&#8617;', true, nil, true) a<< Text.new('&#8617;', true, nil, true)
li.insert_after(li.children.last, a)
last = nil
li.children.reverse_each do |child|
if child.node_type != :text
last = child
break
end
end
if last and last.name == "p"
last.add_text(' ');
last.add(a);
else
li.insert_after(li.children.last, a)
end
ol << li ol << li
else else
maruku_error "Could not find footnote id '#{fid}' among ["+ maruku_error "Could not find footnote id '#{fid}' among ["+