diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb
index c17fd4cb..60d10024 100644
--- a/test/unit/page_renderer_test.rb
+++ b/test/unit/page_renderer_test.rb
@@ -216,6 +216,21 @@ END_THM
end
+ def test_footnotes
+ assert_markup_parsed_as("
Ruby on Rails is a web-framework1. It uses the MVC2 architecture pattern. It has its good points3.
\n",
+ "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
assert_markup_parsed_as(
diff --git a/vendor/plugins/maruku/lib/maruku/output/to_html.rb b/vendor/plugins/maruku/lib/maruku/output/to_html.rb
index ebbdbad1..7c4375c1 100644
--- a/vendor/plugins/maruku/lib/maruku/output/to_html.rb
+++ b/vendor/plugins/maruku/lib/maruku/output/to_html.rb
@@ -326,7 +326,21 @@ Example:
a.attributes['href'] = "\##{get_setting(:doc_prefix)}fnref:#{num}"
a.attributes['rev'] = 'footnote'
a<< Text.new('↩', 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
else
maruku_error "Could not find footnote id '#{fid}' among ["+