mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Allow leading pipes to be ommitted
https://github.com/ruby/rdoc/commit/d263a2c9c4
This commit is contained in:
parent
a19bf47d03
commit
f6c916c7ef
2 changed files with 207 additions and 96 deletions
|
@ -15910,7 +15910,7 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# Table = &{ github? } TableRow:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }
|
||||
# Table = &{ github? } TableHead:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }
|
||||
def _Table
|
||||
|
||||
_save = self.pos
|
||||
|
@ -15922,7 +15922,7 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_tmp = apply(:_TableRow)
|
||||
_tmp = apply(:_TableHead)
|
||||
header = @result
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
|
@ -15966,18 +15966,18 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableRow = TableItem+:row "|"? @Newline { row }
|
||||
def _TableRow
|
||||
# TableHead = TableItem2+:items "|"? @Newline { items }
|
||||
def _TableHead
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
_save1 = self.pos
|
||||
_ary = []
|
||||
_tmp = apply(:_TableItem)
|
||||
_tmp = apply(:_TableItem2)
|
||||
if _tmp
|
||||
_ary << @result
|
||||
while true
|
||||
_tmp = apply(:_TableItem)
|
||||
_tmp = apply(:_TableItem2)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
|
@ -15986,7 +15986,7 @@ class RDoc::Markdown
|
|||
else
|
||||
self.pos = _save1
|
||||
end
|
||||
row = @result
|
||||
items = @result
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
break
|
||||
|
@ -16006,6 +16006,99 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
@result = begin; items ; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
set_failed_rule :_TableHead unless _tmp
|
||||
return _tmp
|
||||
end
|
||||
|
||||
# TableRow = ((TableItem:item1 TableItem2*:items { [item1, *items] }):row | TableItem2+:row) "|"? @Newline { row }
|
||||
def _TableRow
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
|
||||
_save1 = self.pos
|
||||
while true # choice
|
||||
|
||||
_save2 = self.pos
|
||||
while true # sequence
|
||||
_tmp = apply(:_TableItem)
|
||||
item1 = @result
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
_ary = []
|
||||
while true
|
||||
_tmp = apply(:_TableItem2)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
@result = _ary
|
||||
items = @result
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
@result = begin; [item1, *items] ; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
row = @result
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
_save4 = self.pos
|
||||
_ary = []
|
||||
_tmp = apply(:_TableItem2)
|
||||
if _tmp
|
||||
_ary << @result
|
||||
while true
|
||||
_tmp = apply(:_TableItem2)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
@result = _ary
|
||||
else
|
||||
self.pos = _save4
|
||||
end
|
||||
row = @result
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
break
|
||||
end # end choice
|
||||
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_save5 = self.pos
|
||||
_tmp = match_string("|")
|
||||
unless _tmp
|
||||
_tmp = true
|
||||
self.pos = _save5
|
||||
end
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_tmp = _Newline()
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
break
|
||||
end
|
||||
@result = begin; row ; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
|
@ -16018,8 +16111,8 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableItem = "|" < (!"|" !@Newline .)+ > { text.strip }
|
||||
def _TableItem
|
||||
# TableItem2 = "|" TableItem
|
||||
def _TableItem2
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
|
@ -16028,6 +16121,22 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_tmp = apply(:_TableItem)
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
set_failed_rule :_TableItem2 unless _tmp
|
||||
return _tmp
|
||||
end
|
||||
|
||||
# TableItem = < (!"|" !@Newline .)+ > { text.strip }
|
||||
def _TableItem
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
_text_start = self.pos
|
||||
_save1 = self.pos
|
||||
|
||||
|
@ -16109,36 +16218,77 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableLine = TableColumn+:line "|"? @Newline { line }
|
||||
# TableLine = ((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line | TableAlign2+:line) "|"? @Newline { line }
|
||||
def _TableLine
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
|
||||
_save1 = self.pos
|
||||
_ary = []
|
||||
_tmp = apply(:_TableColumn)
|
||||
if _tmp
|
||||
_ary << @result
|
||||
while true
|
||||
_tmp = apply(:_TableColumn)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
@result = _ary
|
||||
else
|
||||
while true # choice
|
||||
|
||||
_save2 = self.pos
|
||||
while true # sequence
|
||||
_tmp = apply(:_TableAlign)
|
||||
align1 = @result
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
_ary = []
|
||||
while true
|
||||
_tmp = apply(:_TableAlign2)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
@result = _ary
|
||||
aligns = @result
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
@result = begin; [align1, *aligns] ; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
line = @result
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
end
|
||||
line = @result
|
||||
_save4 = self.pos
|
||||
_ary = []
|
||||
_tmp = apply(:_TableAlign2)
|
||||
if _tmp
|
||||
_ary << @result
|
||||
while true
|
||||
_tmp = apply(:_TableAlign2)
|
||||
_ary << @result if _tmp
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
@result = _ary
|
||||
else
|
||||
self.pos = _save4
|
||||
end
|
||||
line = @result
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
break
|
||||
end # end choice
|
||||
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_save2 = self.pos
|
||||
_save5 = self.pos
|
||||
_tmp = match_string("|")
|
||||
unless _tmp
|
||||
_tmp = true
|
||||
self.pos = _save2
|
||||
self.pos = _save5
|
||||
end
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
|
@ -16161,8 +16311,8 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableColumn = "|" < ("-"+ ":"? | ":" "-"*) > { text.start_with?(":") ? :left : text.end_with?(":") ? :right : nil }
|
||||
def _TableColumn
|
||||
# TableAlign2 = "|" TableAlign
|
||||
def _TableAlign2
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
|
@ -16171,66 +16321,24 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
_tmp = apply(:_TableAlign)
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
set_failed_rule :_TableAlign2 unless _tmp
|
||||
return _tmp
|
||||
end
|
||||
|
||||
# TableAlign = < /:?-+:?/ > { text.start_with?(":") ? :left : text.end_with?(":") ? :right : nil }
|
||||
def _TableAlign
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
_text_start = self.pos
|
||||
|
||||
_save1 = self.pos
|
||||
while true # choice
|
||||
|
||||
_save2 = self.pos
|
||||
while true # sequence
|
||||
_save3 = self.pos
|
||||
_tmp = match_string("-")
|
||||
if _tmp
|
||||
while true
|
||||
_tmp = match_string("-")
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
else
|
||||
self.pos = _save3
|
||||
end
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
_save4 = self.pos
|
||||
_tmp = match_string(":")
|
||||
unless _tmp
|
||||
_tmp = true
|
||||
self.pos = _save4
|
||||
end
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
|
||||
_save5 = self.pos
|
||||
while true # sequence
|
||||
_tmp = match_string(":")
|
||||
unless _tmp
|
||||
self.pos = _save5
|
||||
break
|
||||
end
|
||||
while true
|
||||
_tmp = match_string("-")
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
self.pos = _save5
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
break if _tmp
|
||||
self.pos = _save1
|
||||
break
|
||||
end # end choice
|
||||
|
||||
_tmp = scan(/\G(?-mix::?-+:?)/)
|
||||
if _tmp
|
||||
text = get_text(_text_start)
|
||||
end
|
||||
|
@ -16248,7 +16356,7 @@ class RDoc::Markdown
|
|||
break
|
||||
end # end sequence
|
||||
|
||||
set_failed_rule :_TableColumn unless _tmp
|
||||
set_failed_rule :_TableAlign unless _tmp
|
||||
return _tmp
|
||||
end
|
||||
|
||||
|
@ -16684,11 +16792,14 @@ class RDoc::Markdown
|
|||
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)? 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 }")
|
||||
Rules[:_TableItem] = rule_info("TableItem", "\"|\" < (!\"|\" !@Newline .)+ > { text.strip }")
|
||||
Rules[:_TableLine] = rule_info("TableLine", "TableColumn+:line \"|\"? @Newline { line }")
|
||||
Rules[:_TableColumn] = rule_info("TableColumn", "\"|\" < (\"-\"+ \":\"? | \":\" \"-\"*) > { text.start_with?(\":\") ? :left : text.end_with?(\":\") ? :right : nil }")
|
||||
Rules[:_Table] = rule_info("Table", "&{ github? } TableHead:header TableLine:line TableRow+:body { table = RDoc::Markup::Table.new(header, line, body) }")
|
||||
Rules[:_TableHead] = rule_info("TableHead", "TableItem2+:items \"|\"? @Newline { items }")
|
||||
Rules[:_TableRow] = rule_info("TableRow", "((TableItem:item1 TableItem2*:items { [item1, *items] }):row | TableItem2+:row) \"|\"? @Newline { row }")
|
||||
Rules[:_TableItem2] = rule_info("TableItem2", "\"|\" TableItem")
|
||||
Rules[:_TableItem] = rule_info("TableItem", "< (!\"|\" !@Newline .)+ > { text.strip }")
|
||||
Rules[:_TableLine] = rule_info("TableLine", "((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line | TableAlign2+:line) \"|\"? @Newline { line }")
|
||||
Rules[:_TableAlign2] = rule_info("TableAlign2", "\"|\" TableAlign")
|
||||
Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > { text.start_with?(\":\") ? :left : text.end_with?(\":\") ? :right : nil }")
|
||||
Rules[:_DefinitionList] = rule_info("DefinitionList", "&{ definition_lists? } DefinitionListItem+:list { RDoc::Markup::List.new :NOTE, *list.flatten }")
|
||||
Rules[:_DefinitionListItem] = rule_info("DefinitionListItem", "DefinitionListLabel+:label DefinitionListDefinition+:defns { list_items = [] list_items << RDoc::Markup::ListItem.new(label, defns.shift) list_items.concat defns.map { |defn| RDoc::Markup::ListItem.new nil, defn } unless list_items.empty? list_items }")
|
||||
Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "StrChunk:label @Sp @Newline { label }")
|
||||
|
|
|
@ -1065,9 +1065,9 @@ and an extra note.[^2]
|
|||
def test_gfm_table_2
|
||||
doc = parse <<~MD
|
||||
| Cmd | Returns | Meaning
|
||||
|-----|---------|--------
|
||||
| "b" | boolean | True if file1 is a block device
|
||||
| "c" | boolean | True if file1 is a character device
|
||||
------|---------|--------
|
||||
|"b" | boolean | True if file1 is a block device
|
||||
"c" | boolean | True if file1 is a character device
|
||||
MD
|
||||
|
||||
head = %w[Cmd Returns Meaning]
|
||||
|
|
Loading…
Reference in a new issue