1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/rdoc] Allow multiple footnotes without in-between blank lines

https://github.com/ruby/ruby/commit/e4e054e3ce40 used four footnotes
without blank lines.  And the ChangeLog generated from that commit
resulted in ``undefined method `parts' for nil`` error.

For now, let a footnote terminated by the next footnote mark.

Also refined the error message when undefined footnote is used.

https://github.com/ruby/rdoc/commit/a7f290130b
This commit is contained in:
Nobuyoshi Nakada 2022-08-08 00:32:37 +09:00
parent 23a84d53c6
commit 5beb75ce8d
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 25 additions and 10 deletions

View file

@ -811,7 +811,7 @@ class RDoc::Markdown
@note_order.each_with_index do |ref, index|
label = index + 1
note = @footnotes[ref]
note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
note.parts.unshift link
@ -15533,7 +15533,7 @@ class RDoc::Markdown
return _tmp
end
# RawNoteBlock = @StartList:a (!@BlankLine OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }
# RawNoteBlock = @StartList:a (!@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }
def _RawNoteBlock
_save = self.pos
@ -15556,6 +15556,14 @@ class RDoc::Markdown
self.pos = _save2
break
end
_save4 = self.pos
_tmp = apply(:_RawNoteReference)
_tmp = _tmp ? nil : true
self.pos = _save4
unless _tmp
self.pos = _save2
break
end
_tmp = apply(:_OptionallyIndentedLine)
l = @result
unless _tmp
@ -15573,26 +15581,34 @@ class RDoc::Markdown
if _tmp
while true
_save4 = self.pos
_save5 = self.pos
while true # sequence
_save5 = self.pos
_save6 = self.pos
_tmp = _BlankLine()
_tmp = _tmp ? nil : true
self.pos = _save5
self.pos = _save6
unless _tmp
self.pos = _save4
self.pos = _save5
break
end
_save7 = self.pos
_tmp = apply(:_RawNoteReference)
_tmp = _tmp ? nil : true
self.pos = _save7
unless _tmp
self.pos = _save5
break
end
_tmp = apply(:_OptionallyIndentedLine)
l = @result
unless _tmp
self.pos = _save4
self.pos = _save5
break
end
@result = begin; a << l ; end
_tmp = true
unless _tmp
self.pos = _save4
self.pos = _save5
end
break
end # end sequence
@ -16656,7 +16672,7 @@ class RDoc::Markdown
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[:_Notes] = rule_info("Notes", "(Note | SkipBlock)*")
Rules[:_RawNoteBlock] = rule_info("RawNoteBlock", "@StartList:a (!@BlankLine OptionallyIndentedLine:l { a << l })+ < @BlankLine* > { a << text } { a }")
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)? Spnl < ((!\"`\" Nonspacechar)+ | !Ticks3 /`+/ | Spacechar | @Newline)+ > Ticks3 @Sp @Newline* { verbatim = RDoc::Markup::Verbatim.new text verbatim.format = format.intern if format.instance_of?(String) verbatim }")
Rules[:_Table] = rule_info("Table", "&{ github? } TableRow:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }")
Rules[:_TableRow] = rule_info("TableRow", "TableItem+:row \"|\" @Newline { row }")

View file

@ -761,7 +761,6 @@ with inline notes^[like this]
and an extra note.[^2]
[^1]: With a footnote
[^2]: Which should be numbered correctly
MD