diff --git a/lib/rdoc/markdown.kpeg b/lib/rdoc/markdown.kpeg index 0e15a604f4..7ca3eb9e59 100644 --- a/lib/rdoc/markdown.kpeg +++ b/lib/rdoc/markdown.kpeg @@ -1234,10 +1234,12 @@ InlineNote = &{ notes? } @StartList:a ( !"]" Inline:l { a << l } )+ "]" - { ref = [:inline, @note_order.length] - @footnotes[ref] = paragraph a + { if @note_order + ref = [:inline, @note_order.length] + @footnotes[ref] = paragraph a - note_for ref + note_for ref + end } Notes = ( Note | SkipBlock )* diff --git a/lib/rdoc/markdown.rb b/lib/rdoc/markdown.rb index c01cab0096..e9e2912df1 100644 --- a/lib/rdoc/markdown.rb +++ b/lib/rdoc/markdown.rb @@ -15476,7 +15476,7 @@ def _Note return _tmp end - # InlineNote = &{ notes? } "^[" @StartList:a (!"]" Inline:l { a << l })+ "]" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref } + # InlineNote = &{ notes? } "^[" @StartList:a (!"]" Inline:l { a << l })+ "]" { if @note_order ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref end } def _InlineNote _save = self.pos @@ -15567,10 +15567,12 @@ def _InlineNote self.pos = _save break end - @result = begin; ref = [:inline, @note_order.length] - @footnotes[ref] = paragraph a + @result = begin; if @note_order + ref = [:inline, @note_order.length] + @footnotes[ref] = paragraph a - note_for ref + note_for ref + end ; end _tmp = true unless _tmp @@ -16841,7 +16843,7 @@ def _DefinitionListDefinition Rules[:_NoteReference] = rule_info("NoteReference", "&{ notes? } RawNoteReference:ref { note_for ref }") Rules[:_RawNoteReference] = rule_info("RawNoteReference", "\"[^\" < (!@Newline !\"]\" .)+ > \"]\" { text }") Rules[:_Note] = rule_info("Note", "&{ notes? } @NonindentSpace RawNoteReference:ref \":\" @Sp @StartList:a RawNoteBlock:i { a.concat i } (&Indent RawNoteBlock:i { a.concat i })* { @footnotes[ref] = paragraph a nil }") - Rules[:_InlineNote] = rule_info("InlineNote", "&{ notes? } \"^[\" @StartList:a (!\"]\" Inline:l { a << l })+ \"]\" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }") + Rules[:_InlineNote] = rule_info("InlineNote", "&{ notes? } \"^[\" @StartList:a (!\"]\" Inline:l { a << l })+ \"]\" { if @note_order ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref end }") Rules[:_Notes] = rule_info("Notes", "(Note | SkipBlock)*") Rules[:_RawNoteBlock] = rule_info("RawNoteBlock", "@StartList:a (!@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }") Rules[:_CodeFence] = rule_info("CodeFence", "&{ github? } Ticks3 (@Sp StrChunk:format)? @Sp @Newline? < ((!\"`\" Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* { verbatim = RDoc::Markup::Verbatim.new text verbatim.format = format.intern if format.instance_of?(String) verbatim }") diff --git a/test/rdoc/rdoc_markdown_test.rb b/test/rdoc/rdoc_markdown_test.rb index 646f12a999..f2542f5157 100644 --- a/test/rdoc/rdoc_markdown_test.rb +++ b/test/rdoc/rdoc_markdown_test.rb @@ -1002,6 +1002,12 @@ def test_parse_note_inline assert_equal expected, doc end + def test_parse_note_inline_in_reference_label + @parser.notes = true + + assert_kind_of RDoc::Markup::Document, parse("[foo ^[note]]: /url\n") + end + def test_parse_note_no_notes @parser.notes = false