Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@
def parse markdown
@references = {}
@unlinked_references = {}
@footnotes = nil
@note_order = nil
Comment thread
skatkov marked this conversation as resolved.
Outdated

markdown += "\n\n"

Expand Down Expand Up @@ -1234,7 +1236,9 @@ InlineNote = &{ notes? }
@StartList:a
( !"]" Inline:l { a << l } )+
"]"
{ ref = [:inline, @note_order.length]
{ raise ParseError, 'invalid inline note' unless @note_order
Comment thread
skatkov marked this conversation as resolved.
Outdated

ref = [:inline, @note_order.length]
@footnotes[ref] = paragraph a

note_for ref
Expand Down
10 changes: 7 additions & 3 deletions lib/rdoc/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@ def paragraph parts
def parse markdown
@references = {}
@unlinked_references = {}
@footnotes = nil
@note_order = nil

markdown += "\n\n"

Expand Down Expand Up @@ -15476,7 +15478,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 })+ "]" { raise ParseError, 'invalid inline note' unless @note_order ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }
def _InlineNote

_save = self.pos
Expand Down Expand Up @@ -15567,7 +15569,9 @@ def _InlineNote
self.pos = _save
break
end
@result = begin; ref = [:inline, @note_order.length]
@result = begin; raise ParseError, 'invalid inline note' unless @note_order

ref = [:inline, @note_order.length]
@footnotes[ref] = paragraph a

note_for ref
Expand Down Expand Up @@ -16841,7 +16845,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 })+ \"]\" { raise ParseError, 'invalid inline note' unless @note_order ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }")
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 }")
Expand Down
12 changes: 12 additions & 0 deletions test/rdoc/rdoc_markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,18 @@ def test_parse_note_inline
assert_equal expected, doc
end

def test_parse_note_inline_in_reference_label_after_reuse
@parser.notes = true

parse "Some text. ^[With a footnote]"

error = assert_raise RDoc::Markdown::ParseError do
parse "[foo ^[note]]: /url\n"
end

assert_equal 'invalid inline note', error.message
end

def test_parse_note_no_notes
@parser.notes = false

Expand Down
Loading