mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/rdoc] Add center align
https://github.com/ruby/rdoc/commit/512cc55a0e
This commit is contained in:
parent
28e24ce355
commit
cf3056be69
2 changed files with 12 additions and 70 deletions
|
@ -16132,73 +16132,13 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableItem = < (!"|" !@Newline .)+ > { text.strip }
|
||||
# TableItem = < /(?:\\.|[^|\n])+/ > { text.strip.gsub(/\\(.)/, '\1') }
|
||||
def _TableItem
|
||||
|
||||
_save = self.pos
|
||||
while true # sequence
|
||||
_text_start = self.pos
|
||||
_save1 = self.pos
|
||||
|
||||
_save2 = self.pos
|
||||
while true # sequence
|
||||
_save3 = self.pos
|
||||
_tmp = match_string("|")
|
||||
_tmp = _tmp ? nil : true
|
||||
self.pos = _save3
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
_save4 = self.pos
|
||||
_tmp = _Newline()
|
||||
_tmp = _tmp ? nil : true
|
||||
self.pos = _save4
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
break
|
||||
end
|
||||
_tmp = get_byte
|
||||
unless _tmp
|
||||
self.pos = _save2
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
if _tmp
|
||||
while true
|
||||
|
||||
_save5 = self.pos
|
||||
while true # sequence
|
||||
_save6 = self.pos
|
||||
_tmp = match_string("|")
|
||||
_tmp = _tmp ? nil : true
|
||||
self.pos = _save6
|
||||
unless _tmp
|
||||
self.pos = _save5
|
||||
break
|
||||
end
|
||||
_save7 = self.pos
|
||||
_tmp = _Newline()
|
||||
_tmp = _tmp ? nil : true
|
||||
self.pos = _save7
|
||||
unless _tmp
|
||||
self.pos = _save5
|
||||
break
|
||||
end
|
||||
_tmp = get_byte
|
||||
unless _tmp
|
||||
self.pos = _save5
|
||||
end
|
||||
break
|
||||
end # end sequence
|
||||
|
||||
break unless _tmp
|
||||
end
|
||||
_tmp = true
|
||||
else
|
||||
self.pos = _save1
|
||||
end
|
||||
_tmp = scan(/\G(?-mix:(?:\\.|[^|\n])+)/)
|
||||
if _tmp
|
||||
text = get_text(_text_start)
|
||||
end
|
||||
|
@ -16206,7 +16146,7 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
@result = begin; text.strip ; end
|
||||
@result = begin; text.strip.gsub(/\\(.)/, '\1') ; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
self.pos = _save
|
||||
|
@ -16337,7 +16277,7 @@ class RDoc::Markdown
|
|||
return _tmp
|
||||
end
|
||||
|
||||
# TableAlign = < /:?-+:?/ > @Sp { text.start_with?(":") ? :left : text.end_with?(":") ? :right : nil }
|
||||
# TableAlign = < /:?-+:?/ > @Sp { text.start_with?(":") ? (text.end_with?(":") ? :center : :left) : (text.end_with?(":") ? :right : nil) }
|
||||
def _TableAlign
|
||||
|
||||
_save = self.pos
|
||||
|
@ -16356,8 +16296,10 @@ class RDoc::Markdown
|
|||
self.pos = _save
|
||||
break
|
||||
end
|
||||
@result = begin; text.start_with?(":") ? :left :
|
||||
text.end_with?(":") ? :right : nil
|
||||
@result = begin;
|
||||
text.start_with?(":") ?
|
||||
(text.end_with?(":") ? :center : :left) :
|
||||
(text.end_with?(":") ? :right : nil)
|
||||
; end
|
||||
_tmp = true
|
||||
unless _tmp
|
||||
|
@ -16806,10 +16748,10 @@ class RDoc::Markdown
|
|||
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[:_TableItem] = rule_info("TableItem", "< /(?:\\\\.|[^|\\n])+/ > { text.strip.gsub(/\\\\(.)/, '\\1') }")
|
||||
Rules[:_TableLine] = rule_info("TableLine", "((TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] }):line | TableAlign2+:line) \"|\"? @Newline { line }")
|
||||
Rules[:_TableAlign2] = rule_info("TableAlign2", "\"|\" @Sp TableAlign")
|
||||
Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > @Sp { text.start_with?(\":\") ? :left : text.end_with?(\":\") ? :right : nil }")
|
||||
Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > @Sp { text.start_with?(\":\") ? (text.end_with?(\":\") ? :center : :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,14 +1065,14 @@ 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
|
||||
|"\|" | boolean | escaped bar \| test
|
||||
MD
|
||||
|
||||
head = %w[Cmd Returns Meaning]
|
||||
align = [nil, nil, nil]
|
||||
align = [nil, :center, nil]
|
||||
body = [
|
||||
['"b"', 'boolean', 'True if file1 is a block device'],
|
||||
['"c"', 'boolean', 'True if file1 is a character device'],
|
||||
|
|
Loading…
Reference in a new issue