Permalink
Browse files

Implement inline notes

  • Loading branch information...
1 parent e3d05f1 commit 51da2bd4445c655f1a257f4ebbec73a3a7a97bd8 @drbrain drbrain committed Oct 31, 2011
Showing with 23 additions and 3 deletions.
  1. +8 −3 pegdown.kpeg
  2. +15 −0 test/test_pegdown.rb
View
@@ -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 } )+
View
@@ -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]"

0 comments on commit 51da2bd

Please sign in to comment.