Skip to content

Commit

Permalink
Implement inline notes
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Oct 31, 2011
1 parent e3d05f1 commit 51da2bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pegdown.kpeg
Expand Up @@ -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 } )+
Expand Down
15 changes: 15 additions & 0 deletions test/test_pegdown.rb
Expand Up @@ -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]"
Expand Down

0 comments on commit 51da2bd

Please sign in to comment.