Skip to content

Commit afb29fd

Browse files
author
Makoto Chiba
committed
Merge pull request #2 from hypermkt/linefeed-support
Support for the linefeed
2 parents 4f5bc50 + 4d3fe8c commit afb29fd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

copyAsMarkdown.spBundle/command.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CopyAsMarkdown
8888
if (!empty($str)) {
8989
$str .= "|";
9090
}
91-
$str .= $val;
91+
$str .= str_replace(array("\n", "\r"), '', nl2br($val));
9292
}
9393
$result[] = $str;
9494
}

lib/CopyAsMarkdown/CopyAsMarkdown.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ protected function _createDataRows(array $rows)
8181
if (!empty($str)) {
8282
$str .= "|";
8383
}
84-
$str .= $val;
84+
$str .= str_replace(array("\n", "\r"), '', nl2br($val));
8585
}
8686
$result[] = $str;
8787
}
8888
return implode("\n", $result);
8989
}
90-
}
90+
}

tests/lib/CopyAsMarkdown/CopyAsMarkdownTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ public function testCreateDataRows()
3333
array('d', 'e', 'f'),
3434
)));
3535
}
36+
37+
public function testCreateDataRows_ReturnLineFeedRemovedData_WhenHasLineFeedInData()
38+
{
39+
$expected = 'a|b1<br />b2<br />b3|c';
40+
$this->assertEquals($expected, $this->copyAsMarkdown->createDataRows(array(
41+
array('a', 'b1
42+
b2
43+
b3', 'c'),
44+
)));
45+
}
3646
}
3747

3848
class CopyAsMarkdownExtended extends CopyAsMarkdown

0 commit comments

Comments
 (0)