This repository was archived by the owner on Jan 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def self.plain_text(md_table)
43
43
md_table !~ // && raise ( 'Invalid input' )
44
44
45
45
# Split the table into lines to get the labels, rows, and alignments.
46
- lines = md_table . split ( "\n " )
46
+ lines = md_table . split ( "\n " ) . map { | l | l . gsub ( /^ \| | \| $/ , '' ) }
47
47
alignments = lines [ 1 ] . split ( '|' )
48
48
# labels or rows might have some empty values but alignments
49
49
# is guaranteed to be of the right width.
Original file line number Diff line number Diff line change @@ -113,19 +113,19 @@ def test_make_table
113
113
114
114
def test_plain_text
115
115
assert_equal (
116
- MarkdownTables . plain_text ( "a|b|c\n :-:|:-:|:-:\n 1| 2|3\n 4| 5|6\n 7| 8|9" ) ,
116
+ MarkdownTables . plain_text ( "| a|b|c| \n | :-:|:-:|:-:| \n |1| 2|3| \n |4| 5|6| \n |7| 8|9| " ) ,
117
117
"|===|===|===|\n | a | b | c |\n |===|===|===|\n | 1 | 2 | 3 |\n |---|---|---|\n | 4 | 5 | 6 |\n |---|---|---|\n | 7 | 8 | 9 |\n |===|===|===|" ,
118
118
)
119
119
assert_equal (
120
- MarkdownTables . plain_text ( "aaaaa|bbbbb|ccccc\n -:|:-:|:-\n 1| 2|3\n 4| 5|6\n 7| 8|9" ) ,
120
+ MarkdownTables . plain_text ( "| aaaaa|bbbbb|ccccc| \n | -:|:-:|:-| \n |1| 2|3| \n |4| 5|6| \n |7| 8|9| " ) ,
121
121
"|=======|=======|=======|\n | aaaaa | bbbbb | ccccc |\n |=======|=======|=======|\n | 1 | 2 | 3 |\n |-------|-------|-------|\n | 4 | 5 | 6 |\n |-------|-------|-------|\n | 7 | 8 | 9 |\n |=======|=======|=======|" ,
122
122
)
123
123
assert_equal (
124
- MarkdownTables . plain_text ( "a|b|c\n :-:|:-:|:-:\n 1| 4|7\n ||8 \n |6 |" ) ,
124
+ MarkdownTables . plain_text ( "| a|b|c| \n | :-:|:-:|:-:| \n |1| 4|7| \n |||8| \n ||6| |" ) ,
125
125
"|===|===|===|\n | a | b | c |\n |===|===|===|\n | 1 | 4 | 7 |\n |---|---|---|\n | | | 8 |\n |---|---|---|\n | | 6 | |\n |===|===|===|" ,
126
126
)
127
127
assert_equal (
128
- MarkdownTables . plain_text ( "||\n :-:|:-:|:-:\n ||\n ||\n ||" ) ,
128
+ MarkdownTables . plain_text ( "|||| \n | :-:|:-:|:-:| \n |||| \n |||| \n || ||" ) ,
129
129
"|===|===|===|\n | | | |\n |===|===|===|\n | | | |\n |---|---|---|\n | | | |\n |---|---|---|\n | | | |\n |===|===|===|"
130
130
)
131
131
end
You can’t perform that action at this time.
0 commit comments