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

e4e054e3ce 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.

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| @note_order.each_with_index do |ref, index|
label = index + 1 label = index + 1
note = @footnotes[ref] note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] " link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
note.parts.unshift link note.parts.unshift link
@ -15533,7 +15533,7 @@ class RDoc::Markdown
return _tmp return _tmp
end 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 def _RawNoteBlock
_save = self.pos _save = self.pos
@ -15556,6 +15556,14 @@ class RDoc::Markdown
self.pos = _save2 self.pos = _save2
break break
end end
_save4 = self.pos
_tmp = apply(:_RawNoteReference)
_tmp = _tmp ? nil : true
self.pos = _save4
unless _tmp
self.pos = _save2
break
end
_tmp = apply(:_OptionallyIndentedLine) _tmp = apply(:_OptionallyIndentedLine)
l = @result l = @result
unless _tmp unless _tmp
@ -15573,26 +15581,34 @@ class RDoc::Markdown
if _tmp if _tmp
while true while true
_save4 = self.pos _save5 = self.pos
while true # sequence while true # sequence
_save5 = self.pos _save6 = self.pos
_tmp = _BlankLine() _tmp = _BlankLine()
_tmp = _tmp ? nil : true _tmp = _tmp ? nil : true
self.pos = _save5 self.pos = _save6
unless _tmp 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 break
end end
_tmp = apply(:_OptionallyIndentedLine) _tmp = apply(:_OptionallyIndentedLine)
l = @result l = @result
unless _tmp unless _tmp
self.pos = _save4 self.pos = _save5
break break
end end
@result = begin; a << l ; end @result = begin; a << l ; end
_tmp = true _tmp = true
unless _tmp unless _tmp
self.pos = _save4 self.pos = _save5
end end
break break
end # end sequence 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[:_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 })+ \"]\" { ref = [:inline, @note_order.length] @footnotes[ref] = paragraph a note_for ref }")
Rules[:_Notes] = rule_info("Notes", "(Note | SkipBlock)*") 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[:_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[:_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 }") 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] and an extra note.[^2]
[^1]: With a footnote [^1]: With a footnote
[^2]: Which should be numbered correctly [^2]: Which should be numbered correctly
MD MD