diff --git a/pegdown.kpeg b/pegdown.kpeg index de3540e..0982ba8 100644 --- a/pegdown.kpeg +++ b/pegdown.kpeg @@ -811,10 +811,15 @@ Note = &{ notes? } InlineNote = &{ notes? } "^[" StartList:a - ( !"]" Inline { raise " a = cons($$, a); " } )+ + ( !"]" Inline:l { a << l } )+ "]" - { raise '$$ = mk_list(NOTE, a); - $$->contents.str = 0; '} + { ref = @footnotes.length + 1 + a.unshift note ref + + @footnotes << RDoc::Markup::Paragraph.new(*a) + + note_for ref + } RawNoteBlock = StartList:a ( !BlankLine OptionallyIndentedLine:l { a << l } )+ diff --git a/test/test_pegdown.rb b/test/test_pegdown.rb index 8577b8d..4a631b3 100644 --- a/test/test_pegdown.rb +++ b/test/test_pegdown.rb @@ -334,6 +334,21 @@ def test_parse_note assert_equal expected, doc end + def test_parse_note_inline + @parser.notes = true + + doc = parse <<-MD +Some text. ^[With a footnote] + MD + + expected = doc( + para("Some text. {*1}[rdoc-label:foottext-1:footmark-1]"), + @RM::Rule.new(1), + para("{^1}[rdoc-label:footmark-1:foottext-1] With a footnote")) + + assert_equal expected, doc + end + def test_parse_note_no_notes assert_raises RuntimeError do parse "Some text.[^1]"